ソースを参照

Play2 activate removal (#2719)

Nate 8 年 前
コミット
b15239ae6b

+ 0 - 33
frameworks/Scala/play2-scala/play2-scala-activate/.gitignore

@@ -1,33 +0,0 @@
-logs
-project/project
-project/target
-public
-target
-test
-tmp
-.history
-dist
-conf/evolutions
-
-# Ignore all dotfiles...
-.*
-# except for .gitignore
-!.gitignore
-
-# Ignore Play! working directory #
-db
-eclipse
-lib
-log
-logs
-modules
-precompiled
-project/project
-project/target
-target
-tmp
-test-result
-server.pid
-*.iml
-*.eml
-

+ 0 - 7
frameworks/Scala/play2-scala/play2-scala-activate/app/Global.scala

@@ -1,7 +0,0 @@
-import play.api._
-import com.typesafe.config.ConfigFactory
-
-object Global extends GlobalSettings {
-	System.setProperty("activate.offlineLocking.enable", "true")
-	System.setProperty("activate.offlineLocking.validateReads", "true")
-}

+ 0 - 91
frameworks/Scala/play2-scala/play2-scala-activate/app/controllers/Application.scala

@@ -1,91 +0,0 @@
-package controllers
-
-import play.api.Play.current
-import play.api.mvc._
-import play.api.libs.json.Json
-import java.util.concurrent._
-import scala.concurrent._
-import scala.concurrent.Future
-import play.api.libs.concurrent.Execution.Implicits._
-import play.core.NamedThreadFactory
-import models.ActivateWorld
-import models.Models._
-import models.ActivateFortune
-import models.persistenceContext._
-
-object Application extends Controller {
-
-  def getRandomWorlds(n: Int): Seq[ActivateWorld] = {
-      val random = ThreadLocalRandom.current()
-      for (_ <- 1 to n) yield {
-          val randomId = random.nextInt(TestDatabaseRows) + 1
-          ActivateWorld.fingByLegacyId(randomId)
-      }
-  }
-
-  def getFortunes(): Seq[ActivateFortune] = {
-      ActivateFortune.all
-  }
-
-  def updateWorlds(n: Int): Seq[ActivateWorld] = {
-      val random = ThreadLocalRandom.current()
-      for (_ <- 1 to n) yield {
-            val randomId = random.nextInt(TestDatabaseRows) + 1
-            val world = ActivateWorld.fingByLegacyId(randomId)
-            world.randomNumber = random.nextInt(10000) + 1
-            world
-      }
-  }
-
-  // Common(ish) code between Scala database code
-
-  protected val TestDatabaseRows = 10000
-
-  def db = Action {
-      transactional {
-          val worlds = getRandomWorlds(1)
-          Ok(Json.toJson(worlds.head))
-      }
-  }
-
-  def queries(countString: String) = Action {
-      val n = parseCount(countString)
-      transactional {
-          val worlds = getRandomWorlds(n)
-          Ok(Json.toJson(worlds))
-      }
-  }
-
-  def fortunes() = Action {
-      val transaction = new Transaction
-      try
-          transactional(transaction) {
-              val dbFortunes = getFortunes()
-              val appendedFortunes =  new ActivateFortune(0, "Additional fortune added at request time.") :: (dbFortunes.to[List])
-              Ok(views.html.fortune(appendedFortunes))
-          }
-      finally
-          transaction.rollback
-  }
-
-  def update(queries: String) = Action {
-      transactional {
-          val n = parseCount(queries)
-          val worlds = updateWorlds(n)
-          Ok(Json.toJson(worlds))
-      }
-  }
-
-  private def parseCount(s: String): Int = {
-      try {
-          val parsed = java.lang.Integer.parseInt(s, 10)
-          parsed match {
-              case i if i < 1 => 1
-              case i if i > 500 => 500
-              case i => i
-          }
-      } catch {
-          case _: NumberFormatException => 1
-      }
-  }
-}

+ 0 - 66
frameworks/Scala/play2-scala/play2-scala-activate/app/models/Migrations.scala

@@ -1,66 +0,0 @@
-package models
-
-import persistenceContext._
-
-class CreateSchema extends Migration {
-
-    def timestamp = System.currentTimeMillis + 100
-
-    def up = {
-        removeAllEntitiesTables.cascade.ifExists
-        createTableForAllEntities.ifNotExists
-    }
-
-}
-
-class MigrateFortunes extends Migration {
-
-    def timestamp = System.currentTimeMillis + 200
-
-    def up = {
-        customScript {
-            val con = storage.directAccess
-            try {
-                val rs = con.createStatement.executeQuery("SELECT id, message FROM Fortune")
-                while (rs.next)
-                    new ActivateFortune(rs.getLong(1), rs.getString(2))
-            } finally
-                con.close
-        }
-    }
-
-}
-
-class MigrateWorlds extends Migration {
-
-    def timestamp = System.currentTimeMillis + 300
-
-    def up = {
-        customScript {
-            val con = storage.directAccess
-            try {
-                val rs = con.createStatement.executeQuery("SELECT id, randomNumber FROM World")
-                while (rs.next)
-                    new ActivateWorld(rs.getLong(1), rs.getInt(2))
-            } finally
-                con.close
-        }
-    }
-
-}
-
-class CreateVersionIndexes extends Migration {
-    
-    def timestamp = System.currentTimeMillis + 400
-    
-    def up = {
-        customScript {
-            val con = storage.directAccess
-            try {
-                con.createStatement.executeUpdate("CREATE UNIQUE INDEX IX_WORLD_VERSION ON ActivateWorld(id, version)")
-                con.createStatement.executeUpdate("CREATE UNIQUE INDEX IX_FORTUNE_VERSION ON ActivateFortune(id, version)")
-            } finally
-                con.close
-        }
-    }
-}

+ 0 - 35
frameworks/Scala/play2-scala/play2-scala-activate/app/models/Models.scala

@@ -1,35 +0,0 @@
-package models
-
-import persistenceContext._
-import play.api.libs.json.JsValue
-import play.api.libs.json.Json
-import play.api.libs.json.Json.toJsFieldJsValueWrapper
-import play.api.libs.json.Writes
-
-class ActivateFortune(val legacyId: Long, val message: String) extends Entity
-
-object ActivateFortune {
-    def all = indexFortuneAll.get(1)
-}
-
-class ActivateWorld(val legacyId: Long, var randomNumber: Long) extends Entity
-
-object ActivateWorld {
-    def fingByLegacyId(legacyId: Long) =
-        indexWorldByLegacyId
-            .get(legacyId)
-            .headOption
-            .getOrElse(throw new IllegalStateException("invalid id " + legacyId))
-}
-
-object Models {
-
-    implicit val worldToJson =
-        new Writes[ActivateWorld] {
-            def writes(w: ActivateWorld): JsValue =
-                Json.obj(
-                    "id" -> w.legacyId,
-                    "randomNumber" -> w.randomNumber)
-        }
-
-}

+ 0 - 28
frameworks/Scala/play2-scala/play2-scala-activate/app/models/PersistenceContext.scala

@@ -1,28 +0,0 @@
-package models
-
-import net.fwbrasil.activate.ActivateContext
-import net.fwbrasil.activate.storage.relational.idiom.postgresqlDialect
-import net.fwbrasil.activate.storage.relational.PooledJdbcRelationalStorage
-import net.fwbrasil.activate.storage.relational.idiom.mySqlDialect
-import play.api.Play
-import net.fwbrasil.activate.OptimisticOfflineLocking
-
-object persistenceContext extends ActivateContext {
-	require(OptimisticOfflineLocking.isEnabled)
-	require(OptimisticOfflineLocking.validateReads)
-    
-    private def config = Play.current.configuration
-    
-    val storage = new PooledJdbcRelationalStorage {
-        val jdbcDriver = config.getString("db.default.driver").get
-        val user = config.getString("db.default.user").get
-        val password = config.getString("db.default.password").get
-        val url = config.getString("db.default.url").get
-        val dialect = mySqlDialect
-        override val poolSize = 400
-    }
-    
-    val indexWorldByLegacyId = memoryIndex[ActivateWorld].on(_.legacyId)
-    val indexFortuneAll = memoryIndex[ActivateFortune].on(_ => 1)
-
-}

+ 0 - 18
frameworks/Scala/play2-scala/play2-scala-activate/app/views/fortune.scala.html

@@ -1,18 +0,0 @@
-@(fortunes: List[ActivateFortune])
-
-@main("Fortunes") {
-    <table>
-        <tr>
-            <th>id</th>
-            <th>message</th>
-        </tr>
-
-        @fortunes.sortBy(_.message).map { fortune => 
-            <tr>
-                <td>@fortune.legacyId</td>
-                <td>@fortune.message</td>
-            </tr>
-        }
-
-    </table>
-}

+ 0 - 12
frameworks/Scala/play2-scala/play2-scala-activate/app/views/main.scala.html

@@ -1,12 +0,0 @@
-@(title: String)(content: Html)
-
-<!DOCTYPE html>
-
-<html>
-<head>
-    <title>@title</title>
-</head>
-<body>
-    @content
-</body>
-</html>

+ 0 - 88
frameworks/Scala/play2-scala/play2-scala-activate/conf/application.conf

@@ -1,88 +0,0 @@
-# This is the main configuration file for the application.
-# ~~~~~
-
-# Secret key
-# ~~~~~
-# The secret key is used to secure cryptographics functions.
-# If you deploy your application to several instances be sure to use the same key!
-application.secret="RItx1I:80?W@]8GAtPDuF8Ydd3mXM85p/<7og]Q;uBOdijQAauRDgu73B6`wQP59"
-
-# The application languages
-# ~~~~~
-application.langs="en"
-
-# Global object class
-# ~~~~~
-# Define the Global object class for this application.
-# Default to Global in the root package.
-# global=Global
-
-# Database configuration
-# ~~~~~ 
-# You can declare as many datasources as you want.
-# By convention, the default datasource is named `default`
-#
-#db.default.driver=org.h2.Driver
-#db.default.url="jdbc:h2:mem:play"
-#db.default.user=sa
-# db.default.password=
-#
-# You can expose this datasource via JNDI if needed (Useful for JPA)
-# db.default.jndiName=DefaultDS
-db.default.driver=com.mysql.jdbc.Driver
-db.default.url="jdbc:mysql://localhost:3306/hello_world?jdbcCompliantTruncation=false&elideSetAutoCommits=true&useLocalSessionState=true&cachePrepStmts=true&cacheCallableStmts=true&alwaysSendSetIsolation=false&prepStmtCacheSize=4096&cacheServerConfiguration=true&prepStmtCacheSqlLimit=2048&zeroDateTimeBehavior=convertToNull&traceProtocol=false&useUnbufferedInput=false&useReadAheadInput=false&maintainTimeStats=false&useServerPrepStmts&cacheRSMetadata=true"
-db.default.user=benchmarkdbuser
-db.default.password=benchmarkdbpass
-db.default.jndiName=DefaultDS
-
-# db.default.partitionCount=4
-
-# The number of connections to create per partition. Setting this to 
-# 5 with 3 partitions means you will have 15 unique connections to the 
-# database. Note that BoneCP will not create all these connections in 
-# one go but rather start off with minConnectionsPerPartition and 
-# gradually increase connections as required.
-# db.default.maxConnectionsPerPartition=64
-
-# The number of initial connections, per partition.
-# db.default.minConnectionsPerPartition=64
-
-# Evolutions
-# ~~~~~
-# You can disable evolutions if needed
-evolutionplugin=disabled
-
-# Logger
-# ~~~~~
-# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
-
-# Root logger:
-logger.root=ERROR
-
-# Logger used by the framework:
-logger.play=ERROR
-
-# Logger provided to your application:
-logger.application=ERROR
-
-iteratee-threadpool-size=300
-
-play {
-  akka {
-    event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
-    loglevel = ERROR
-    actor {
-      default-dispatcher = {
-        fork-join-executor {
-          parallelism-factor = 4.0
-          parallelism-max = 300
-        }
-      }
-      application = {
-        fork-join-executor {
-          parallelism-max = 300
-        }
-      }
-    }
-  }
-}

+ 0 - 1
frameworks/Scala/play2-scala/play2-scala-activate/conf/play.plugins

@@ -1 +0,0 @@
-100:net.fwbrasil.activate.play.ActivatePlayPlugin

+ 0 - 12
frameworks/Scala/play2-scala/play2-scala-activate/conf/routes

@@ -1,12 +0,0 @@
-# Routes
-# This file defines all application routes (Higher priority routes first)
-# ~~~~
-
-# Home page
-GET     /db                             controllers.Application.db
-GET     /queries                        controllers.Application.queries(queries ?= "1")
-GET     /fortunes                       controllers.Application.fortunes
-GET     /update                         controllers.Application.update(queries ?= "1")
-
-# Map static resources from the /public folder to the /assets URL path
-GET     /assets/*file                   controllers.Assets.at(path="/public", file)

+ 0 - 28
frameworks/Scala/play2-scala/play2-scala-activate/project/Build.scala

@@ -1,28 +0,0 @@
-import sbt._
-import Keys._
-import play.Project._
-
-object ApplicationBuild extends Build {
-
-  val appName         = "play2-scala-activate"
-  val appVersion      = "1.0-SNAPSHOT"
-
-  val activateVersion = "1.4.4"
-  val activateCore = "net.fwbrasil" %% "activate-core" % activateVersion
-  val activateJdbc = "net.fwbrasil" %% "activate-jdbc" % activateVersion
-  val activatePlay = "net.fwbrasil" %% "activate-play" % activateVersion
-
-  val mysql = "mysql" % "mysql-connector-java" % "5.1.38"
-
-  val appDependencies = Seq(
-    mysql,
-    activateCore,
-    activateJdbc,
-    activatePlay
-  )
-
-  val main = play.Project(appName, appVersion, appDependencies).settings(
-	  resolvers ++= Seq("fwbrasil.net" at "http://fwbrasil.net/maven/")
-  )
-
-}

+ 0 - 1
frameworks/Scala/play2-scala/play2-scala-activate/project/build.properties

@@ -1 +0,0 @@
-sbt.version=0.13.0

+ 0 - 8
frameworks/Scala/play2-scala/play2-scala-activate/project/plugins.sbt

@@ -1,8 +0,0 @@
-// Comment to get more information during initialization
-logLevel := Level.Warn
-
-// The Typesafe repository 
-resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
-
-// Use the Play sbt plugin for Play projects
-addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.0")

+ 0 - 14
frameworks/Scala/play2-scala/setup_scala_activate.sh

@@ -1,14 +0,0 @@
-#!/bin/bash
-
-fw_depends mysql java sbt
-
-cd play2-scala-activate
-sed -i 's|jdbc:mysql://.*:3306|jdbc:mysql://'"${DBHOST}"':3306|g' $TROOT/play2-scala-activate/conf/application.conf
-
-rm -rf $TROOT/play2-scala-activate/target/universal/stage/RUNNING_PID
-
-# Stage application.
-sbt stage
-
-# Execute Start script in background.
-$TROOT/play2-scala-activate/target/universal/stage/bin/play2-scala-activate &