/** * Gets the {@link BeanManager} linked to the root bean deployment archive. This BeanManager has access to all beans in a * deployment * * @throws IllegalStateException if the container is not running */ public BeanManagerImpl getBeanManager() { if (!started) { throw WeldLogger.ROOT_LOGGER.notStarted("WeldContainer"); } return bootstrap.getManager(rootBeanDeploymentArchive); }
/** * Gets the {@link BeanManager} for a given bean deployment archive id. * * @throws IllegalStateException if the container is not running * @throws IllegalArgumentException if the bean deployment archive id is not found */ public BeanManagerImpl getBeanManager(String beanArchiveId) { if (!started) { throw WeldLogger.ROOT_LOGGER.notStarted("WeldContainer"); } BeanDeploymentArchive beanDeploymentArchive = beanDeploymentArchives.get(beanArchiveId); if (beanDeploymentArchive == null) { throw WeldLogger.ROOT_LOGGER.beanDeploymentNotFound(beanArchiveId); } return bootstrap.getManager(beanDeploymentArchive); }
/** * Stops the container * Executed in WeldStartService to shutdown the runtime before NamingService is closed. * * @throws IllegalStateException if the container is not running */ @Override public void stop(final StopContext context) { final WeldBootstrapService bootstrapService = bootstrapSupplier.get(); if (!bootstrapService.isStarted()) { throw WeldLogger.ROOT_LOGGER.notStarted("WeldContainer"); } WeldLogger.DEPLOYMENT_LOGGER.stoppingWeldService(bootstrapService.getDeploymentName()); ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(bootstrapService.getDeployment().getModule().getClassLoader()); WeldProvider.containerShutDown(Container.instance(bootstrapService.getDeploymentName())); bootstrapService.getBootstrap().shutdown(); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); ModuleGroupSingletonProvider.removeClassLoader(bootstrapService.getDeployment().getModule().getClassLoader()); } bootstrapService.setStarted(false); }