Merge with master
This commit is contained in:
commit
435de7b689
4 changed files with 31 additions and 17 deletions
|
|
@ -19,11 +19,10 @@ trait BootableActorLoaderService extends Bootable with Logging {
|
|||
val BOOT_CLASSES = config.getList("akka.boot")
|
||||
lazy val applicationLoader: Option[ClassLoader] = createApplicationClassLoader
|
||||
|
||||
protected def createApplicationClassLoader : Option[ClassLoader] = {
|
||||
Some(
|
||||
protected def createApplicationClassLoader : Option[ClassLoader] = Some({
|
||||
if (HOME.isDefined) {
|
||||
val CONFIG = HOME.getOrElse(throwNoAkkaHomeException) + "/config"
|
||||
val DEPLOY = HOME.getOrElse(throwNoAkkaHomeException) + "/deploy"
|
||||
val CONFIG = HOME.get + "/config"
|
||||
val DEPLOY = HOME.get + "/deploy"
|
||||
val DEPLOY_DIR = new File(DEPLOY)
|
||||
if (!DEPLOY_DIR.exists) {
|
||||
log.slf4j.error("Could not find a deploy directory at [{}]", DEPLOY)
|
||||
|
|
@ -47,8 +46,8 @@ trait BootableActorLoaderService extends Bootable with Logging {
|
|||
val allJars = toDeploy ::: dependencyJars
|
||||
|
||||
new URLClassLoader(allJars.toArray,Thread.currentThread.getContextClassLoader)
|
||||
} else Thread.currentThread.getContextClassLoader)
|
||||
}
|
||||
} else Thread.currentThread.getContextClassLoader
|
||||
})
|
||||
|
||||
abstract override def onLoad = {
|
||||
applicationLoader.foreach(_ => log.slf4j.info("Creating /deploy class-loader"))
|
||||
|
|
|
|||
|
|
@ -144,8 +144,8 @@ object ReflectiveAccess extends Logging {
|
|||
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
||||
} catch {
|
||||
case e =>
|
||||
log.slf4j.warn("Could not instantiate class [{}] due to [{}]", clazz.getName, e.getCause)
|
||||
e.printStackTrace
|
||||
log.slf4j.warn("Could not instantiate class [{}]", clazz.getName)
|
||||
log.slf4j.warn("createInstance",e.getCause)
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +162,8 @@ object ReflectiveAccess extends Logging {
|
|||
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
||||
} catch {
|
||||
case e =>
|
||||
log.slf4j.warn("Could not instantiate class [{}] due to [{}]", fqn, e.getCause)
|
||||
log.slf4j.warn("Could not instantiate class [{}]", fqn)
|
||||
log.slf4j.warn("createInstance",e.getCause)
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -174,12 +175,13 @@ object ReflectiveAccess extends Logging {
|
|||
Option(instance.get(null).asInstanceOf[T])
|
||||
} catch {
|
||||
case e: ClassNotFoundException => {
|
||||
log.slf4j.debug("Could not get object [{}] due to [{}]", fqn, e)
|
||||
log.slf4j.debug("Could not get object [{}]", fqn)
|
||||
log.slf4j.debug("getObjectFor", e)
|
||||
None
|
||||
}
|
||||
case ei: ExceptionInInitializerError => {
|
||||
log.error("Exception in initializer for object [%s]".format(fqn))
|
||||
log.error(ei.getCause, "Cause was:")
|
||||
log.slf4j.error("Exception in initializer for object [{}]",fqn)
|
||||
log.slf4j.error("Cause was:",ei.getCause)
|
||||
throw ei
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import java.io.File
|
|||
import akka.actor.BootableActorLoaderService
|
||||
import akka.util.{Bootable, Logging}
|
||||
|
||||
//import akka.comet.AkkaServlet
|
||||
|
||||
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)
|
||||
|
|
@ -32,17 +32,21 @@ trait EmbeddedAppServer extends Bootable with Logging {
|
|||
|
||||
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) {
|
||||
log.slf4j.info("Attempting to start Akka HTTP service")
|
||||
|
||||
val configuration = new XmlConfiguration(findJettyConfigXML.getOrElse(error("microkernel-server.xml not found!")))
|
||||
|
||||
System.setProperty("jetty.port", REST_PORT.toString)
|
||||
System.setProperty("jetty.host", REST_HOSTNAME)
|
||||
System.setProperty("jetty.home", HOME.getOrElse(throwNoAkkaHomeException) + "/deploy/root")
|
||||
|
||||
val configuration = new XmlConfiguration(
|
||||
new File(HOME.getOrElse(throwNoAkkaHomeException) + "/config/microkernel-server.xml").toURI.toURL)
|
||||
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 =>
|
||||
|
|
|
|||
|
|
@ -380,6 +380,7 @@ final class TypedActorConfiguration {
|
|||
private[akka] var _host: Option[InetSocketAddress] = None
|
||||
private[akka] var _messageDispatcher: Option[MessageDispatcher] = None
|
||||
private[akka] var _threadBasedDispatcher: Option[Boolean] = None
|
||||
private[akka] var _id: Option[String] = None
|
||||
|
||||
def timeout = _timeout
|
||||
def timeout(timeout: Duration) : TypedActorConfiguration = {
|
||||
|
|
@ -387,6 +388,12 @@ final class TypedActorConfiguration {
|
|||
this
|
||||
}
|
||||
|
||||
def id = _id
|
||||
def id(id: String): TypedActorConfiguration = {
|
||||
_id = Option(id)
|
||||
this
|
||||
}
|
||||
|
||||
def makeRemote(hostname: String, port: Int): TypedActorConfiguration = makeRemote(new InetSocketAddress(hostname, port))
|
||||
|
||||
def makeRemote(remoteAddress: InetSocketAddress): TypedActorConfiguration = {
|
||||
|
|
@ -564,6 +571,8 @@ object TypedActor extends Logging {
|
|||
typedActor.initialize(proxy)
|
||||
if (config._messageDispatcher.isDefined) actorRef.dispatcher = config._messageDispatcher.get
|
||||
if (config._threadBasedDispatcher.isDefined) actorRef.dispatcher = Dispatchers.newThreadBasedDispatcher(actorRef)
|
||||
if (config._id.isDefined) actorRef.id = config._id.get
|
||||
|
||||
actorRef.timeout = config.timeout
|
||||
//log.slf4j.debug("config._host for {} is {} but homeAddress is {} and on ref {}",Array[AnyRef](intfClass, config._host, typedActor.context.homeAddress,actorRef.homeAddress))
|
||||
AspectInitRegistry.register(proxy, AspectInit(intfClass, typedActor, actorRef, actorRef.homeAddress, actorRef.timeout))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue