Allow fallback classloader to be explicitly specified

(cherry picked from commit f51a2894150e0f5cc6923b8e3aa42d7ebdd6663d)
This commit is contained in:
Michael Pilquist 2012-11-16 12:55:27 -05:00 committed by Patrik Nordwall
parent 739583e384
commit 44c317832a

View file

@ -12,12 +12,12 @@ import org.osgi.framework.BundleContext
* Factory class to create ActorSystem implementations in an OSGi environment. This mainly involves dealing with
* bundle classloaders appropriately to ensure that configuration files and classes get loaded properly
*/
class OsgiActorSystemFactory(val context: BundleContext) {
class OsgiActorSystemFactory(val context: BundleContext, val fallbackClassLoader: Option[ClassLoader]) {
/*
* Classloader that delegates to the bundle for which the factory is creating an ActorSystem
*/
private val classloader = new BundleDelegatingClassLoader(context.getBundle, Some(classOf[ActorSystem].getClassLoader))
private val classloader = new BundleDelegatingClassLoader(context.getBundle, fallbackClassLoader)
/**
* Creates the [[akka.actor.ActorSystem]], using the name specified
@ -52,5 +52,5 @@ object OsgiActorSystemFactory {
/*
* Create an [[OsgiActorSystemFactory]] instance to set up Akka in an OSGi environment
*/
def apply(context: BundleContext): OsgiActorSystemFactory = new OsgiActorSystemFactory(context)
def apply(context: BundleContext): OsgiActorSystemFactory = new OsgiActorSystemFactory(context, Some(classOf[ActorSystem].getClassLoader))
}