+
+ synchronized private static final ActorSystem getOrCreateInstance(final BundleContext bundleContext, ConfigurationReader configurationReader) {
+
+ AtomicReference<ActorSystem> actorSystemReference = persistentActorSystem;
+ String configurationName = CONFIGURATION_NAME;
+ String actorSystemName = ACTOR_SYSTEM_NAME;
+
+ if (actorSystemReference.get() != null){
+ return actorSystemReference.get();
+ }
+
+ // Create an OSGi bundle classloader for actor system
+ BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundleContext.getBundle(),
+ Thread.currentThread().getContextClassLoader());
+
+ ActorSystem system = ActorSystem.create(actorSystemName,
+ ConfigFactory.load(configurationReader.read()).getConfig(configurationName), classLoader);
+ system.actorOf(Props.create(TerminationMonitor.class), "termination-monitor");
+
+ actorSystemReference.set(system);
+ return system;
+ }
+