*
ClassLoader cl = new ShrinkWrapClassLoader(archive);
Thread.currentThread().setContextClassLoader(cl);
*/
final ShrinkWrapMetaDataDiscovery discovery = new ShrinkWrapMetaDataDiscovery(archive);
ContainerLifecycle lifecycle = new StandaloneLifeCycle()
{
/**
* Override so we can set out own scannerService.
* TODO: We should change this to use the ServiceLoader via openwebbeans.properties, then do something like:
* ((ShrinkWrapScannerService)StandardLifecycle.getScannerService()).setArchive(deployment)
*/
@Override
protected void afterInitApplication(Properties properties)
{
super.afterInitApplication(properties);
this.scannerService = discovery;
}
};
try
{
lifecycle.startApplication(null);
}
catch (Exception e)
{
throw new RuntimeException("Failed to start standalone OpenWebBeans container", e);
}
lifecycleProducer.set(lifecycle);
beanManagerProducer.set(lifecycle.getBeanManager());
return new ProtocolMetaData();
}