Re-enable akka-kernel and add small sample

Created a new simple version of the microkernel for
inclusion in the akka download and to be able to start
working on sample applications
This commit is contained in:
Peter Vlugter 2011-12-14 16:19:16 +13:00
parent 66e7155ef1
commit ba9ed982ca
19 changed files with 247 additions and 531 deletions

View file

@ -7,10 +7,8 @@
akka {
version = "2.0-SNAPSHOT" # Akka version, checked against the runtime version of Akka.
home = "" # Home directory of Akka, modules in the deploy directory will be loaded
enabled-modules = [] # Comma separated list of the enabled modules. Options: ["cluster", "camel", "http"]
home = "" # Home directory of Akka, modules in the deploy directory will be loaded
event-handlers = ["akka.event.Logging$DefaultLogger"] # Event handlers to register at boot time (Logging$DefaultLogger logs to STDOUT)
loglevel = "INFO" # Options: ERROR, WARNING, INFO, DEBUG
@ -19,20 +17,11 @@ akka {
stdout-loglevel = "WARNING" # Loglevel for the very basic logger activated during AkkaApplication startup
# FIXME: Is there any sensible reason why we have 2 different log levels?
logConfigOnStart = off # Log the complete configuration at INFO level when the actor system is started.
logConfigOnStart = off # Log the complete configuration at INFO level when the actor system is started.
# This is useful when you are uncertain of what configuration is used.
extensions = [] # List FQCN of extensions which shall be loaded at actor system startup.
# FIXME: clarify "extensions" here, "Akka Extensions (<link to docs>)"
# These boot classes are loaded (and created) automatically when the Akka Microkernel boots up
# Can be used to bootstrap your application(s)
# Should be the FQN (Fully Qualified Name) of the boot class which needs to have a default constructor
# boot = ["sample.camel.Boot",
# "sample.rest.java.Boot",
# "sample.rest.scala.Boot",
# "sample.security.Boot"]
boot = []
extensions = [] # List FQCN of extensions which shall be loaded at actor system startup.
# FIXME: clarify "extensions" here, "Akka Extensions (<link to docs>)"
actor {
provider = "akka.actor.LocalActorRefProvider"
@ -45,7 +34,7 @@ akka {
dispatcher-shutdown-timeout = 1s # How long dispatchers by default will wait for new actors until they shut down
deployment {
default { # deployment id pattern, e.g. /app/service-ping
router = "direct" # routing (load-balance) scheme to use
@ -56,7 +45,7 @@ akka {
# in several ways:
# - nr-of-instances: will create that many children given the actor factory
# supplied in the source code (overridable using create-as below)
# - target.paths: will look the paths up using actorFor and route to
# - target.paths: will look the paths up using actorFor and route to
# them, i.e. will not create children
nr-of-instances = 1 # number of children to create in case of a non-direct router; this setting
@ -67,11 +56,11 @@ akka {
}
target {
paths = [] # Alternatively to giving nr-of-instances you can specify the full paths of
paths = [] # Alternatively to giving nr-of-instances you can specify the full paths of
# those actors which should be routed to. This setting takes precedence over
# nr-of-instances
}
}
}
@ -109,7 +98,7 @@ akka {
fsm = off # enable DEBUG logging of all LoggingFSMs for events, transitions and timers
event-stream = off # enable DEBUG logging of subscription changes on the eventStream
}
# Entries for pluggable serializers and their bindings. If a binding for a specific class is not found,
# then the default serializer (Java serialization) is used.
#
@ -146,5 +135,5 @@ akka {
tickDuration = 100ms
ticksPerWheel = 512
}
}

View file

@ -96,9 +96,6 @@ object ActorSystem {
case "" None
case x Some(x)
}
val BootClasses: Seq[String] = getStringList("akka.boot").asScala
val EnabledModules: Seq[String] = getStringList("akka.enabled-modules").asScala
val SchedulerTickDuration = Duration(getMilliseconds("akka.scheduler.tickDuration"), MILLISECONDS)
val SchedulerTicksPerWheel = getInt("akka.scheduler.ticksPerWheel")

View file

@ -1,66 +0,0 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor
import java.io.File
import java.net.{ URL, URLClassLoader }
import java.util.jar.JarFile
import akka.util.Bootable
/**
* Handles all modules in the deploy directory (load and unload)
*/
trait BootableActorLoaderService extends Bootable {
def system: ActorSystem
val BOOT_CLASSES = system.settings.BootClasses
lazy val applicationLoader = createApplicationClassLoader()
protected def createApplicationClassLoader(): Option[ClassLoader] = Some({
if (system.settings.Home.isDefined) {
val DEPLOY = system.settings.Home.get + "/deploy"
val DEPLOY_DIR = new File(DEPLOY)
if (!DEPLOY_DIR.exists) {
System.exit(-1)
}
val filesToDeploy = DEPLOY_DIR.listFiles.toArray.toList
.asInstanceOf[List[File]].filter(_.getName.endsWith(".jar"))
var dependencyJars: List[URL] = Nil
filesToDeploy.map { file
val jarFile = new JarFile(file)
val en = jarFile.entries
while (en.hasMoreElements) {
val name = en.nextElement.getName
if (name.endsWith(".jar")) dependencyJars ::= new File(
String.format("jar:file:%s!/%s", jarFile.getName, name)).toURI.toURL
}
}
val toDeploy = filesToDeploy.map(_.toURI.toURL)
val allJars = toDeploy ::: dependencyJars
new URLClassLoader(allJars.toArray, Thread.currentThread.getContextClassLoader)
} else Thread.currentThread.getContextClassLoader
})
abstract override def onLoad() = {
super.onLoad()
applicationLoader foreach Thread.currentThread.setContextClassLoader
for (loader applicationLoader; clazz BOOT_CLASSES) {
loader.loadClass(clazz).newInstance
}
}
abstract override def onUnload() = {
super.onUnload()
}
}
/**
* Java API for the default JAX-RS/Mist Initializer
*/
class DefaultBootableActorLoaderService(val system: ActorSystem) extends BootableActorLoaderService

View file

@ -1,91 +0,0 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.util
import akka.actor.ActorSystem
/*
* This class is responsible for booting up a stack of bundles and then shutting them down
*/
class AkkaLoader(system: ActorSystem) {
private val hasBooted = new Switch(false)
@volatile
private var _bundles: Option[Bootable] = None
def bundles = _bundles;
/*
* Boot initializes the specified bundles
*/
def boot(withBanner: Boolean, b: Bootable): Unit = hasBooted switchOn {
if (withBanner) printBanner()
println("Starting Akka...")
b.onLoad()
Thread.currentThread.setContextClassLoader(getClass.getClassLoader)
_bundles = Some(b)
println("Akka started successfully")
}
/*
* Shutdown, well, shuts down the bundles used in boot
*/
def shutdown() {
hasBooted switchOff {
println("Shutting down Akka...")
_bundles.foreach(_.onUnload())
_bundles = None
println("Akka succesfully shut down")
}
}
private def printBanner() {
println("""
==============================================================================
ZZ:
ZZZZ
ZZZZZZ
ZZZ' ZZZ
~7 7ZZ' ZZZ
:ZZZ: IZZ' ZZZ
,OZZZZ.~ZZ? ZZZ
ZZZZ' 'ZZZ$ ZZZ
. $ZZZ ~ZZ$ ZZZ
.=Z?. .ZZZO ~ZZ7 OZZ
.ZZZZ7..:ZZZ~ 7ZZZ ZZZ~
.$ZZZ$Z+.ZZZZ ZZZ: ZZZ$
.,ZZZZ?' =ZZO= .OZZ 'ZZZ
.$ZZZZ+ .ZZZZ IZZZ ZZZ$
.ZZZZZ' .ZZZZ' .ZZZ$ ?ZZZ
.ZZZZZZ' .OZZZ? ?ZZZ 'ZZZ$
.?ZZZZZZ' .ZZZZ? .ZZZ? 'ZZZO
.+ZZZZZZ?' .7ZZZZ' .ZZZZ :ZZZZ
.ZZZZZZ$' .?ZZZZZ' .~ZZZZ 'ZZZZ.
NNNNN $NNNN+
NNNNN $NNNN+
NNNNN $NNNN+
NNNNN $NNNN+
NNNNN $NNNN+
=NNNNNNNNND$ NNNNN DDDDDD: $NNNN+ DDDDDN NDDNNNNNNNN,
NNNNNNNNNNNNND NNNNN DNNNNN $NNNN+ 8NNNNN= :NNNNNNNNNNNNNN
NNNNN$ DNNNNN NNNNN $NNNNN~ $NNNN+ NNNNNN NNNNN, :NNNNN+
?DN~ NNNNN NNNNN MNNNNN $NNNN+:NNNNN7 $ND =NNNNN
DNNNNN NNNNNDNNNN$ $NNNNDNNNNN :DNNNNN
ZNDNNNNNNNNND NNNNNNNNNND, $NNNNNNNNNNN DNDNNNNNNNNNN
NNNNNNNDDINNNNN NNNNNNNNNNND $NNNNNNNNNNND ONNNNNNND8+NNNNN
:NNNND NNNNN NNNNNN DNNNN, $NNNNNO 7NNNND NNNNNO :NNNNN
DNNNN NNNNN NNNNN DNNNN $NNNN+ 8NNNNN NNNNN $NNNNN
DNNNNO NNNNNN NNNNN NNNNN $NNNN+ NNNNN$ NNNND, ,NNNNND
NNNNNNDDNNNNNNNN NNNNN =NNNNN $NNNN+ DNNNN? DNNNNNNDNNNNNNNND
NNNNNNNNN NNNN$ NNNNN 8NNNND $NNNN+ NNNNN= ,DNNNNNNND NNNNN$
==============================================================================
Running version %s
==============================================================================
""".format(ActorSystem.Version))
}
}

View file

@ -1,11 +0,0 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.util
import akka.actor.ActorSystem
trait Bootable {
def onLoad() {}
def onUnload() {}
}

View file

@ -0,0 +1,19 @@
#####################################
# Akka Kernel Reference Config File #
#####################################
# This reference config file has all the default settings
# Make your edits/overrides in your akka.conf
akka {
kernel {
# The name of the actor system created by the Akka Microkernel
system.name = "default"
# Boot classes are loaded and created automatically when the Akka Microkernel starts up
# A list of FQNs (Fully Qualified Names) of classes that implement akka.kernel.Bootable
boot = []
}
}

View file

@ -1,23 +0,0 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.http
import akka.config.Config
import akka.util.{ Bootable, AkkaLoader }
import akka.cluster.BootableRemoteActorService
import akka.actor.BootableActorLoaderService
class DefaultAkkaLoader extends AkkaLoader {
def boot(): Unit = boot(true, new EmbeddedAppServer with BootableActorLoaderService with BootableRemoteActorService)
}
/**
* Can be used to boot Akka
*
* java -cp ... akka.http.Main
*/
object Main extends DefaultAkkaLoader {
def main(args: Array[String]) = boot
}

View file

@ -1,73 +0,0 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.http
import javax.ws.rs.core.UriBuilder
import javax.servlet.ServletConfig
import java.io.File
import akka.actor.BootableActorLoaderService
import akka.util.Bootable
import org.eclipse.jetty.xml.XmlConfiguration
import org.eclipse.jetty.server.{ Handler, Server }
import org.eclipse.jetty.server.handler.{ HandlerList, HandlerCollection, ContextHandler }
import java.net.URL
import akka.AkkaException
/**
* Handles the Akka Comet Support (load/unload)
*/
trait EmbeddedAppServer extends Bootable {
self: BootableActorLoaderService
import akka.config.Config._
val REST_HOSTNAME = config.getString("akka.http.hostname", "localhost")
val REST_PORT = config.getInt("akka.http.port", 9998)
val isRestEnabled = config.getList("akka.enabled-modules").exists(_ == "http")
protected var server: Option[Server] = None
protected def findJettyConfigXML: Option[URL] =
Option(applicationLoader.getOrElse(this.getClass.getClassLoader).getResource("microkernel-server.xml")) orElse
HOME.map(home new File(home + "/config/microkernel-server.xml").toURI.toURL)
abstract override def onLoad = {
super.onLoad
if (isRestEnabled) {
val configuration = new XmlConfiguration(findJettyConfigXML.getOrElse(sys.error("microkernel-server.xml not found!")))
System.setProperty("jetty.port", REST_PORT.toString)
System.setProperty("jetty.host", REST_HOSTNAME)
HOME.foreach(home System.setProperty("jetty.home", home + "/deploy/root"))
server = Option(configuration.configure.asInstanceOf[Server]) map { s //Set the correct classloader to our contexts
applicationLoader foreach { loader
//We need to provide the correct classloader to the servlets
def setClassLoader(handlers: Seq[Handler]) {
handlers foreach {
case c: ContextHandler c.setClassLoader(loader)
case c: HandlerCollection setClassLoader(c.getHandlers)
case _
}
}
setClassLoader(s.getHandlers)
}
//Start the server
s.start()
s
}
}
}
abstract override def onUnload = {
super.onUnload
server foreach { _.stop() }
}
}

View file

@ -1,36 +0,0 @@
/**
* Copyright (C) 2009-2010 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.kernel
import akka.http.EmbeddedAppServer
import akka.util.AkkaLoader
import akka.cluster.BootableRemoteActorService
import akka.actor.BootableActorLoaderService
import akka.camel.CamelService
import java.util.concurrent.CountDownLatch
object Main {
val keepAlive = new CountDownLatch(2)
def main(args: Array[String]) = {
Kernel.boot
keepAlive.await
}
}
/**
* The Akka Kernel, is used to start And postStop Akka in standalone/kernel mode.
*/
object Kernel extends AkkaLoader {
def boot(): Unit = boot(true, new EmbeddedAppServer with BootableActorLoaderService with BootableRemoteActorService with CamelService)
// For testing purposes only
def startRemoteService(): Unit = bundles.foreach(_ match {
case x: BootableRemoteActorService x.startRemoteService()
case _
})
}

View file

@ -0,0 +1,143 @@
/**
* Copyright (C) 2009-2010 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.kernel
import akka.actor.ActorSystem
import com.typesafe.config.ConfigFactory
import java.io.File
import java.lang.Boolean.getBoolean
import java.net.{ URL, URLClassLoader }
import java.util.jar.JarFile
import scala.collection.JavaConverters._
trait Bootable {
def startup(system: ActorSystem): Unit
def shutdown(system: ActorSystem): Unit
}
object Main {
val quiet = getBoolean("akka.kernel.quiet")
def log(s: String) = if (!quiet) println(s)
def main(args: Array[String]) = {
log(banner)
log("Starting Akka...")
log("Running Akka " + ActorSystem.Version)
val config = ConfigFactory.load("akka.conf")
val name = config.getString("akka.kernel.system.name")
val system = ActorSystem(name, config)
val classLoader = deployJars(system)
log("Created actor system '%s'" format name)
Thread.currentThread.setContextClassLoader(classLoader)
val bootClasses: Seq[String] = system.settings.config.getStringList("akka.kernel.boot").asScala
val bootables: Seq[Bootable] = bootClasses map { c classLoader.loadClass(c).newInstance.asInstanceOf[Bootable] }
for (bootable bootables) {
log("Starting up " + bootable.getClass.getName)
bootable.startup(system)
}
addShutdownHook(system, bootables)
log("Successfully started Akka")
}
def deployJars(system: ActorSystem): ClassLoader = {
if (system.settings.Home.isEmpty) {
log("Akka home is not defined")
System.exit(1)
Thread.currentThread.getContextClassLoader
} else {
val home = system.settings.Home.get
val deploy = new File(home, "deploy")
if (!deploy.exists) {
log("No deploy dir found at " + deploy)
log("Please check that akka home is defined correctly")
System.exit(1)
}
val jars = deploy.listFiles.filter(_.getName.endsWith(".jar"))
val nestedJars = jars flatMap { jar
val jarFile = new JarFile(jar)
val jarEntries = jarFile.entries.asScala.toArray.filter(_.getName.endsWith(".jar"))
jarEntries map { entry new File("jar:file:%s!/%s" format (jarFile.getName, entry.getName)) }
}
val urls = (jars ++ nestedJars) map { _.toURI.toURL }
urls foreach { url log("Deploying " + url) }
new URLClassLoader(urls, Thread.currentThread.getContextClassLoader)
}
}
def addShutdownHook(system: ActorSystem, bootables: Seq[Bootable]): Unit = {
Runtime.getRuntime.addShutdownHook(new Thread(new Runnable {
def run = {
log("")
log("Received signal to stop")
log("Shutting down Akka...")
for (bootable bootables) {
log("Shutting down " + bootable.getClass.getName)
bootable.shutdown(system)
}
system.stop()
log("Successfully shut down Akka")
}
}))
}
def banner = """
==============================================================================
ZZ:
ZZZZ
ZZZZZZ
ZZZ' ZZZ
~7 7ZZ' ZZZ
:ZZZ: IZZ' ZZZ
,OZZZZ.~ZZ? ZZZ
ZZZZ' 'ZZZ$ ZZZ
. $ZZZ ~ZZ$ ZZZ
.=Z?. .ZZZO ~ZZ7 OZZ
.ZZZZ7..:ZZZ~ 7ZZZ ZZZ~
.$ZZZ$Z+.ZZZZ ZZZ: ZZZ$
.,ZZZZ?' =ZZO= .OZZ 'ZZZ
.$ZZZZ+ .ZZZZ IZZZ ZZZ$
.ZZZZZ' .ZZZZ' .ZZZ$ ?ZZZ
.ZZZZZZ' .OZZZ? ?ZZZ 'ZZZ$
.?ZZZZZZ' .ZZZZ? .ZZZ? 'ZZZO
.+ZZZZZZ?' .7ZZZZ' .ZZZZ :ZZZZ
.ZZZZZZ$' .?ZZZZZ' .~ZZZZ 'ZZZZ.
NNNNN $NNNN+
NNNNN $NNNN+
NNNNN $NNNN+
NNNNN $NNNN+
NNNNN $NNNN+
=NNNNNNNNND$ NNNNN DDDDDD: $NNNN+ DDDDDN NDDNNNNNNNN,
NNNNNNNNNNNNND NNNNN DNNNNN $NNNN+ 8NNNNN= :NNNNNNNNNNNNNN
NNNNN$ DNNNNN NNNNN $NNNNN~ $NNNN+ NNNNNN NNNNN, :NNNNN+
?DN~ NNNNN NNNNN MNNNNN $NNNN+:NNNNN7 $ND =NNNNN
DNNNNN NNNNNDNNNN$ $NNNNDNNNNN :DNNNNN
ZNDNNNNNNNNND NNNNNNNNNND, $NNNNNNNNNNN DNDNNNNNNNNNN
NNNNNNNDDINNNNN NNNNNNNNNNND $NNNNNNNNNNND ONNNNNNND8+NNNNN
:NNNND NNNNN NNNNNN DNNNN, $NNNNNO 7NNNND NNNNNO :NNNNN
DNNNN NNNNN NNNNN DNNNN $NNNN+ 8NNNNN NNNNN $NNNNN
DNNNNO NNNNNN NNNNN NNNNN $NNNN+ NNNNN$ NNNND, ,NNNNND
NNNNNNDDNNNNNNNN NNNNN =NNNNN $NNNN+ DNNNN? DNNNNNNDNNNNNNNND
NNNNNNNNN NNNN$ NNNNN 8NNNND $NNNN+ NNNNN= ,DNNNNNNND NNNNN$
==============================================================================
"""
}

View file

@ -1,33 +0,0 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.servlet
import akka.cluster.BootableRemoteActorService
import akka.actor.BootableActorLoaderService
import akka.config.Config
import akka.util.{ Bootable, AkkaLoader }
import javax.servlet.{ ServletContextListener, ServletContextEvent }
/**
* This class can be added to web.xml mappings as a listener to start and postStop Akka.
*
* <web-system>
* ...
* <listener>
* <listener-class>akka.servlet.Initializer</listener-class>
* </listener>
* ...
* </web-system>
*/
class Initializer extends ServletContextListener {
lazy val loader = new AkkaLoader
def contextDestroyed(e: ServletContextEvent): Unit =
loader.shutdown
def contextInitialized(e: ServletContextEvent): Unit =
loader.boot(true, new BootableActorLoaderService with BootableRemoteActorService)
}

View file

@ -1,47 +0,0 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.remote
import akka.actor.{ Actor, BootableActorLoaderService }
import akka.util.{ ReflectiveAccess, Bootable }
// TODO: remove me - remoting is enabled through the RemoteActorRefProvider
/**
* This bundle/service is responsible for booting up and shutting down the remote actors facility.
* <p/>
* It is used in Kernel.
*/
/*
trait BootableRemoteActorService extends Bootable {
self: BootableActorLoaderService
def settings: RemoteServerSettings
protected lazy val remoteServerThread = new Thread(new Runnable() {
def run = system.remote.start(self.applicationLoader.getOrElse(null)) //Use config host/port
}, "Akka RemoteModule Service")
def startRemoteService() { remoteServerThread.start() }
abstract override def onLoad() {
if (system.reflective.ClusterModule.isEnabled && settings.isRemotingEnabled) {
system.eventHandler.info(this, "Initializing Remote Actors Service...")
startRemoteService()
system.eventHandler.info(this, "Remote Actors Service initialized")
}
super.onLoad()
}
abstract override def onUnload() {
system.eventHandler.info(this, "Shutting down Remote Actors Service")
system.remote.shutdown()
if (remoteServerThread.isAlive) remoteServerThread.join(1000)
system.eventHandler.info(this, "Remote Actors Service has been shut down")
super.onUnload()
}
}
*/

View file

@ -0,0 +1,8 @@
# Config for the Hello Kernel sample
akka {
kernel {
system.name = "hellokernel"
boot = ["sample.kernel.hello.HelloKernel"]
}
}

View file

@ -0,0 +1,33 @@
/**
* Copyright (C) 2009-2011 Typesafe Inc. <http://www.typesafe.com>
*/
package sample.kernel.hello
import akka.actor.{ Actor, ActorSystem, Props }
import akka.kernel.Bootable
case object Start
class HelloActor extends Actor {
val worldActor = context.actorOf(Props[WorldActor])
def receive = {
case Start worldActor ! "Hello"
case message: String
println("Received message '%s'" format message)
}
}
class WorldActor extends Actor {
def receive = {
case message: String sender ! (message.toUpperCase + " world!")
}
}
class HelloKernel extends Bootable {
def startup(system: ActorSystem) = {
system.actorOf(Props[HelloActor]) ! Start
}
def shutdown(system: ActorSystem) = {}
}

View file

@ -1,2 +1,2 @@
# In this file you can override any option defined in the 'akka-reference.conf' file.
# Copy in all or parts of the 'akka-reference.conf' file and modify as you please.
# In this file you can override any option defined in the 'reference.conf' files.
# Copy in all or parts of the 'reference.conf' files and modify as you please.

View file

@ -1,106 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!-- =============================================================== -->
<!-- Configure the Jetty Server -->
<!-- -->
<!-- Documentation of this file format can be found at: -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
<!-- -->
<!-- Additional configuration files are available in $JETTY_HOME/etc -->
<!-- and can be mixed in. For example: -->
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
<!-- -->
<!-- See start.ini file for the default configuration files -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<New class="org.eclipse.jetty.util.thread.ExecutorThreadPool">
</New>
</Set>
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host" /></Set>
<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<!-- Uncomment this and enter your SSL config/credentials to enable https
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Set name="Port">8443</Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="AcceptQueueSize">100</Set>
<Set name="Keystore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
<Set name="Password">PASSWORD</Set>
<Set name="KeyPassword">KEYPASSWORD</Set>
<Set name="truststore"><SystemProperty name="jetty.home" default="." />/etc/keystore</Set>
<Set name="trustPassword">TRUSTPASSWORD</Set>
</New>
</Arg>
</Call>
-->
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<!--Item>
<New id="AkkaRestHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/</Set>
<Call name="addServlet">
<Arg>akka.http.AkkaRestServlet</Arg>
<Arg>/*</Arg>
</Call>
</New>
</Item-->
<Item>
<New id="AkkaMistHandler" class="org.eclipse.jetty.servlet.ServletContextHandler">
<Set name="contextPath">/</Set>
<Call name="addServlet">
<Arg>akka.http.AkkaMistServlet</Arg>
<Arg>/*</Arg>
</Call>
</New>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
</Configure>

View file

@ -30,7 +30,7 @@ object AkkaBuild extends Build {
Unidoc.unidocExclude := Seq(samples.id, tutorials.id),
Dist.distExclude := Seq(actorTests.id, akkaSbtPlugin.id, docs.id)
),
aggregate = Seq(actor, testkit, actorTests, stm, remote, slf4j, amqp, mailboxes, akkaSbtPlugin, samples, tutorials, docs)
aggregate = Seq(actor, testkit, actorTests, stm, remote, slf4j, amqp, mailboxes, kernel, akkaSbtPlugin, samples, tutorials, docs)
)
lazy val actor = Project(
@ -192,14 +192,14 @@ object AkkaBuild extends Build {
// )
// )
// lazy val kernel = Project(
// id = "akka-kernel",
// base = file("akka-kernel"),
// dependencies = Seq(cluster, slf4j, spring),
// settings = defaultSettings ++ Seq(
// libraryDependencies ++= Dependencies.kernel
// )
// )
lazy val kernel = Project(
id = "akka-kernel",
base = file("akka-kernel"),
dependencies = Seq(actor),
settings = defaultSettings ++ Seq(
libraryDependencies ++= Dependencies.kernel
)
)
lazy val akkaSbtPlugin = Project(
id = "akka-sbt-plugin",
@ -213,7 +213,7 @@ object AkkaBuild extends Build {
id = "akka-samples",
base = file("akka-samples"),
settings = parentSettings,
aggregate = Seq(fsmSample, helloSample)
aggregate = Seq(fsmSample, helloSample, helloKernelSample)
)
lazy val fsmSample = Project(
@ -230,6 +230,13 @@ object AkkaBuild extends Build {
settings = defaultSettings
)
lazy val helloKernelSample = Project(
id = "akka-sample-hello-kernel",
base = file("akka-samples/akka-sample-hello-kernel"),
dependencies = Seq(kernel),
settings = defaultSettings
)
lazy val tutorials = Project(
id = "akka-tutorials",
base = file("akka-tutorials"),
@ -388,9 +395,7 @@ object Dependencies {
val spring = Seq(springBeans, springContext, Test.junit, Test.scalatest)
val kernel = Seq(
jettyUtil, jettyXml, jettyServlet, jacksonCore, staxApi
)
val kernel = Seq()
// TODO: resolve Jetty version conflict
// val sampleCamel = Seq(camelCore, camelSpring, commonsCodec, Runtime.camelJms, Runtime.activemq, Runtime.springJms,

View file

@ -66,9 +66,8 @@ object Dist {
val libAkka = lib / "akka"
val src = base / "src" / "akka"
IO.delete(unzipped)
// TODO: re-enable bin and config dirs, and add deploy dir, when akka-kernel is enabled
//copyFilesTo(scripts, bin, setExecutable = true)
//IO.copyDirectory(configSources, config)
copyFilesTo(scripts, bin, setExecutable = true)
IO.copyDirectory(configSources, config)
IO.copyDirectory(allSources.api, api)
IO.copyDirectory(allSources.docs, docs)
copyFilesTo(allSources.docJars, docJars)

View file

@ -1,9 +1,18 @@
#!/bin/bash
#!/usr/bin/env bash
AKKA_HOME="$(cd "$(cd "$(dirname "$0")"; pwd -P)"/..; pwd)"
declare quiet="false"
while true; do
case "$1" in
-q | --quiet ) quiet="true"; shift ;;
* ) break ;;
esac
done
declare 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
java $JAVA_OPTS -cp "$AKKA_CLASSPATH" -Dakka.home="$AKKA_HOME" -Dakka.kernel.quiet=$quiet akka.kernel.Main