/** * Adds a service to all bean deployment archives in the module * @param clazz The service type * @param service The service * @param <S> The service type */ public synchronized <S extends Service> void addService(Class<S> clazz, S service) { for (BeanDeploymentArchiveImpl bda : beanDeploymentArchives) { bda.getServices().add(clazz,service); } }
public BeanDeploymentArchiveImpl(Set<String> beanClasses, Set<String> allClasses, BeansXml beansXml, Module module, String id, BeanArchiveType beanArchiveType, boolean root) { this.beanClasses = new ConcurrentSkipListSet<String>(beanClasses); this.allKnownClasses = new ConcurrentSkipListSet<String>(allClasses); this.beanDeploymentArchives = new CopyOnWriteArraySet<BeanDeploymentArchive>(); this.beansXml = beansXml; this.id = id; this.serviceRegistry = new SimpleServiceRegistry(); this.resourceLoader = new WeldModuleResourceLoader(module); this.serviceRegistry.add(ResourceLoader.class, resourceLoader); for (Entry<Class<? extends Service>, Service> entry : ServiceLoaders.loadBeanDeploymentArchiveServices(BeanDeploymentArchiveImpl.class, this) .entrySet()) { this.serviceRegistry.add(entry.getKey(), Reflections.cast(entry.getValue())); } this.module = module; this.ejbDescriptors = new HashSet<EjbDescriptor<?>>(); this.beanArchiveType = beanArchiveType; this.root = root; }
public WeldDeployment(Set<BeanDeploymentArchiveImpl> beanDeploymentArchives, Collection<Metadata<Extension>> extensions, Module module, Set<ClassLoader> subDeploymentClassLoaders, DeploymentUnit deploymentUnit, BeanDeploymentModule rootBeanDeploymentModule, Map<ModuleIdentifier, EEModuleDescriptor> eeModuleDescriptors) { this.subDeploymentClassLoaders = new HashSet<ClassLoader>(subDeploymentClassLoaders); this.beanDeploymentArchives = Collections.newSetFromMap(new ConcurrentHashMap<>()); this.beanDeploymentArchives.addAll(beanDeploymentArchives); this.extensions = new HashSet<Metadata<Extension>>(extensions); this.serviceRegistry = new SimpleServiceRegistry(); this.additionalBeanDeploymentArchivesByClassloader = new ConcurrentHashMap<>(); this.module = module; this.rootBeanDeploymentModule = rootBeanDeploymentModule; this.eeModuleDescriptors = eeModuleDescriptors; // add static services this.serviceRegistry.add(ProxyServices.class, new ProxyServicesImpl(module)); this.serviceRegistry.add(ResourceLoader.class, new WeldModuleResourceLoader(module)); calculateAccessibilityGraph(this.beanDeploymentArchives); makeTopLevelBdasVisibleFromStaticModules(); }
bda.getServices().add(moduleService.getKey(), Reflections.cast(moduleService.getValue()));
private void installBootstrapConfigurationService(WeldDeployment deployment, DeploymentUnit parentDeploymentUnit) { final boolean nonPortableMode = parentDeploymentUnit.getAttachment(WeldConfiguration.ATTACHMENT_KEY).isNonPortableMode(); final ExternalConfiguration configuration = new ExternalConfigurationBuilder() .add(ConfigurationKey.NON_PORTABLE_MODE.get(), nonPortableMode) .add(ConfigurationKey.ALLOW_OPTIMIZED_CLEANUP.get(), true) .build(); deployment.getServices().add(ExternalConfiguration.class, configuration); }
beanDeploymentArchives.add(additional); for (Entry<Class<? extends Service>, Service> entry : rootModuleServices.entrySet()) { additional.getServices().add(entry.getKey(), Reflections.cast(entry.getValue()));
@Override public void postServiceRegistration(PostServiceRegistrationContext ctx) { ctx.getServices().add(ExpressionLanguageSupport.class, EL_SUPPORT); ctx.getServices().add(ServletContextService.class, new ServletContextService()); ctx.getServices().add(ServletApiAbstraction.class, new ServletApiAbstraction(WeldClassLoaderResourceLoader.INSTANCE)); }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.cast(value)); } }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.<T>cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.<T>cast(value)); } }
@Override protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive() { WeldBeanDeploymentArchive archive = super.createAdditionalBeanDeploymentArchive(); archive.getServices().add(EEModuleDescriptor.class, eeModule); return archive; } };
@Override protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive() { WeldBeanDeploymentArchive archive = super.createAdditionalBeanDeploymentArchive(); archive.getServices().add(EEModuleDescriptor.class, eeModule); return archive; } };
private <T extends Service> void copyService(BeanDeploymentArchive archive, Class<T> serviceClass) { // for certain services we can fall back to deployment-level settings or defaults ServiceRegistry registry = archive.getServices(); if (!registry.contains(serviceClass)) { T service = deployment.getServices().get(serviceClass); if (service != null) { registry.add(serviceClass, service); } } }
private <T extends Service> void copyService(BeanDeploymentArchive archive, Class<T> serviceClass) { // for certain services we can fall back to deployment-level settings or defaults ServiceRegistry registry = archive.getServices(); if (!registry.contains(serviceClass)) { T service = deployment.getServices().get(serviceClass); if (service != null) { registry.add(serviceClass, service); } } }
private <T extends Service> void copyService(BeanDeploymentArchive archive, Class<T> serviceClass) { // for certain services we can fall back to deployment-level settings or defaults ServiceRegistry registry = archive.getServices(); if (!registry.contains(serviceClass)) { T service = deployment.getServices().get(serviceClass); if (service != null) { registry.add(serviceClass, service); } } }
private <T extends Service> void copyService(BeanDeploymentArchive archive, Class<T> serviceClass) { // for certain services we can fall back to deployment-level settings or defaults ServiceRegistry registry = archive.getServices(); if (!registry.contains(serviceClass)) { T service = deployment.getServices().get(serviceClass); if (service != null) { registry.add(serviceClass, service); } } }
@Override public void postBeanArchiveServiceRegistration(PostBeanArchiveServiceRegistrationContext ctx) { final ServiceRegistry services = ctx.getServices(); final EjbServices ejbServices = services.get(EjbServices.class); if (ejbServices != null) { // Must populate EJB cache first, as we need it to detect whether a // bean is an EJB! services.add(EjbSupport.class, new EjbSupportImpl(ejbServices, ctx.getBeanDeploymentArchive().getEjbs())); } }
@Override public void postServiceRegistration(PostServiceRegistrationContext ctx) { ctx.getServices().add(CurrentInvocationInjectionPoint.class, new CurrentInvocationInjectionPoint()); ctx.registerPlugableValidator(new WeldEjbValidator()); ctx.getServices().get(ResourceInjectionFactory.class).addResourceInjectionProcessor(new EjbResourceInjectionProcessor()); }
protected TestContainer bootstrapContainer(int id, Collection<Class<?>> classes) { // Bootstrap container SwitchableSingletonProvider.use(id); TestContainer container = new TestContainer(new FlatDeployment(new BeanDeploymentArchiveImpl(classes))); container.getDeployment().getServices().add(ProxyServices.class, new SwitchableCLProxyServices()); container.startContainer(); container.ensureRequestActive(); return container; }