diff --git a/akka-core/src/main/scala/util/ListenerManagement.scala b/akka-core/src/main/scala/util/ListenerManagement.scala index 7316beba64..8b53cc7d0a 100644 --- a/akka-core/src/main/scala/util/ListenerManagement.scala +++ b/akka-core/src/main/scala/util/ListenerManagement.scala @@ -31,8 +31,8 @@ trait ListenerManagement extends Logging { * The listener is stopped by this method. */ def removeListener(listener: ActorRef) = { - listener.stop listeners.remove(listener) + listener.stop } /** diff --git a/akka-samples/akka-sample-lift/src/main/scala/akka/SimpleService.scala b/akka-samples/akka-sample-lift/src/main/scala/akka/SimpleService.scala index 7557404da9..4d20b60448 100644 --- a/akka-samples/akka-sample-lift/src/main/scala/akka/SimpleService.scala +++ b/akka-samples/akka-sample-lift/src/main/scala/akka/SimpleService.scala @@ -1,35 +1,24 @@ package sample.lift -import se.scalablesolutions.akka.actor.{Transactor, Actor} +import se.scalablesolutions.akka.actor._ +import se.scalablesolutions.akka.actor.Actor._ import se.scalablesolutions.akka.config.ScalaConfig._ import se.scalablesolutions.akka.stm.TransactionalMap import se.scalablesolutions.akka.persistence.cassandra.CassandraStorage -import Actor._ - +import scala.xml.Node import java.lang.Integer import javax.ws.rs.{GET, Path, Produces} import java.nio.ByteBuffer +import net.liftweb.http._ +import net.liftweb.http.rest._ -/** - * Try service out by invoking (multiple times): - *
- * curl http://localhost:9998/liftcount
- * 
- * Or browse to the URL from a web browser. - */ -@Path("/liftcount") -class SimpleService extends Transactor { - case object Tick +class SimpleServiceActor extends Transactor { private val KEY = "COUNTER" private var hasStartedTicking = false private lazy val storage = TransactionalMap[String, Integer]() - @GET - @Produces(Array("text/html")) - def count = (self !! Tick).getOrElse(

Error in counter

) - def receive = { - case Tick => if (hasStartedTicking) { + case "Tick" => if (hasStartedTicking) { val counter = storage.get(KEY).get.asInstanceOf[Integer].intValue storage.put(KEY, new Integer(counter + 1)) self.reply(

Tick: {counter + 1}

) @@ -41,27 +30,14 @@ class SimpleService extends Transactor { } } -/** - * Try service out by invoking (multiple times): - *
- * curl http://localhost:9998/persistentliftcount
- * 
- * Or browse to the URL from a web browser. - */ -@Path("/persistentliftcount") -class PersistentSimpleService extends Transactor { +class PersistentServiceActor extends Transactor { - case object Tick private val KEY = "COUNTER" private var hasStartedTicking = false private lazy val storage = CassandraStorage.newMap - @GET - @Produces(Array("text/html")) - def count = (self !! Tick).getOrElse(

Error in counter

) - def receive = { - case Tick => if (hasStartedTicking) { + case "Tick" => if (hasStartedTicking) { val bytes = storage.get(KEY.getBytes).get val counter = ByteBuffer.wrap(bytes).getInt storage.put(KEY.getBytes, ByteBuffer.allocate(4).putInt(counter + 1).array) @@ -73,3 +49,46 @@ class PersistentSimpleService extends Transactor { } } } + + +/** + * Try service out by invoking (multiple times): + *
+ * curl http://localhost:8080/liftcount
+ * 
+ * Or browse to the URL from a web browser. + */ + +object SimpleRestService extends RestHelper { + serve { + case Get("liftcount" :: _, req) => + //Fetch the first actor of type SimpleServiceActor + //Send it the "Tick" message and expect a Node back + val result = for( a <- ActorRegistry.actorsFor(classOf[SimpleServiceActor]).headOption; + r <- (a !! "Tick").as[Node] ) yield r + + //Return either the resulting NodeSeq or a default one + (result getOrElse

Error in counter

).asInstanceOf[Node] + } +} + + +/** + * Try service out by invoking (multiple times): + *
+ * curl http://localhost:8080/persistentliftcount
+ * 
+ * Or browse to the URL from a web browser. + */ + object PersistentRestService extends RestHelper { + serve { + case Get("persistentliftcount" :: _, req) => + //Fetch the first actor of type SimpleServiceActor + //Send it the "Tick" message and expect a Node back + val result = for( a <- ActorRegistry.actorsFor(classOf[PersistentServiceActor]).headOption; + r <- (a !! "Tick").as[Node] ) yield r + + //Return either the resulting NodeSeq or a default one + (result getOrElse

Error in counter

).asInstanceOf[Node] + } + } \ No newline at end of file diff --git a/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala b/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala index 0f4a0e9020..2e56a5857a 100644 --- a/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala +++ b/akka-samples/akka-sample-lift/src/main/scala/bootstrap/liftweb/Boot.scala @@ -13,7 +13,7 @@ import se.scalablesolutions.akka.actor.Actor._ import se.scalablesolutions.akka.config.ScalaConfig._ import se.scalablesolutions.akka.util.Logging -import sample.lift.{PersistentSimpleService, SimpleService} +import sample.lift._ /** * A class that's instantiated early and run. It allows the application @@ -35,6 +35,8 @@ class Boot extends Logging { true } } + LiftRules.statelessDispatchTable.append(SimpleRestService) + LiftRules.statelessDispatchTable.append(PersistentRestService) LiftRules.passNotFoundToChain = true @@ -42,10 +44,10 @@ class Boot extends Logging { SupervisorConfig( RestartStrategy(OneForOne, 3, 100, List(classOf[Exception])), Supervise( - actorOf[SimpleService], + actorOf[SimpleServiceActor], LifeCycle(Permanent)) :: Supervise( - actorOf[PersistentSimpleService], + actorOf[PersistentServiceActor], LifeCycle(Permanent)) :: Nil)) factory.newInstance.start diff --git a/akka-samples/akka-sample-lift/src/main/webapp/WEB-INF/web.xml b/akka-samples/akka-sample-lift/src/main/webapp/WEB-INF/web.xml index 23348604bb..3a1b672cec 100644 --- a/akka-samples/akka-sample-lift/src/main/webapp/WEB-INF/web.xml +++ b/akka-samples/akka-sample-lift/src/main/webapp/WEB-INF/web.xml @@ -13,7 +13,7 @@ AkkaServlet - se.scalablesolutions.akka.rest.AkkaServlet + se.scalablesolutions.akka.comet.AkkaServlet AkkaServlet diff --git a/config/akka-reference.conf b/config/akka-reference.conf index 23412db3d3..c504598e31 100644 --- a/config/akka-reference.conf +++ b/config/akka-reference.conf @@ -57,7 +57,9 @@ akka { hostname = "localhost" port = 9998 filters = ["se.scalablesolutions.akka.security.AkkaSecurityFilterFactory"] # List with all jersey filters to use - resource_packages = ["sample.rest.scala","sample.rest.java","sample.security"] # List with all resource packages for your Jersey services + resource_packages = ["sample.rest.scala", + "sample.rest.java", + "sample.security"] # List with all resource packages for your Jersey services authenticator = "sample.security.BasicAuthenticationService" # The authentication service to use. Need to be overridden (uses sample now) #maxInactiveActivity = 60000 #Atmosphere CometSupport maxInactiveActivity #IF you are using a KerberosAuthenticationActor diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index a5ba9d0465..d1e125f07d 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -2,35 +2,20 @@ | Copyright (C) 2009-2010 Scalable Solutions AB | \---------------------------------------------------------------------------*/ -import sbt._ -import sbt.CompileOrder._ - -import spde._ +import com.weiglewilczek.bnd4sbt.BNDPlugin import de.tuxed.codefellow.plugin.CodeFellowPlugin - +import java.io.File import java.util.jar.Attributes import java.util.jar.Attributes.Name._ -import java.io.File +import sbt._ +import sbt.CompileOrder._ +import spde._ -import com.weiglewilczek.bnd4sbt._ - -class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { - - // ------------------------------------------------------------ - // project versions - val JERSEY_VERSION = "1.2" - val ATMO_VERSION = "0.6" - val CAMEL_VERSION = "2.4.0" - val SPRING_VERSION = "3.0.3.RELEASE" - val CASSANDRA_VERSION = "0.6.1" - val LIFT_VERSION = "2.0-scala280-SNAPSHOT" - val SCALATEST_VERSION = "1.2-for-scala-2.8.0.final-SNAPSHOT" - val MULTIVERSE_VERSION = "0.6-SNAPSHOT" - - // ------------------------------------------------------------ - lazy val deployPath = info.projectPath / "deploy" - lazy val distPath = info.projectPath / "dist" +class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { + // ------------------------------------------------------------------------------------------------------------------- + // Compile settings + // ------------------------------------------------------------------------------------------------------------------- override def compileOptions = super.compileOptions ++ Seq("-deprecation", "-Xmigration", @@ -39,57 +24,195 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { "-Xwarninit", "-encoding", "utf8") .map(x => CompileOption(x)) - override def javaCompileOptions = JavaCompileOption("-Xlint:unchecked") :: super.javaCompileOptions.toList + // ------------------------------------------------------------------------------------------------------------------- + // Deploy/dist settings + // ------------------------------------------------------------------------------------------------------------------- + lazy val deployPath = info.projectPath / "deploy" + lazy val distPath = info.projectPath / "dist" def distName = "%s_%s-%s.zip".format(name, buildScalaVersion, version) - lazy val dist = zipTask(allArtifacts, "dist", distName) dependsOn (`package`) describedAs("Zips up the distribution.") // ------------------------------------------------------------------------------------------------------------------- - // Repositories + // All repositories *must* go here! See ModuleConigurations below. + // ------------------------------------------------------------------------------------------------------------------- + object Repositories { + lazy val AkkaRepo = MavenRepository("Akka Repository", "http://scalablesolutions.se/akka/repository") + lazy val CodehausSnapshotRepo = MavenRepository("Codehaus Snapshots", "http://snapshots.repository.codehaus.org") + lazy val EmbeddedRepo = MavenRepository("Embedded Repo", (info.projectPath / "embedded-repo").asURL.toString) + lazy val GuiceyFruitRepo = MavenRepository("GuiceyFruit Repo", "http://guiceyfruit.googlecode.com/svn/repo/releases/") + lazy val JBossRepo = MavenRepository("JBoss Repo", "https://repository.jboss.org/nexus/content/groups/public/") + lazy val JavaNetRepo = MavenRepository("java.net Repo", "http://download.java.net/maven/2") + lazy val SonatypeSnapshotRepo = MavenRepository("Sonatype OSS Repo", "http://oss.sonatype.org/content/repositories/releases") + lazy val SunJDMKRepo = MavenRepository("Sun JDMK Repo", "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo") + } + + // ------------------------------------------------------------------------------------------------------------------- + // ModuleConfigurations // Every dependency that cannot be resolved from the built-in repositories (Maven Central and Scala Tools Releases) // must be resolved from a ModuleConfiguration. This will result in a significant acceleration of the update action. // Therefore, if repositories are defined, this must happen as def, not as val. // ------------------------------------------------------------------------------------------------------------------- - val embeddedRepo = "Embedded Repo" at (info.projectPath / "embedded-repo").asURL.toString - val scalaTestModuleConfig = ModuleConfiguration("org.scalatest", ScalaToolsSnapshots) - def guiceyFruitRepo = "GuiceyFruit Repo" at "http://guiceyfruit.googlecode.com/svn/repo/releases/" - val guiceyFruitModuleConfig = ModuleConfiguration("org.guiceyfruit", guiceyFruitRepo) - def jbossRepo = "JBoss Repo" at "https://repository.jboss.org/nexus/content/groups/public/" - val jbossModuleConfig = ModuleConfiguration("org.jboss", jbossRepo) - val nettyModuleConfig = ModuleConfiguration("org.jboss.netty", jbossRepo) - val jgroupsModuleConfig = ModuleConfiguration("jgroups", jbossRepo) - def sunjdmkRepo = "Sun JDMK Repo" at "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo" - val jmsModuleConfig = ModuleConfiguration("javax.jms", sunjdmkRepo) - val jdmkModuleConfig = ModuleConfiguration("com.sun.jdmk", sunjdmkRepo) - val jmxModuleConfig = ModuleConfiguration("com.sun.jmx", sunjdmkRepo) - def javaNetRepo = "java.net Repo" at "http://download.java.net/maven/2" - def sonatypeSnapshotRepo = "Sonatype OSS Repo" at "http://oss.sonatype.org/content/repositories/releases" - val jerseyModuleConfig = ModuleConfiguration("com.sun.jersey", javaNetRepo) - val jerseyContrModuleConfig = ModuleConfiguration("com.sun.jersey.contribs", javaNetRepo) - val grizzlyModuleConfig = ModuleConfiguration("com.sun.grizzly", javaNetRepo) - val atmosphereModuleConfig = ModuleConfiguration("org.atmosphere", sonatypeSnapshotRepo) - val liftModuleConfig = ModuleConfiguration("net.liftweb", ScalaToolsSnapshots) -// val scalaBundleConfig = ModuleConfiguration("com.weiglewilczek.scala-lang-osgi", ScalaToolsReleases) - def codehausSnapshotRepo = "Codehaus Snapshots" at "http://snapshots.repository.codehaus.org" - val multiverseModuleConfig = ModuleConfiguration("org.multiverse", codehausSnapshotRepo) + import Repositories._ + lazy val atmosphereModuleConfig = ModuleConfiguration("org.atmosphere", SonatypeSnapshotRepo) + lazy val grizzlyModuleConfig = ModuleConfiguration("com.sun.grizzly", JavaNetRepo) + lazy val guiceyFruitModuleConfig = ModuleConfiguration("org.guiceyfruit", GuiceyFruitRepo) + lazy val jbossModuleConfig = ModuleConfiguration("org.jboss", JBossRepo) + lazy val jdmkModuleConfig = ModuleConfiguration("com.sun.jdmk", SunJDMKRepo) + lazy val jerseyContrModuleConfig = ModuleConfiguration("com.sun.jersey.contribs", JavaNetRepo) + lazy val jerseyModuleConfig = ModuleConfiguration("com.sun.jersey", JavaNetRepo) + lazy val jgroupsModuleConfig = ModuleConfiguration("jgroups", JBossRepo) + lazy val jmsModuleConfig = ModuleConfiguration("javax.jms", SunJDMKRepo) + lazy val jmxModuleConfig = ModuleConfiguration("com.sun.jmx", SunJDMKRepo) + lazy val liftModuleConfig = ModuleConfiguration("net.liftweb", ScalaToolsSnapshots) + lazy val multiverseModuleConfig = ModuleConfiguration("org.multiverse", CodehausSnapshotRepo) + lazy val nettyModuleConfig = ModuleConfiguration("org.jboss.netty", JBossRepo) + lazy val scalaTestModuleConfig = ModuleConfiguration("org.scalatest", ScalaToolsSnapshots) + lazy val embeddedRepo = EmbeddedRepo // This is the only exception, because the embedded repo is fast! - // ------------------------------------------------------------ - // project defintions - lazy val akka_core = project("akka-core", "akka-core", new AkkaCoreProject(_)) - lazy val akka_amqp = project("akka-amqp", "akka-amqp", new AkkaAMQPProject(_), akka_core) - lazy val akka_http = project("akka-http", "akka-http", new AkkaHttpProject(_), akka_core, akka_camel) - lazy val akka_camel = project("akka-camel", "akka-camel", new AkkaCamelProject(_), akka_core) + // ------------------------------------------------------------------------------------------------------------------- + // Versions + // ------------------------------------------------------------------------------------------------------------------- + lazy val ATMO_VERSION = "0.6" + lazy val CAMEL_VERSION = "2.4.0" + lazy val CASSANDRA_VERSION = "0.6.1" + lazy val DispatchVersion = "0.7.4" + lazy val JacksonVersion = "1.2.1" + lazy val JERSEY_VERSION = "1.2" + lazy val LIFT_VERSION = "2.0-scala280-SNAPSHOT" + lazy val MULTIVERSE_VERSION = "0.6-SNAPSHOT" + lazy val SCALATEST_VERSION = "1.2-for-scala-2.8.0.final-SNAPSHOT" + lazy val Slf4jVersion = "1.6.0" + lazy val SPRING_VERSION = "3.0.3.RELEASE" + lazy val WerkzVersion = "2.2.1" + + // ------------------------------------------------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------------------------------------------------- + object Dependencies { + + // Compile + + lazy val annotation = "javax.annotation" % "jsr250-api" % "1.0" % "compile" + + lazy val aopalliance = "aopalliance" % "aopalliance" % "1.0" % "compile" + + lazy val atmo = "org.atmosphere" % "atmosphere-annotations" % ATMO_VERSION % "compile" + lazy val atmo_jbossweb = "org.atmosphere" % "atmosphere-compat-jbossweb" % ATMO_VERSION % "compile" + lazy val atmo_jersey = "org.atmosphere" % "atmosphere-jersey" % ATMO_VERSION % "compile" + lazy val atmo_runtime = "org.atmosphere" % "atmosphere-runtime" % ATMO_VERSION % "compile" + lazy val atmo_tomcat = "org.atmosphere" % "atmosphere-compat-tomcat" % ATMO_VERSION % "compile" + lazy val atmo_weblogic = "org.atmosphere" % "atmosphere-compat-weblogic" % ATMO_VERSION % "compile" + + lazy val atomikos_transactions = "com.atomikos" % "transactions" % "3.2.3" % "compile" + lazy val atomikos_transactions_api = "com.atomikos" % "transactions-api" % "3.2.3" % "compile" + lazy val atomikos_transactions_jta = "com.atomikos" % "transactions-jta" % "3.2.3" % "compile" + + lazy val camel_core = "org.apache.camel" % "camel-core" % CAMEL_VERSION % "compile" + + lazy val cassandra = "org.apache.cassandra" % "cassandra" % CASSANDRA_VERSION % "compile" + + lazy val commons_codec = "commons-codec" % "commons-codec" % "1.4" % "compile" + + lazy val commons_io = "commons-io" % "commons-io" % "1.4" % "compile" + + lazy val commons_logging = "commons-logging" % "commons-logging" % "1.1.1" % "compile" + + lazy val commons_pool = "commons-pool" % "commons-pool" % "1.5.4" % "compile" + + lazy val configgy = "net.lag" % "configgy" % "2.8.0-1.5.5" % "compile" + + lazy val dispatch_http = "net.databinder" % "dispatch-http_2.8.0" % DispatchVersion % "compile" + lazy val dispatch_json = "net.databinder" % "dispatch-json_2.8.0" % DispatchVersion % "compile" + + lazy val grizzly = "com.sun.grizzly" % "grizzly-comet-webserver" % "1.9.18-i" % "compile" + + lazy val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile" + + lazy val h2_lzf = "voldemort.store.compress" % "h2-lzf" % "1.0" % "compile" + + lazy val jackson = "org.codehaus.jackson" % "jackson-mapper-asl" % JacksonVersion % "compile" + lazy val jackson_core = "org.codehaus.jackson" % "jackson-core-asl" % JacksonVersion % "compile" + lazy val jackson_core_asl = "org.codehaus.jackson" % "jackson-core-asl" % JacksonVersion % "compile" + + lazy val jersey = "com.sun.jersey" % "jersey-core" % JERSEY_VERSION % "compile" + lazy val jersey_json = "com.sun.jersey" % "jersey-json" % JERSEY_VERSION % "compile" + lazy val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "compile" + lazy val jersey_contrib = "com.sun.jersey.contribs" % "jersey-scala" % JERSEY_VERSION % "compile" + + lazy val jgroups = "jgroups" % "jgroups" % "2.9.0.GA" % "compile" + + lazy val jsr166x = "jsr166x" % "jsr166x" % "1.0" % "compile" + + lazy val jsr250 = "javax.annotation" % "jsr250-api" % "1.0" % "compile" + + lazy val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile" + + lazy val jta_1_1 = "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1" % "compile" intransitive() + + lazy val lift = "net.liftweb" % "lift-webkit" % LIFT_VERSION % "compile" + lazy val lift_util = "net.liftweb" % "lift-util" % LIFT_VERSION % "compile" + + lazy val log4j = "log4j" % "log4j" % "1.2.15" % "compile" + + lazy val mongo = "org.mongodb" % "mongo-java-driver" % "1.4" % "compile" + + lazy val multiverse = "org.multiverse" % "multiverse-alpha" % MULTIVERSE_VERSION % "compile" intransitive() + + lazy val netty = "org.jboss.netty" % "netty" % "3.2.1.Final" % "compile" + + lazy val protobuf = "com.google.protobuf" % "protobuf-java" % "2.3.0" % "compile" + + lazy val rabbit = "com.rabbitmq" % "amqp-client" % "1.8.1" % "compile" + + lazy val redis = "com.redis" % "redisclient" % "2.8.0-1.4" % "compile" + + lazy val sbinary = "sbinary" % "sbinary" % "2.8.0-0.3.1" % "compile" + + lazy val servlet = "javax.servlet" % "servlet-api" % "2.5" % "compile" + + lazy val sjson = "sjson.json" % "sjson" % "0.7-SNAPSHOT-2.8.0" % "compile" + + lazy val slf4j = "org.slf4j" % "slf4j-api" % Slf4jVersion % "compile" + lazy val slf4j_log4j = "org.slf4j" % "slf4j-log4j12" % Slf4jVersion % "compile" + + lazy val spring_beans = "org.springframework" % "spring-beans" % SPRING_VERSION % "compile" + lazy val spring_context = "org.springframework" % "spring-context" % SPRING_VERSION % "compile" + + lazy val stax_api = "javax.xml.stream" % "stax-api" % "1.0-2" % "compile" + + lazy val thrift = "com.facebook" % "thrift" % "r917130" % "compile" + + lazy val werkz = "org.codehaus.aspectwerkz" % "aspectwerkz-nodeps-jdk5" % WerkzVersion % "compile" + lazy val werkz_core = "org.codehaus.aspectwerkz" % "aspectwerkz-jdk5" % WerkzVersion % "compile" + + // Test + + lazy val camel_spring = "org.apache.camel" % "camel-spring" % CAMEL_VERSION % "test" + lazy val cassandra_clhm = "org.apache.cassandra" % "clhm-production" % CASSANDRA_VERSION % "test" + lazy val commons_coll = "commons-collections" % "commons-collections" % "3.2.1" % "test" + lazy val google_coll = "com.google.collections" % "google-collections" % "1.0" % "test" + lazy val high_scale = "org.apache.cassandra" % "high-scale-lib" % CASSANDRA_VERSION % "test" + lazy val jettyServer = "org.mortbay.jetty" % "jetty" % "6.1.22" % "test" + lazy val junit = "junit" % "junit" % "4.5" % "test" + lazy val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" + lazy val scalatest = "org.scalatest" % "scalatest" % SCALATEST_VERSION % "test" + } + + // ------------------------------------------------------------------------------------------------------------------- + // Subprojects + // ------------------------------------------------------------------------------------------------------------------- + lazy val akka_core = project("akka-core", "akka-core", new AkkaCoreProject(_)) + lazy val akka_amqp = project("akka-amqp", "akka-amqp", new AkkaAMQPProject(_), akka_core) + lazy val akka_http = project("akka-http", "akka-http", new AkkaHttpProject(_), akka_core, akka_camel) + lazy val akka_camel = project("akka-camel", "akka-camel", new AkkaCamelProject(_), akka_core) lazy val akka_persistence = project("akka-persistence", "akka-persistence", new AkkaPersistenceParentProject(_)) - lazy val akka_spring = project("akka-spring", "akka-spring", new AkkaSpringProject(_), akka_core, akka_camel) - lazy val akka_jta = project("akka-jta", "akka-jta", new AkkaJTAProject(_), akka_core) - lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_), - akka_core, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp) - lazy val akka_osgi = project("akka-osgi", "akka-osgi", new AkkaOSGiParentProject(_)) - - // examples - lazy val akka_samples = project("akka-samples", "akka-samples", new AkkaSamplesParentProject(_)) + lazy val akka_spring = project("akka-spring", "akka-spring", new AkkaSpringProject(_), akka_core, akka_camel) + lazy val akka_jta = project("akka-jta", "akka-jta", new AkkaJTAProject(_), akka_core) + lazy val akka_kernel = project("akka-kernel", "akka-kernel", new AkkaKernelProject(_), + akka_core, akka_http, akka_spring, akka_camel, akka_persistence, akka_amqp) + lazy val akka_samples = project("akka-samples", "akka-samples", new AkkaSamplesParentProject(_)) // ------------------------------------------------------------ // Run Akka microkernel using 'sbt run' + use for packaging executable JAR @@ -177,103 +300,87 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { None } dependsOn(dist) describedAs("Run mvn install for artifacts in dist.") - // ------------------------------------------------------------ - // subprojects + // ------------------------------------------------------------------------------------------------------------------- + // akka-core subproject + // ------------------------------------------------------------------------------------------------------------------- class AkkaCoreProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with CodeFellowPlugin { - val netty = "org.jboss.netty" % "netty" % "3.2.1.Final" % "compile" - val commons_codec = "commons-codec" % "commons-codec" % "1.4" % "compile" - val commons_io = "commons-io" % "commons-io" % "1.4" % "compile" - val dispatch_json = "net.databinder" % "dispatch-json_2.8.0" % "0.7.4" % "compile" - val dispatch_http = "net.databinder" % "dispatch-http_2.8.0" % "0.7.4" % "compile" - val sjson = "sjson.json" % "sjson" % "0.7-SNAPSHOT-2.8.0" % "compile" - val sbinary = "sbinary" % "sbinary" % "2.8.0-0.3.1" % "compile" - val jackson = "org.codehaus.jackson" % "jackson-mapper-asl" % "1.2.1" % "compile" - val jackson_core = "org.codehaus.jackson" % "jackson-core-asl" % "1.2.1" % "compile" - val h2_lzf = "voldemort.store.compress" % "h2-lzf" % "1.0" % "compile" - val jsr166x = "jsr166x" % "jsr166x" % "1.0" % "compile" - val jta_1_1 = "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1" % "compile" intransitive() - val werkz = "org.codehaus.aspectwerkz" % "aspectwerkz-nodeps-jdk5" % "2.2.1" % "compile" - val werkz_core = "org.codehaus.aspectwerkz" % "aspectwerkz-jdk5" % "2.2.1" % "compile" - val configgy = "net.lag" % "configgy" % "2.8.0-1.5.5" % "compile" - val guicey = "org.guiceyfruit" % "guice-all" % "2.0" % "compile" - val aopalliance = "aopalliance" % "aopalliance" % "1.0" % "compile" - val protobuf = "com.google.protobuf" % "protobuf-java" % "2.3.0" % "compile" - val multiverse = "org.multiverse" % "multiverse-alpha" % MULTIVERSE_VERSION % "compile" intransitive() - val jgroups = "jgroups" % "jgroups" % "2.9.0.GA" % "compile" + val aopalliance = Dependencies.aopalliance + val commons_codec = Dependencies.commons_codec + val commons_io = Dependencies.commons_io + val configgy = Dependencies.configgy + val dispatch_http = Dependencies.dispatch_http + val dispatch_json = Dependencies.dispatch_json + val guicey = Dependencies.guicey + val h2_lzf = Dependencies.h2_lzf + val jackson = Dependencies.jackson + val jackson_core = Dependencies.jackson_core + val jgroups = Dependencies.jgroups + val jsr166x = Dependencies.jsr166x + val jta_1_1 = Dependencies.jta_1_1 + val multiverse = Dependencies.multiverse + val netty = Dependencies.netty + val protobuf = Dependencies.protobuf + val sbinary = Dependencies.sbinary + val sjson = Dependencies.sjson + val werkz = Dependencies.werkz + val werkz_core = Dependencies.werkz_core // testing - val scalatest = "org.scalatest" % "scalatest" % SCALATEST_VERSION % "test" - val junit = "junit" % "junit" % "4.5" % "test" + val junit = Dependencies.junit + val scalatest = Dependencies.scalatest } + // ------------------------------------------------------------------------------------------------------------------- + // akka-amqp subproject + // ------------------------------------------------------------------------------------------------------------------- class AkkaAMQPProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with CodeFellowPlugin { - val commons_io = "commons-io" % "commons-io" % "1.4" % "compile" - val rabbit = "com.rabbitmq" % "amqp-client" % "1.8.1" % "compile" + val commons_io = Dependencies.commons_io + val rabbit = Dependencies.rabbit // testing - val multiverse = "org.multiverse" % "multiverse-alpha" % MULTIVERSE_VERSION % "test" intransitive() - val scalatest = "org.scalatest" % "scalatest" % SCALATEST_VERSION % "test" - val junit = "junit" % "junit" % "4.5" % "test" + val junit = Dependencies.junit + val multiverse = Dependencies.multiverse + val scalatest = Dependencies.scalatest } + // ------------------------------------------------------------------------------------------------------------------- + // akka-http subproject + // ------------------------------------------------------------------------------------------------------------------- class AkkaHttpProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with CodeFellowPlugin { - val jackson_core_asl = "org.codehaus.jackson" % "jackson-core-asl" % "1.2.1" % "compile" - val stax_api = "javax.xml.stream" % "stax-api" % "1.0-2" % "compile" - val servlet = "javax.servlet" % "servlet-api" % "2.5" % "compile" - val jersey = "com.sun.jersey" % "jersey-core" % JERSEY_VERSION % "compile" - val jersey_server = "com.sun.jersey" % "jersey-server" % JERSEY_VERSION % "compile" - val jersey_json = "com.sun.jersey" % "jersey-json" % JERSEY_VERSION % "compile" - val jersey_contrib = "com.sun.jersey.contribs" % "jersey-scala" % JERSEY_VERSION % "compile" - val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1" % "compile" - val grizzly = "com.sun.grizzly" % "grizzly-comet-webserver" % "1.9.18-i" % "compile" - val atmo = "org.atmosphere" % "atmosphere-annotations" % ATMO_VERSION % "compile" - val atmo_jersey = "org.atmosphere" % "atmosphere-jersey" % ATMO_VERSION % "compile" - val atmo_runtime = "org.atmosphere" % "atmosphere-runtime" % ATMO_VERSION % "compile" - val atmo_tomcat = "org.atmosphere" % "atmosphere-compat-tomcat" % ATMO_VERSION % "compile" - val atmo_weblogic = "org.atmosphere" % "atmosphere-compat-weblogic" % ATMO_VERSION % "compile" - val atmo_jbossweb = "org.atmosphere" % "atmosphere-compat-jbossweb" % ATMO_VERSION % "compile" - val commons_logging = "commons-logging" % "commons-logging" % "1.1.1" % "compile" - val annotation = "javax.annotation" % "jsr250-api" % "1.0" % "compile" + val annotation = Dependencies.annotation + val atmo = Dependencies.atmo + val atmo_jbossweb = Dependencies.atmo_jbossweb + val atmo_jersey = Dependencies.atmo_jersey + val atmo_runtime = Dependencies.atmo_runtime + val atmo_tomcat = Dependencies.atmo_tomcat + val atmo_weblogic = Dependencies.atmo_weblogic + val commons_logging = Dependencies.commons_logging + val grizzly = Dependencies.grizzly + val jackson_core_asl = Dependencies.jackson_core_asl + val jersey = Dependencies.jersey + val jersey_contrib = Dependencies.jersey_contrib + val jersey_json = Dependencies.jersey_json + val jersey_server = Dependencies.jersey_server + val jsr311 = Dependencies.jsr311 + val servlet = Dependencies.servlet + val stax_api = Dependencies.stax_api // testing - val scalatest = "org.scalatest" % "scalatest" % SCALATEST_VERSION % "test" - val junit = "junit" % "junit" % "4.5" % "test" - val mockito = "org.mockito" % "mockito-all" % "1.8.1" % "test" + val junit = Dependencies.junit + val mockito = Dependencies.mockito + val scalatest = Dependencies.scalatest } + // ------------------------------------------------------------------------------------------------------------------- + // akka-camel subproject + // ------------------------------------------------------------------------------------------------------------------- class AkkaCamelProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with CodeFellowPlugin { - val camel_core = "org.apache.camel" % "camel-core" % CAMEL_VERSION % "compile" - } - - class AkkaPersistenceCommonProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { - val thrift = "com.facebook" % "thrift" % "r917130" % "compile" - val commons_pool = "commons-pool" % "commons-pool" % "1.5.4" % "compile" - } - - class AkkaRedisProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { - val redis = "com.redis" % "redisclient" % "2.8.0-1.4" % "compile" - val commons_codec = "commons-codec" % "commons-codec" % "1.4" % "compile" - override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil - } - - class AkkaMongoProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { - val mongo = "org.mongodb" % "mongo-java-driver" % "1.4" % "compile" - override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil - } - - class AkkaCassandraProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { - val cassandra = "org.apache.cassandra" % "cassandra" % CASSANDRA_VERSION % "compile" - val slf4j = "org.slf4j" % "slf4j-api" % "1.6.0" % "compile" - val slf4j_log4j = "org.slf4j" % "slf4j-log4j12" % "1.6.0" % "compile" - val log4j = "log4j" % "log4j" % "1.2.15" % "compile" - // testing - val high_scale = "org.apache.cassandra" % "high-scale-lib" % CASSANDRA_VERSION % "test" - val cassandra_clhm = "org.apache.cassandra" % "clhm-production" % CASSANDRA_VERSION % "test" - val commons_coll = "commons-collections" % "commons-collections" % "3.2.1" % "test" - val google_coll = "com.google.collections" % "google-collections" % "1.0" % "test" - override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil + val camel_core = Dependencies.camel_core } + // ------------------------------------------------------------------------------------------------------------------- + // akka-persistence subproject + // ------------------------------------------------------------------------------------------------------------------- class AkkaPersistenceParentProject(info: ProjectInfo) extends ParentProject(info) { lazy val akka_persistence_common = project("akka-persistence-common", "akka-persistence-common", new AkkaPersistenceCommonProject(_), akka_core) @@ -285,24 +392,78 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { new AkkaCassandraProject(_), akka_persistence_common) } - class AkkaKernelProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) - - class AkkaSpringProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with CodeFellowPlugin { - val spring_beans = "org.springframework" % "spring-beans" % SPRING_VERSION % "compile" - val spring_context = "org.springframework" % "spring-context" % SPRING_VERSION % "compile" - - // testing - val camel_spring = "org.apache.camel" % "camel-spring" % CAMEL_VERSION % "test" - val scalatest = "org.scalatest" % "scalatest" % SCALATEST_VERSION % "test" - val junit = "junit" % "junit" % "4.5" % "test" + // ------------------------------------------------------------------------------------------------------------------- + // akka-persistence-common subproject + // ------------------------------------------------------------------------------------------------------------------- + class AkkaPersistenceCommonProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + val commons_pool = Dependencies.commons_pool + val thrift = Dependencies.thrift } + // ------------------------------------------------------------------------------------------------------------------- + // akka-persistence-redis subproject + // ------------------------------------------------------------------------------------------------------------------- + class AkkaRedisProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + val commons_codec = Dependencies.commons_codec + val redis = Dependencies.redis + + override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil + } + + // ------------------------------------------------------------------------------------------------------------------- + // akka-persistence-mongo subproject + // ------------------------------------------------------------------------------------------------------------------- + class AkkaMongoProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + val mongo = Dependencies.mongo + + override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil + } + + // ------------------------------------------------------------------------------------------------------------------- + // akka-persistence-cassandra subproject + // ------------------------------------------------------------------------------------------------------------------- + class AkkaCassandraProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) { + val cassandra = Dependencies.cassandra + val log4j = Dependencies.log4j + val slf4j = Dependencies.slf4j + val slf4j_log4j = Dependencies.slf4j_log4j + + // testing + val cassandra_clhm = Dependencies.cassandra_clhm + val commons_coll = Dependencies.commons_coll + val google_coll = Dependencies.google_coll + val high_scale = Dependencies.high_scale + + override def testOptions = TestFilter((name: String) => name.endsWith("Test")) :: Nil + } + + // ------------------------------------------------------------------------------------------------------------------- + // akka-kernel subproject + // ------------------------------------------------------------------------------------------------------------------- + class AkkaKernelProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) + + // ------------------------------------------------------------------------------------------------------------------- + // akka-spring subproject + // ------------------------------------------------------------------------------------------------------------------- + class AkkaSpringProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with CodeFellowPlugin { + val spring_beans = Dependencies.spring_beans + val spring_context = Dependencies.spring_context + + // testing + val camel_spring = Dependencies.camel_spring + val junit = Dependencies.junit + val scalatest = Dependencies.scalatest + } + + // ------------------------------------------------------------------------------------------------------------------- + // akka-jta subproject + // ------------------------------------------------------------------------------------------------------------------- class AkkaJTAProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with CodeFellowPlugin { - val atomikos_transactions = "com.atomikos" % "transactions" % "3.2.3" % "compile" - val atomikos_transactions_jta = "com.atomikos" % "transactions-jta" % "3.2.3" % "compile" - val atomikos_transactions_api = "com.atomikos" % "transactions-api" % "3.2.3" % "compile" + val atomikos_transactions = Dependencies.atomikos_transactions + val atomikos_transactions_api = Dependencies.atomikos_transactions_api + val atomikos_transactions_jta = Dependencies.atomikos_transactions_jta + val jta_1_1 = Dependencies.jta_1_1 //val atomikos_transactions_util = "com.atomikos" % "transactions-util" % "3.2.3" % "compile" - val jta_spec = "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1" % "compile" intransitive() } // ================= OSGi Packaging ================== @@ -404,21 +565,24 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { // ================= EXAMPLES ================== class AkkaSampleAntsProject(info: ProjectInfo) extends DefaultSpdeProject(info) with CodeFellowPlugin { - val scalaToolsSnapshots = ScalaToolsSnapshots +// val scalaToolsSnapshots = ScalaToolsSnapshots override def spdeSourcePath = mainSourcePath / "spde" } class AkkaSampleChatProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin class AkkaSamplePubSubProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin - class AkkaSampleLiftProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin { - val commons_logging = "commons-logging" % "commons-logging" % "1.1.1" % "compile" - val lift = "net.liftweb" % "lift-webkit" % LIFT_VERSION % "compile" - val lift_util = "net.liftweb" % "lift-util" % LIFT_VERSION % "compile" - val servlet = "javax.servlet" % "servlet-api" % "2.5" % "compile" + class AkkaSampleLiftProject(info: ProjectInfo) extends DefaultWebProject(info) with DeployProject with CodeFellowPlugin { + val commons_logging = Dependencies.commons_logging + val lift = Dependencies.lift + val lift_util = Dependencies.lift_util + val servlet = Dependencies.servlet + // testing - val jetty = "org.mortbay.jetty" % "jetty" % "6.1.22" % "test" - val junit = "junit" % "junit" % "4.5" % "test" + val jettyServer = Dependencies.jettyServer + val junit = Dependencies.junit + + def deployPath = AkkaParentProject.this.deployPath } class AkkaSampleRestJavaProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin @@ -426,7 +590,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin class AkkaSampleRestScalaProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin { - val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1.1" % "compile" + val jsr311 = Dependencies.jsr311 } class AkkaSampleCamelProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin { @@ -447,9 +611,9 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { } class AkkaSampleSecurityProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) with CodeFellowPlugin { - val jsr311 = "javax.ws.rs" % "jsr311-api" % "1.1.1" % "compile" - val jsr250 = "javax.annotation" % "jsr250-api" % "1.0" % "compile" - val commons_codec = "commons-codec" % "commons-codec" % "1.4" % "compile" + val commons_codec = Dependencies.commons_codec + val jsr250 = Dependencies.jsr250 + val jsr311 = Dependencies.jsr311 } class AkkaSampleOSGiProject(info: ProjectInfo) extends AkkaDefaultProject(info, distPath) with BNDPlugin { @@ -516,7 +680,7 @@ class AkkaParent(info: ProjectInfo) extends DefaultProject(info) { // ------------------------------------------------------------ class AkkaDefaultProject(info: ProjectInfo, val deployPath: Path) extends DefaultProject(info) with DeployProject with OSGiProject - trait DeployProject extends DefaultProject { + trait DeployProject { self: Project => // defines where the deployTask copies jars to def deployPath: Path diff --git a/project/plugins/Plugins.scala b/project/plugins/Plugins.scala index 5e3da324da..f0332505da 100644 --- a/project/plugins/Plugins.scala +++ b/project/plugins/Plugins.scala @@ -1,17 +1,31 @@ import sbt._ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { - val embeddedRepo = "Embedded Repo" at (info.projectPath / "embedded-repo").asURL.toString - val codeFellow = "de.tuxed" % "codefellow-plugin" % "0.3" // for code completion and more in VIM -// val repo = "GH-pages repo" at "http://mpeltonen.github.com/maven/" -// val idea = "com.github.mpeltonen" % "sbt-idea-plugin" % "0.1-SNAPSHOT" - // Repositories: Using module configs to speed up resolution => Repos must be defs! - def aquteRepo = "aQute Maven Repository" at "http://www.aqute.biz/repo" - lazy val aquteModuleConfig = ModuleConfiguration("biz.aQute", aquteRepo) - def databinderRepo = "Databinder Repository" at "http://databinder.net/repo" - lazy val spdeModuleConfig = ModuleConfiguration("us.technically.spde", databinderRepo) + // ------------------------------------------------------------------------------------------------------------------- + // All repositories *must* go here! See ModuleConigurations below. + // ------------------------------------------------------------------------------------------------------------------- + object Repositories { + lazy val AquteRepo = "aQute Maven Repository" at "http://www.aqute.biz/repo" + lazy val DatabinderRepo = "Databinder Repository" at "http://databinder.net/repo" + lazy val EmbeddedRepo = "Embedded Repo" at (info.projectPath / "embedded-repo").asURL.toString + } + + // ------------------------------------------------------------------------------------------------------------------- + // ModuleConfigurations + // Every dependency that cannot be resolved from the built-in repositories (Maven Central and Scala Tools Releases) + // must be resolved from a ModuleConfiguration. This will result in a significant acceleration of the update action. + // Therefore, if repositories are defined, this must happen as def, not as val. + // ------------------------------------------------------------------------------------------------------------------- + import Repositories._ + lazy val aquteModuleConfig = ModuleConfiguration("biz.aQute", AquteRepo) + lazy val codeFellowModuleConfig = ModuleConfiguration("de.tuxed", EmbeddedRepo) + lazy val spdeModuleConfig = ModuleConfiguration("us.technically.spde", DatabinderRepo) - val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "1.0.0.RC3" - val spdeSbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.1" + // ------------------------------------------------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------------------------------------------------- + lazy val bnd4sbt = "com.weiglewilczek.bnd4sbt" % "bnd4sbt" % "1.0.0.RC4" + lazy val codeFellow = "de.tuxed" % "codefellow-plugin" % "0.3" // for code completion and more in VIM + lazy val spdeSbt = "us.technically.spde" % "spde-sbt-plugin" % "0.4.1" }