+
+ /**
+ * This method should be called only once during initialization
+ *
+ * @param bundleContext
+ */
+ public static final ActorSystem createInstance(final BundleContext bundleContext) {
+ if(actorSystem == null) {
+ // Create an OSGi bundle classloader for actor system
+ BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundleContext.getBundle(),
+ Thread.currentThread().getContextClassLoader());
+ synchronized (ActorSystemFactory.class) {
+ // Double check
+
+ if (actorSystem == null) {
+ ActorSystem system = ActorSystem.create(ACTOR_SYSTEM_NAME,
+ ConfigFactory.load(readAkkaConfiguration()).getConfig(CONFIGURATION_NAME), classLoader);
+ system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");
+ actorSystem = system;
+ }
+ }
+ }
+
+ return actorSystem;
+ }
+
+
+ private static final Config readAkkaConfiguration(){
+ File defaultConfigFile = new File(AKKA_CONF_PATH);
+ Preconditions.checkState(defaultConfigFile.exists(), "akka.conf is missing");
+ return ConfigFactory.parseFile(defaultConfigFile);
+ }