@Override public void stop(final StopContext context) { SingletonProvider.reset(); }
@Override public void start(final StartContext context) throws StartException { SingletonProvider.initialize(new ModuleGroupSingletonProvider()); }
newBda.addBeanClass(beanClass); ServiceRegistry newBdaServices = newBda.getServices(); for (Entry<Class<? extends Service>, Service> entry : serviceRegistry.entrySet()) { if (!newBdaServices.contains(entry.getKey())) { newBdaServices.add(entry.getKey(), Reflections.cast(entry.getValue())); newBdaServices.add(ResourceLoader.class, serviceRegistry.get(ResourceLoader.class)); newBda.getServices().add(EEModuleDescriptor.class, eeModuleDescriptors.get(module.getIdentifier()));
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; }
private void addInterceptorInstance(Interceptor<Object> interceptor, BeanManagerImpl beanManager, Map<String, SerializableContextualInstance<Interceptor<Object>, Object>> instances, final CreationalContext<Object> creationalContext) { Object instance = beanManager.getReference(interceptor, interceptor.getBeanClass(), creationalContext, true); SerializableContextualInstance<Interceptor<Object>, Object> serializableContextualInstance = beanManager.getServices().get(ContextualStore.class).<Interceptor<Object>, Object>getSerializableContextualInstance(interceptor, instance, creationalContext); instances.put(interceptor.getBeanClass().getName(), serializableContextualInstance); }
if (!deployment.getServices().contains(ExecutorServices.class)) { addWeldService(ExecutorServices.class, executorServicesSupplier.get());
/** * Get the container for the current application deployment * * @return */ public static Container instance() { return instance.get(RegistrySingletonProvider.STATIC_INSTANCE); }
/** * 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 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(); }
private InterceptorBindings getInterceptorBindings(final String ejbName, final BeanManagerImpl manager) { InterceptorBindings retVal = null; if (ejbName != null) { retVal = interceptorSupport.getInterceptorBindings(ejbName, manager); } else { // This is a managed bean SlimAnnotatedType<?> type = (SlimAnnotatedType<?>) manager.createAnnotatedType(componentClass); if (!manager.getInterceptorModelRegistry().containsKey(type)) { EnhancedAnnotatedType<?> enhancedType = manager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(type); InterceptionModelInitializer.of(manager, enhancedType, null).init(); } InterceptionModel model = manager.getInterceptorModelRegistry().get(type); if (model != null) { retVal = new InterceptorBindingsAdapter(manager.getInterceptorModelRegistry().get(type)); } } return retVal != null ? retVal : NullInterceptorBindings.INSTANCE; }
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); }
private void checkNoArgsConstructor(EnhancedAnnotatedType<T> type) { if (!beanManager.getServices().get(ProxyInstantiator.class).isUsingConstructor()) { return; } EnhancedAnnotatedConstructor<T> constructor = type.getNoArgsEnhancedConstructor(); if (constructor == null) { throw BeanLogger.LOG.decoratedHasNoNoargsConstructor(this); } else if (constructor.isPrivate()) { throw BeanLogger.LOG .decoratedNoargsConstructorIsPrivate(this, Formats.formatAsStackTraceElement(constructor.getJavaMember())); } }
bda.getServices().add(moduleService.getKey(), Reflections.cast(moduleService.getValue()));
final ClassTransformer transformer = beanManager.getServices().get(ClassTransformer.class); @SuppressWarnings("unchecked") final Class<T> clazz = (Class<T>) componentClass;
beanDeploymentArchives.add(additional); for (Entry<Class<? extends Service>, Service> entry : rootModuleServices.entrySet()) { additional.getServices().add(entry.getKey(), Reflections.cast(entry.getValue()));
beanManager.getServices().get(InjectionTargetService.class).validateProducer(injectionTarget);
private void checkDecoratedMethods(EnhancedAnnotatedType<T> type, List<Decorator<?>> decorators) { if (type.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithDecoratorsNotAllowed(this); } checkNoArgsConstructor(type); for (Decorator<?> decorator : decorators) { EnhancedAnnotatedType<?> decoratorClass; if (decorator instanceof DecoratorImpl<?>) { DecoratorImpl<?> decoratorBean = (DecoratorImpl<?>) decorator; decoratorClass = decoratorBean.getBeanManager().getServices().get(ClassTransformer.class) .getEnhancedAnnotatedType(decoratorBean.getAnnotated()); } else if (decorator instanceof CustomDecoratorWrapper<?>) { decoratorClass = ((CustomDecoratorWrapper<?>) decorator).getEnhancedAnnotated(); } else { throw BeanLogger.LOG.nonContainerDecorator(decorator); } for (EnhancedAnnotatedMethod<?, ?> decoratorMethod : decoratorClass.getEnhancedMethods()) { EnhancedAnnotatedMethod<?, ?> method = type.getEnhancedMethod(decoratorMethod.getSignature()); if (method != null && !method.isStatic() && !method.isPrivate() && method.isFinal()) { throw BeanLogger.LOG.finalBeanClassWithInterceptorsNotAllowed(this); } } } }
InjectionTargetService injectionTargetService = it.getBeanManager().getServices().get(InjectionTargetService.class); injectionTargetService.addInjectionTargetToBeInitialized(jit.getEnhancedAnnotatedType(), jit); return jit;
protected TransactionalObserverNotifier(String contextId, TypeSafeObserverResolver resolver, ServiceRegistry services, boolean strict) { super(resolver, services, strict); this.contextId = contextId; this.transactionServices = services.get(TransactionServices.class); }