ShrinkWrapClassLoader classLoader = new ShrinkWrapClassLoader(archive.getClass().getClassLoader(), archive);
ContextClassLoaderManager classLoaderManager = new ContextClassLoaderManager(classLoader);
classLoaderManager.enable();
TestContainer container = new TestContainer(findArchiveId(archive), findBeansXml(archive), findBeanClasses(archive, classLoader));
Bootstrap bootstrap = container.getLifecycle().getBootstrap();
context.add(ContextClassLoaderManager.class, classLoaderManager);
container.startContainer();
context.add(TestContainer.class, container);
context.add(Bootstrap.class, bootstrap);
// Assume a flat structure
context.add(WeldManager.class, container.getBeanManager(container.getDeployment().getBeanDeploymentArchives().iterator().next()));
context.register(AfterDeploy.class, new SessionLifeCycleCreator());
context.register(BeforeUnDeploy.class, new SessionLifeCycleDestoryer());
context.register(Before.class, new RequestLifeCycleCreator());