Permalink
Browse files

Removing Akka provided implementation of ActorSystem OSGi Service.

  • Loading branch information...
atooni committed Sep 30, 2018
1 parent 3baa37d commit ab847997c334a71551e7f1009e6b2535bdcb1a38
@@ -1,57 +1,26 @@
package blended.akka.internal
import scala.util.control.NonFatal
import akka.actor.ActorSystem
import akka.event.LogSource
import akka.osgi.ActorSystemActivator
import blended.container.context.api.{ ContainerContext, ContainerIdentifierService }
import blended.container.context.api.ContainerIdentifierService
import blended.util.logging.Logger
import com.typesafe.config.Config
import domino.DominoActivator
import domino.capsule.Capsule
import org.osgi.framework.BundleContext
object BlendedAkkaActivator {
implicit val logSource: LogSource[AnyRef] = new LogSource[AnyRef] {
def genString(o: AnyRef): String = o.getClass.getName
override def getClazz(o: AnyRef): Class[_] = o.getClass
}
}
class BlendedAkkaActivator extends DominoActivator {
private[this] val log = Logger[BlendedAkkaActivator]
private class AkkaCapsule(bundleContext: BundleContext, containerContext: ContainerContext)
extends ActorSystemActivator with Capsule {
override def start(): Unit = start(bundleContext)
override def stop(): Unit = stop(bundleContext)
def configure(osgiContext: BundleContext, system: ActorSystem): Unit = {
log.info("Registering Actor System as Service.")
registerService(osgiContext, system)
log.info(s"ActorSystem [${system.name}] initialized.")
}
whenBundleActive {
whenServicePresent[ContainerIdentifierService] { svc =>
val ctConfig = svc.containerContext.getContainerConfig()
override def getActorSystemName(context: BundleContext): String = "BlendedActorSystem"
log.debug(s"$ctConfig")
override def getActorSystemConfiguration(context: BundleContext): Config = try {
containerContext.getContainerConfig()
} catch {
case NonFatal(e) =>
log.warn(s"Error retrieving config for ActorSystem [${e.getMessage()}]")
throw e
}
}
val system : ActorSystem = ActorSystem.create("BlendedActorSystem", ctConfig, classOf[ActorSystem].getClassLoader())
system.providesService[ActorSystem]
whenBundleActive {
whenServicePresent[ContainerIdentifierService] { svc =>
addCapsule(new AkkaCapsule(bundleContext, svc.containerContext))
onStop {
system.terminate()
}
}
}
}
@@ -127,10 +127,10 @@ class ContainerContextImpl() extends ContainerContext {
}
config.withFallback(ConfigFactory.parseFile(
new File(getProfileConfigDirectory(), "application.conf"), ConfigParseOptions.defaults().setAllowMissing(false)
)).
withFallback(sysProps).
withFallback(envProps).
resolve()
))
.withFallback(sysProps)
.withFallback(envProps)
.resolve()
}
override def getContainerConfig() = ctConfig
@@ -8,7 +8,6 @@ object BlendedAkka extends ProjectFactory {
deps = Seq(
Dependencies.orgOsgi,
Dependencies.akkaActor,
Dependencies.akkaOsgi,
Dependencies.domino
),
adaptBundle = b => b.copy(

0 comments on commit ab84799

Please sign in to comment.