diff --git a/akka-samples/akka-sample-hello/config/akka.conf b/akka-samples/akka-sample-hello/config/akka.conf new file mode 100644 index 0000000000..1278bd0e70 --- /dev/null +++ b/akka-samples/akka-sample-hello/config/akka.conf @@ -0,0 +1,27 @@ +#################### +# Akka Config File # +#################### + +akka { + version = "2.0-SNAPSHOT" + + enabled-modules = ["http"] + + time-unit = "seconds" + + event-handlers = ["akka.event.EventHandler$DefaultListener"] + + boot = ["sample.hello.Boot"] + + http { + hostname = "localhost" + port = 9998 + + connection-close = true + root-actor-id = "_httproot" + root-actor-builtin = true + timeout = 1000 + expired-header-name = "Async-Timeout" + expired-header-value = "expired" + } +} diff --git a/akka-samples/akka-sample-hello/config/microkernel-server.xml b/akka-samples/akka-sample-hello/config/microkernel-server.xml new file mode 100644 index 0000000000..7180bca3f4 --- /dev/null +++ b/akka-samples/akka-sample-hello/config/microkernel-server.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + 300000 + 2 + false + 8443 + 20000 + 5000 + + + + + + + + + + + + + + / + + akka.http.AkkaMistServlet + /* + + + + + + + + + + + + + + + true + true + true + 1000 + + diff --git a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala new file mode 100644 index 0000000000..91f413e1fc --- /dev/null +++ b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/Boot.scala @@ -0,0 +1,20 @@ +/** + * Copyright (C) 2009-2011 Scalable Solutions AB + */ + +package sample.hello + +import akka.actor._ +import akka.http._ +import akka.config.Supervision._ + +class Boot { + val factory = + SupervisorFactory( + SupervisorConfig( + OneForOneStrategy(List(classOf[Exception]), 3, 100), + Supervise(Actor.actorOf[RootEndpoint], Permanent) :: + Supervise(Actor.actorOf[HelloEndpoint], Permanent) :: Nil)) + + factory.newInstance.start +} diff --git a/akka-samples/akka-sample-hello/src/main/scala/sample/hello/HelloEndpoint.scala b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/HelloEndpoint.scala new file mode 100644 index 0000000000..fec6f55470 --- /dev/null +++ b/akka-samples/akka-sample-hello/src/main/scala/sample/hello/HelloEndpoint.scala @@ -0,0 +1,29 @@ +/** + * Copyright (C) 2009-2011 Scalable Solutions AB + */ + +package sample.hello + +import akka.actor._ +import akka.http._ + +import java.text.DateFormat +import java.util.Date + +class HelloEndpoint extends Actor with Endpoint { + self.dispatcher = Endpoint.Dispatcher + + lazy val hello = Actor.actorOf( + new Actor { + def time = DateFormat.getTimeInstance.format(new Date) + def receive = { + case get: Get => get OK "Hello at " + time + } + }).start + + def hook: Endpoint.Hook = { case _ => hello } + + override def preStart = Actor.registry.actorFor(MistSettings.RootActorID).get ! Endpoint.Attach(hook) + + def receive = handleHttpRequest +} diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index ec0a765aa1..7f3b8de710 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -598,31 +598,35 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec } } - class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info) - class AkkaSampleChatProject(info: ProjectInfo) extends AkkaDefaultProject(info) class AkkaSampleFSMProject(info: ProjectInfo) extends AkkaDefaultProject(info) + class AkkaSampleHelloProject(info: ProjectInfo) extends AkkaDefaultProject(info) + class AkkaSampleOsgiProject(info: ProjectInfo) extends AkkaDefaultProject(info) with BNDPlugin { val osgiCore = Dependencies.osgi_core override protected def bndPrivatePackage = List("sample.osgi.*") override protected def bndBundleActivator = Some("sample.osgi.Activator") } + class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info) + class AkkaSamplesParentProject(info: ProjectInfo) extends ParentProject(info) { override def disableCrossPaths = true lazy val akka_sample_ants = project("akka-sample-ants", "akka-sample-ants", new AkkaSampleAntsProject(_), akka_stm) - lazy val akka_sample_fsm = project("akka-sample-fsm", "akka-sample-fsm", - new AkkaSampleFSMProject(_), akka_actor) -// lazy val akka_sample_remote = project("akka-sample-remote", "akka-sample-remote", -// new AkkaSampleRemoteProject(_), akka_remote) // lazy val akka_sample_chat = project("akka-sample-chat", "akka-sample-chat", // new AkkaSampleChatProject(_), akka_remote) + lazy val akka_sample_fsm = project("akka-sample-fsm", "akka-sample-fsm", + new AkkaSampleFSMProject(_), akka_actor) + lazy val akka_sample_hello = project("akka-sample-hello", "akka-sample-hello", + new AkkaSampleHelloProject(_), akka_kernel) lazy val akka_sample_osgi = project("akka-sample-osgi", "akka-sample-osgi", new AkkaSampleOsgiProject(_), akka_actor) +// lazy val akka_sample_remote = project("akka-sample-remote", "akka-sample-remote", +// new AkkaSampleRemoteProject(_), akka_remote) lazy val publishRelease = { val releaseConfiguration = new DefaultPublishConfiguration(localReleaseRepository, "release", false) @@ -784,6 +788,9 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec lazy val akkaCoreDist = project("core", "akka-dist-core", new AkkaCoreDistProject(_), akkaActorsDist, akka_remote, akka_http, akka_slf4j, akka_testkit, akka_actor_tests) + lazy val akkaMicrokernelDist = project("microkernel", "akka-dist-microkernel", new AkkaMicrokernelDistProject(_), + akkaCoreDist, akka_kernel, akka_samples) + def doNothing = task { None } override def publishLocalAction = doNothing override def deliverLocalAction = doNothing @@ -792,6 +799,7 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec class AkkaActorsDistProject(info: ProjectInfo) extends DefaultProject(info) with DistDocProject { def distName = "akka-actors" + override def distDocName = "akka" override def distConfigSources = (akkaParent.info.projectPath / "config" ##) * "*" @@ -817,6 +825,51 @@ class AkkaParentProject(info: ProjectInfo) extends ParentProject(info) with Exec class AkkaCoreDistProject(info: ProjectInfo)extends DefaultProject(info) with DistProject { def distName = "akka-core" } + + class AkkaMicrokernelDistProject(info: ProjectInfo) extends DefaultProject(info) with DistProject { + def distName = "akka-microkernel" + + override def distScriptSources = akkaParent.info.projectPath / "scripts" / "microkernel" * "*" + + override def distClasspath = akka_kernel.runClasspath + + override def projectDependencies = akka_kernel.topologicalSort + + override def distAction = super.distAction dependsOn (distSamples) + + val distSamplesPath = distDocPath / "samples" + + lazy val distSamples = task { + val demo = akka_samples.akka_sample_hello.jarPath + val samples = Set(//akka_samples.akka_sample_camel + akka_samples.akka_sample_hello) + //akka_samples.akka_sample_security) + + def copySamples[P <: DefaultProject](samples: Set[P]) = { + samples.map { sample => + val sampleOutputPath = distSamplesPath / sample.name + val binPath = sampleOutputPath / "bin" + val configPath = sampleOutputPath / "config" + val deployPath = sampleOutputPath / "deploy" + val libPath = sampleOutputPath / "lib" + val srcPath = sampleOutputPath / "src" + val confs = sample.info.projectPath / "config" ** "*.*" + val scripts = akkaParent.info.projectPath / "scripts" / "samples" * "*" + val libs = sample.managedClasspath(Configurations.Runtime) + val deployed = sample.jarPath + val sources = sample.packageSourcePaths + copyFiles(confs, configPath) orElse + copyScripts(scripts, binPath) orElse + copyFiles(libs, libPath) orElse + copyFiles(deployed, deployPath) orElse + copyPaths(sources, srcPath) + }.foldLeft(None: Option[String])(_ orElse _) + } + + copyFiles(demo, distDeployPath) orElse + copySamples(samples) + } dependsOn (distBase) + } } } diff --git a/project/build/DistProject.scala b/project/build/DistProject.scala index de1cb0cdf9..f930adbf37 100644 --- a/project/build/DistProject.scala +++ b/project/build/DistProject.scala @@ -4,27 +4,7 @@ import sbt._ -trait DistBaseProject extends DefaultProject { - def distOutputPath: Path - def distLibPath: Path - def distSrcPath: Path - def distDocPath: Path - def dist: Task - - override def disableCrossPaths = true - - def doNothing = task { None } - override def compileAction = doNothing - override def testCompileAction = doNothing - override def testAction = doNothing - override def packageAction = doNothing - override def publishLocalAction = doNothing - override def deliverLocalAction = doNothing - override def publishAction = doNothing - override def deliverAction = doNothing -} - -trait DistProject extends DistBaseProject { +trait DistProject extends DefaultProject { def distName: String val distFullName = distName + "-" + version @@ -38,7 +18,6 @@ trait DistProject extends DistBaseProject { val distSrcPath = distOutputPath / "src" / "akka" val distDocPath = distOutputPath / "doc" / "akka" val distDocJarsPath = distDocPath / "api" / "jars" - val distSharePath = Path.userHome / ".ivy2" / "dist" / distFullName val distArchiveName = distFullName + ".zip" val distArchive = (distOutputBasePath ##) / distArchiveName @@ -58,7 +37,7 @@ trait DistProject extends DistBaseProject { def distDependencies = { allProjectDependencies.flatMap( p => p match { - case adp: DistBaseProject => Some(adp) + case dp: DistProject => Some(dp) case _ => None }) } @@ -92,8 +71,6 @@ trait DistProject extends DistBaseProject { def distDocJars = dependencyJars(isDocJar) +++ projectDependencyJars(_.packageDocsJar) - def distShareSources = ((distOutputPath ##) ***) - lazy val dist = (distAction dependsOn (distBase, `package`, packageSrc, packageDocs) describedAs("Create a distribution.")) @@ -116,7 +93,6 @@ trait DistProject extends DistBaseProject { copyFiles(distDocJars, distDocJarsPath) orElse copyPaths(distConfigSources, distConfigPath) orElse copyScripts(distScriptSources, distBinPath) orElse - copyPaths(distShareSources, distSharePath) orElse FileUtilities.zip(List(distOutputPath), distArchive, true, log) orElse exclusiveDist } @@ -136,8 +112,7 @@ trait DistProject extends DistBaseProject { describedAs "Clean the dist target dir.") def distCleanAction = task { - FileUtilities.clean(distOutputPath, log) orElse - FileUtilities.clean(distSharePath, log) + FileUtilities.clean(distOutputPath, log) } def copyFiles(from: PathFinder, to: Path): Option[String] = { @@ -162,6 +137,18 @@ trait DistProject extends DistBaseProject { val success = target.asFile.setExecutable(executable, false) if (success) None else Some("Couldn't set permissions of " + target) } + + override def disableCrossPaths = true + + def doNothing = task { None } + override def compileAction = doNothing + override def testCompileAction = doNothing + override def testAction = doNothing + override def packageAction = doNothing + override def publishLocalAction = doNothing + override def deliverLocalAction = doNothing + override def publishAction = doNothing + override def deliverAction = doNothing } trait DistDocProject extends DistProject { @@ -197,19 +184,3 @@ trait DistDocProject extends DistProject { copyPaths(docsPdfSources, docsPdfPath) } dependsOn (distBase, docParent.docs) } - -/* - * For wiring together akka and akka-modules. - */ -trait DistSharedProject extends DistBaseProject { - def distName: String - - val distFullName = distName + "-" + version - val distOutputPath = Path.userHome / ".ivy2" / "dist" / distFullName - - val distLibPath = distOutputPath / "lib" / "akka" - val distSrcPath = distOutputPath / "src" / "akka" - val distDocPath = distOutputPath / "doc" / "akka" - - lazy val dist = task { None } -} diff --git a/scripts/microkernel/akka b/scripts/microkernel/akka new file mode 100755 index 0000000000..4241d2693d --- /dev/null +++ b/scripts/microkernel/akka @@ -0,0 +1,9 @@ +#!/bin/bash + +AKKA_HOME="$(cd "$(cd "$(dirname "$0")"; pwd -P)"/..; pwd)" + +[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC" + +[ -n "$AKKA_CLASSPATH" ] || AKKA_CLASSPATH="$AKKA_HOME/lib/scala-library.jar:$AKKA_HOME/lib/akka/*:$AKKA_HOME/config" + +java $JAVA_OPTS -cp "$AKKA_CLASSPATH" -Dakka.home="$AKKA_HOME" akka.kernel.Main diff --git a/scripts/microkernel/akka.bat b/scripts/microkernel/akka.bat new file mode 100644 index 0000000000..4d2f912096 --- /dev/null +++ b/scripts/microkernel/akka.bat @@ -0,0 +1,6 @@ +@echo off +set AKKA_HOME=%~dp0.. +set JAVA_OPTS=-Xms1024M -Xmx1024M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC +set AKKA_CLASSPATH=%AKKA_HOME%\lib\scala-library.jar;%AKKA_HOME%\lib\akka\*;%AKKA_HOME%\config + +java %JAVA_OPTS% -cp "%AKKA_CLASSPATH%" -Dakka.home="%AKKA_HOME%" akka.kernel.Main diff --git a/scripts/samples/start b/scripts/samples/start new file mode 100755 index 0000000000..491c617db2 --- /dev/null +++ b/scripts/samples/start @@ -0,0 +1,13 @@ +#!/bin/bash + +SAMPLE="$(cd "$(cd "$(dirname "$0")"; pwd -P)"/..; pwd)" + +AKKA_HOME="$(cd "$SAMPLE"/../../../..; pwd)" + +[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xms1536M -Xmx1536M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC" + +[ -n "$AKKA_CLASSPATH" ] || AKKA_CLASSPATH="$AKKA_HOME/lib/scala-library.jar:$AKKA_HOME/lib/akka/*" + +SAMPLE_CLASSPATH="$AKKA_CLASSPATH:$SAMPLE/lib/*:$SAMPLE/config" + +java $JAVA_OPTS -cp "$SAMPLE_CLASSPATH" -Dakka.home="$SAMPLE" akka.kernel.Main diff --git a/scripts/samples/start.bat b/scripts/samples/start.bat new file mode 100644 index 0000000000..1bffae4e5b --- /dev/null +++ b/scripts/samples/start.bat @@ -0,0 +1,8 @@ +@echo off +set SAMPLE=%~dp0.. +set AKKA_HOME=%SAMPLE%\..\..\..\.. +set JAVA_OPTS=-Xms1024M -Xmx1024M -Xss1M -XX:MaxPermSize=256M -XX:+UseParallelGC +set AKKA_CLASSPATH=%AKKA_HOME%\lib\scala-library.jar;%AKKA_HOME%\lib\akka\* +set SAMPLE_CLASSPATH=%AKKA_CLASSPATH%;%SAMPLE%\lib\*;%SAMPLE%\config + +java %JAVA_OPTS% -cp "%SAMPLE_CLASSPATH%" -Dakka.home="%SAMPLE%" akka.kernel.Main