ClassLoader cl = new ShrinkWrapClassLoader(archive);
Thread.currentThread().setContextClassLoader(cl);
final ShrinkWrapMetaDataDiscovery discovery = new ShrinkWrapMetaDataDiscovery(archive);
ContainerLifecycle lifecycle = new StandaloneLifeCycle()
{
// TODO this override method will need to change to afterInitApplication(Properties) after 1.0.0-M4
@Override
public void init()
{
super.init();
log.info("Using discovery service impl class adapted to ShrinkWrap archive : [" + discovery.getClass().getName() + "]");
this.discoveryService = discovery;
}
};
try
{
lifecycle.start(null);
}
catch (Exception e)
{
throw new RuntimeException("Failed to start standalone OpenWebBeans container", e);
}
BeanManager manager = lifecycle.getBeanManager();
// start the application lifecycle
ContextFactory.initApplicationContext(null);
// start the session lifecycle
HttpSession session = new MockHttpSession();