public boolean deploy(Collection<Class<?>> classes, Collection<URL> beansXml) { this.testContainer = new TestContainer(beansXml, classes); try { testContainer.startContainer(); } catch (Exception e) { this.deploymentException = new DeploymentException("Error deploying beans", e); return false; } testContainer.ensureRequestActive(); return true; }
public boolean deploy(Collection<Class<?>> classes, Collection<URL> beansXml) { this.testContainer = new TestContainer(beansXml, classes); try { testContainer.startContainer(); } catch (Exception e) { this.deploymentException = new DeploymentException("Error deploying beans", e); return false; } testContainer.ensureRequestActive(); return true; }
/** * Bootstrap and shutdown the container. * * @param runnable a {@link Runnable} to be called whilst the container is * active * */ public void run(Runnable runnable) throws Exception { TestContainer container = null; try { container = new TestContainer(beansXml, classes); container.startContainer().ensureRequestActive(); runnable.run(container.getBeanManager(container.getDeployment().getBeanDeploymentArchives().iterator().next())); } finally { if (container != null) { container.stopContainer(); } } }
/** * Bootstrap and shutdown the container. * * @param runnable a {@link Runnable} to be called whilst the container is * active * */ public void run(Runnable runnable) throws Exception { TestContainer container = null; try { container = new TestContainer(beansXml, classes); container.startContainer().ensureRequestActive(); runnable.run(container.getBeanManager(container.getDeployment().getBeanDeploymentArchives().iterator().next())); } finally { if (container != null) { container.stopContainer(); } } }
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException { ShrinkWrapClassLoader classLoader = getClassLoader(archive); ContextClassLoaderManager classLoaderManager = new ContextClassLoaderManager(classLoader); classLoaderManager.enable(); TestContainer container = new TestContainer(findArchiveId(archive), findBeansXml(archive), findBeanClasses(archive, classLoader), true); Bootstrap bootstrap = container.getBootstrap(); contextClassLoaderManagerProducer.set(classLoaderManager); try { container.startContainer(); } finally { // always set container - even if an exception occurs, we want the container to be cleaned up properly in undeploy() testContainerProducer.set(container); bootstrapProducer.set(bootstrap); } // Assume a flat structure WeldManager manager = container.getBeanManager(container.getDeployment().getBeanDeploymentArchives().iterator().next()); weldManagerProducer.set(manager); beanManagerProducer.set(manager); return new ProtocolMetaData(); }
classLoaderManager.enable(); TestContainer container = new TestContainer(findArchiveId(archive), findBeansXml(archive), findBeanClasses(archive, classLoader)); Bootstrap bootstrap = container.getBootstrap();