Merge branch 'master' of git@github.com:jboner/akka
This commit is contained in:
commit
166f9a0af3
4 changed files with 39 additions and 44 deletions
|
|
@ -41,6 +41,12 @@ object Config {
|
|||
}
|
||||
|
||||
val config = {
|
||||
|
||||
val confName = System.getenv("AKKA_MODE") match {
|
||||
case null | "" => Option(System.getProperty("akka.mode")).map("akka." + _ + ".conf").getOrElse("akka.conf")
|
||||
case s:String => "akka." + s + ".conf"
|
||||
}
|
||||
|
||||
if (System.getProperty("akka.config", "") != "") {
|
||||
val configFile = System.getProperty("akka.config", "")
|
||||
try {
|
||||
|
|
@ -52,19 +58,9 @@ object Config {
|
|||
"\n\tdue to: " + e.toString)
|
||||
}
|
||||
Configgy.config
|
||||
} else if (getClass.getClassLoader.getResource("akka.conf") ne null) {
|
||||
} else if (HOME.isDefined) {
|
||||
try {
|
||||
Configgy.configureFromResource("akka.conf", getClass.getClassLoader)
|
||||
ConfigLogger.log.info("Config loaded from the application classpath.")
|
||||
} catch {
|
||||
case e: ParseException => throw new ConfigurationException(
|
||||
"Can't load 'akka.conf' config file from application classpath," +
|
||||
"\n\tdue to: " + e.toString)
|
||||
}
|
||||
Configgy.config
|
||||
} else if (HOME.isDefined) {
|
||||
try {
|
||||
val configFile = HOME.getOrElse(throwNoAkkaHomeException) + "/config/akka.conf"
|
||||
val configFile = HOME.getOrElse(throwNoAkkaHomeException) + "/config/" + confName
|
||||
Configgy.configure(configFile)
|
||||
ConfigLogger.log.info(
|
||||
"AKKA_HOME is defined as [%s], config loaded from [%s].",
|
||||
|
|
@ -73,18 +69,28 @@ object Config {
|
|||
} catch {
|
||||
case e: ParseException => throw new ConfigurationException(
|
||||
"AKKA_HOME is defined as [" + HOME.get + "] " +
|
||||
"\n\tbut the 'akka.conf' config file can not be found at [" + HOME.get + "/config/akka.conf]," +
|
||||
"\n\tbut the 'akka.conf' config file can not be found at [" + HOME.get + "/config/"+ confName + "]," +
|
||||
"\n\tdue to: " + e.toString)
|
||||
}
|
||||
Configgy.config
|
||||
} else if (getClass.getClassLoader.getResource(confName) ne null) {
|
||||
try {
|
||||
Configgy.configureFromResource(confName, getClass.getClassLoader)
|
||||
ConfigLogger.log.info("Config [%s] loaded from the application classpath.",confName)
|
||||
} catch {
|
||||
case e: ParseException => throw new ConfigurationException(
|
||||
"Can't load '" + confName + "' config file from application classpath," +
|
||||
"\n\tdue to: " + e.toString)
|
||||
}
|
||||
Configgy.config
|
||||
} else {
|
||||
ConfigLogger.log.warning(
|
||||
"\nCan't load 'akka.conf'." +
|
||||
"\nOne of the three ways of locating the 'akka.conf' file needs to be defined:" +
|
||||
"\nCan't load '" + confName + "'." +
|
||||
"\nOne of the three ways of locating the '" + confName + "' file needs to be defined:" +
|
||||
"\n\t1. Define the '-Dakka.config=...' system property option." +
|
||||
"\n\t2. Put the 'akka.conf' file on the classpath." +
|
||||
"\n\t2. Put the '" + confName + "' file on the classpath." +
|
||||
"\n\t3. Define 'AKKA_HOME' environment variable pointing to the root of the Akka distribution." +
|
||||
"\nI have no way of finding the 'akka.conf' configuration file." +
|
||||
"\nI have no way of finding the '" + confName + "' configuration file." +
|
||||
"\nUsing default values everywhere.")
|
||||
CConfig.fromString("<akka></akka>") // default empty config
|
||||
}
|
||||
|
|
@ -92,7 +98,7 @@ object Config {
|
|||
|
||||
val CONFIG_VERSION = config.getString("akka.version", VERSION)
|
||||
if (VERSION != CONFIG_VERSION) throw new ConfigurationException(
|
||||
"Akka JAR version [" + VERSION + "] is different than the provided config ('akka.conf') version [" + CONFIG_VERSION + "]")
|
||||
"Akka JAR version [" + VERSION + "] is different than the provided config version [" + CONFIG_VERSION + "]")
|
||||
|
||||
val TIME_UNIT = config.getString("akka.time-unit", "seconds")
|
||||
|
||||
|
|
|
|||
|
|
@ -258,13 +258,8 @@ object ReflectiveAccess extends Logging {
|
|||
ctor.setAccessible(true)
|
||||
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
||||
} catch {
|
||||
case e: java.lang.reflect.InvocationTargetException =>
|
||||
e.printStackTrace
|
||||
log.error(e.getCause, "Could not instantiate class [%s]", clazz.getName)
|
||||
None
|
||||
case e: Exception =>
|
||||
e.printStackTrace
|
||||
log.error(e.getCause, "Could not instantiate class [%s]", clazz.getName)
|
||||
log.debug(e, "Could not instantiate class [%s] due to [%s]", clazz.getName, e.getMessage)
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -280,13 +275,8 @@ object ReflectiveAccess extends Logging {
|
|||
ctor.setAccessible(true)
|
||||
Some(ctor.newInstance(args: _*).asInstanceOf[T])
|
||||
} catch {
|
||||
case e: java.lang.reflect.InvocationTargetException =>
|
||||
e.printStackTrace
|
||||
log.error(e.getCause, "Could not instantiate class [%s] due to [%s]", fqn, e.toString)
|
||||
None
|
||||
case e: Exception =>
|
||||
e.printStackTrace
|
||||
log.error(e.getCause, "Could not instantiate class [%s] due to [%s]", fqn, e.toString)
|
||||
log.debug(e, "Could not instantiate class [%s] due to [%s]", fqn, e.getMessage)
|
||||
None
|
||||
}
|
||||
|
||||
|
|
@ -297,13 +287,8 @@ object ReflectiveAccess extends Logging {
|
|||
instance.setAccessible(true)
|
||||
Option(instance.get(null).asInstanceOf[T])
|
||||
} catch {
|
||||
case e: java.lang.reflect.InvocationTargetException =>
|
||||
e.printStackTrace
|
||||
log.error(e.getCause, "Could not instantiate class [%s]", fqn)
|
||||
None
|
||||
case e: Exception =>
|
||||
e.printStackTrace
|
||||
log.error(e.getCause, "Could not instantiate class [%s]", fqn)
|
||||
log.debug(e, "Could not get object [%s] due to [%s]", fqn, e.getMessage)
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,23 +5,27 @@
|
|||
package se.scalablesolutions.akka.comet
|
||||
|
||||
import org.atmosphere.cpr.{AtmosphereResourceEvent, AtmosphereResource}
|
||||
|
||||
import se.scalablesolutions.akka.actor.Actor._
|
||||
import se.scalablesolutions.akka.actor.Actor
|
||||
import se.scalablesolutions.akka.dispatch.Dispatchers
|
||||
import org.atmosphere.jersey.util.JerseyBroadcasterUtil
|
||||
|
||||
object AkkaBroadcaster {
|
||||
val broadcasterDispatcher = Dispatchers.fromConfig("akka.rest.comet-dispatcher")
|
||||
|
||||
type Event = AtmosphereResourceEvent[_,_]
|
||||
type Resource = AtmosphereResource[_,_]
|
||||
}
|
||||
|
||||
class AkkaBroadcaster extends org.atmosphere.jersey.JerseyBroadcaster {
|
||||
class AkkaBroadcaster extends org.atmosphere.jersey.util.JerseySimpleBroadcaster {
|
||||
import AkkaBroadcaster._
|
||||
name = classOf[AkkaBroadcaster].getName
|
||||
|
||||
//FIXME should be supervised
|
||||
val caster = actorOf(new Actor {
|
||||
lazy val caster = actorOf(new Actor {
|
||||
self.dispatcher = broadcasterDispatcher
|
||||
def receive = {
|
||||
case f : Function0[_] => f()
|
||||
case (r: Resource,e: Event) => JerseyBroadcasterUtil.broadcast(r,e)
|
||||
}
|
||||
}).start
|
||||
|
||||
|
|
@ -30,7 +34,7 @@ class AkkaBroadcaster extends org.atmosphere.jersey.JerseyBroadcaster {
|
|||
caster.stop
|
||||
}
|
||||
|
||||
protected override def broadcast(r : AtmosphereResource[_,_], e : AtmosphereResourceEvent[_,_]) = {
|
||||
caster ! (() => super.broadcast(r,e))
|
||||
protected override def broadcast(r: Resource, e : Event) {
|
||||
caster ! ((r,e))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,7 +91,7 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) {
|
|||
// Versions
|
||||
// -------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
lazy val ATMO_VERSION = "0.6.1"
|
||||
lazy val ATMO_VERSION = "0.6.2"
|
||||
lazy val CAMEL_VERSION = "2.4.0"
|
||||
lazy val CASSANDRA_VERSION = "0.6.1"
|
||||
lazy val DISPATCH_VERSION = "0.7.4"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue