public ScriptedContainerBuilderFactory(URL compositionURL, String builderClassName, ClassLoader contextClassLoader) throws ClassNotFoundException {
createContainerBuilder(compositionURL, contextClassLoader, builderClassName);
}
private void createContainerBuilder(Object composition, ClassLoader classLoader, String builderClass) throws ClassNotFoundException {
DefaultNanoContainer defaultNanoContainer;
{
// transient.
DefaultPicoContainer factory = new DefaultPicoContainer();
if(composition == null) {
throw new NullPointerException("composition can't be null");
}
factory.registerComponentInstance(composition);
if(classLoader == null) {
// on some weird JVMs (like jeode) Thread.currentThread().getContextClassLoader() returns null !?!?
classLoader = getClass().getClassLoader();
}
factory.registerComponentInstance(classLoader);
defaultNanoContainer = new DefaultNanoContainer(factory);
}
ComponentAdapter componentAdapter = defaultNanoContainer.registerComponentImplementation(builderClass);
containerBuilder = (ScriptedContainerBuilder) componentAdapter.getComponentInstance(defaultNanoContainer.getPico());
}