Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * JBoss, Home of Professional Open Source
    * Copyright 2008, Red Hat, Inc., and individual contributors
    * by the @authors tag. See the copyright.txt in the distribution for a
    * full listing of individual contributors.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
   * http://www.apache.org/licenses/LICENSE-2.0
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.jboss.weld.manager;
  
  import static org.jboss.weld.annotated.AnnotatedTypeValidator.validateAnnotatedType;
  import static org.jboss.weld.util.reflection.Reflections.cast;
  import static org.jboss.weld.util.reflection.Reflections.isCacheable;
  
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  
 
 
 import  edu.umd.cs.findbugs.annotations.SuppressWarnings;

Implementation of the Bean Manager.

Essentially a singleton for registering Beans, Contexts, Observers, Interceptors etc. as well as providing resolution

Author(s):
Pete Muir
Marius Bogoevici
Ales Justin
Jozef Hartinger
 
 public class BeanManagerImpl implements WeldManagerSerializable {
 
     private static final long serialVersionUID = 3021562879133838561L;
 
     private static final String CREATIONAL_CONTEXT = "creationalContext";
     /*
     * Application scoped services
     * ***************************
     */
     private final transient ServiceRegistry services;
 
     /*
     * Application scoped data structures
     * ***********************************
     */
 
     // Contexts are shared across the application
     private final transient Map<Class<? extends Annotation>, List<Context>> contexts;
 
     // Client proxies can be used application wide
     private final transient ClientProxyProvider clientProxyProvider;
 
     // TODO review this structure
     private final transient Map<EjbDescriptor<?>, SessionBean<?>> enterpriseBeans;
 
     /*
     * Archive scoped data structures
     * ******************************
     */
 
     /* These data structures are all non-transitive in terms of bean deployment
     * archive accessibility, and the configuration for this bean deployment
     * archive
     */
     private transient volatile ModuleEnablement enabled;
     private final transient Set<CurrentActivitycurrentActivities;
 
 
     /*
     * Activity scoped services
     * *************************
     */
 
     /* These services are scoped to this activity only, but use data
     * structures that are transitive accessible from other bean deployment
     * archives
     */
     private final transient TypeSafeBeanResolver beanResolver;
     private final transient TypeSafeDecoratorResolver decoratorResolver;
     private final transient TypeSafeInterceptorResolver interceptorResolver;
     private final transient NameBasedResolver nameBasedResolver;
     private final transient ELResolver weldELResolver;
     private transient Namespace rootNamespace;
 
     /*
      * Lenient instances do not perform event type checking - this is required for firing container lifecycle events.
      * Strict instances do perform event type checking and are used for firing application an extension events.
      */
     private final transient ObserverNotifier accessibleLenientObserverNotifier;
     private final transient ObserverNotifier globalLenientObserverNotifier;
     private final transient ObserverNotifier globalStrictObserverNotifier;
 
     /*
     * Activity scoped data structures
     * ********************************
     */
 
     /* These data structures are scoped to this bean deployment archive activity
     * only and represent the beans, decorators, interceptors, namespaces and
     * observers deployed in this bean deployment archive activity
     */
     private final transient List<Bean<?>> enabledBeans;
     // shared beans are accessible from other bean archives (generally all beans except for built-in beans and @New beans)
     private final transient List<Bean<?>> sharedBeans;
     private final transient List<Decorator<?>> decorators;
     private final transient List<Interceptor<?>> interceptors;
     private final transient List<Stringnamespaces;
     private final transient List<ObserverMethod<?>> observers;
 
     /*
     * set that is only used to make sure that no duplicate beans are added
     */
     private transient Set<Bean<?>> beanSet = Collections.synchronizedSet(new HashSet<Bean<?>>());
 
     /*
      * Data structure representing all managers *accessible* from this bean
      * deployment archive activity
      */
     private final transient Set<BeanManagerImplmanagers;
 
     /*
     * These data structures represent the managers *accessible* from this bean
     * deployment archive activity
     */
     private final transient HashSet<BeanManagerImplaccessibleManagers;
 
     /*
     * This data structures represents child activities for this activity, it is
     * not transitively accessible
     */
     private final transient Set<BeanManagerImplchildActivities;
 
     private final transient AtomicInteger childIds;
 
     private final String id;
     private final String contextId;

    
Interception model
 
     private final transient InterceptorMetadataReader interceptorMetadataReader = new InterceptorMetadataReader(this);
 
     private final transient ContainerLifecycleEvents containerLifecycleEvents;
 
     private final transient SpecializationAndEnablementRegistry registry;

    
Create a new, root, manager

Parameters:
serviceRegistry
Returns:
 
     public static BeanManagerImpl newRootManager(String contextIdString idServiceRegistry serviceRegistry) {
         Map<Class<? extends Annotation>, List<Context>> contexts = new ConcurrentHashMap<Class<? extends Annotation>, List<Context>>();
 
         return new BeanManagerImpl(
                 serviceRegistry,
                 new CopyOnWriteArrayList<Bean<?>>(),
                 new CopyOnWriteArrayList<Bean<?>>(),
                 new CopyOnWriteArrayList<Decorator<?>>(),
                 new CopyOnWriteArrayList<Interceptor<?>>(),
                 new CopyOnWriteArrayList<ObserverMethod<?>>(),
                 new CopyOnWriteArrayList<String>(),
                 new ConcurrentHashMap<EjbDescriptor<?>, SessionBean<?>>(),
                 new ClientProxyProvider(contextId),
                 contexts,
                 new CopyOnWriteArraySet<CurrentActivity>(),
                 .,
                 id,
                 new AtomicInteger(),
                 new HashSet<BeanManagerImpl>(),
                 contextId);
     }
 
     public static BeanManagerImpl newManager(BeanManagerImpl rootManagerString idServiceRegistry services) {
         return new BeanManagerImpl(
                 services,
                 new CopyOnWriteArrayList<Bean<?>>(),
                 new CopyOnWriteArrayList<Bean<?>>(),
                 new CopyOnWriteArrayList<Decorator<?>>(),
                 new CopyOnWriteArrayList<Interceptor<?>>(),
                 new CopyOnWriteArrayList<ObserverMethod<?>>(),
                 new CopyOnWriteArrayList<String>(),
                 rootManager.getEnterpriseBeans(),
                 rootManager.getClientProxyProvider(),
                 rootManager.getContexts(),
                 new CopyOnWriteArraySet<CurrentActivity>(),
                 .,
                 id,
                 new AtomicInteger(),
                 rootManager.managers,
                 rootManager.contextId);
     }

    
Create a new child manager

Parameters:
parentManager the parent manager
Returns:
new child manager
 
     public static BeanManagerImpl newChildActivityManager(BeanManagerImpl parentManager) {
         List<Bean<?>> beans = new CopyOnWriteArrayList<Bean<?>>();
         beans.addAll(parentManager.getBeans());
         List<Bean<?>> transitiveBeans = new CopyOnWriteArrayList<Bean<?>>();
         beans.addAll(parentManager.getSharedBeans());
 
         List<ObserverMethod<?>> registeredObservers = new CopyOnWriteArrayList<ObserverMethod<?>>();
         registeredObservers.addAll(parentManager.getObservers());
         List<Stringnamespaces = new CopyOnWriteArrayList<String>();
         namespaces.addAll(parentManager.getNamespaces());
 
         return new BeanManagerImpl(
                 parentManager.getServices(),
                 beans,
                 transitiveBeans,
                 parentManager.getDecorators(),
                 parentManager.getInterceptors(),
                 registeredObservers,
                 namespaces,
                 parentManager.getEnterpriseBeans(),
                 parentManager.getClientProxyProvider(),
                 parentManager.getContexts(),
                 parentManager.getCurrentActivities(),
                 parentManager.getEnabled(),
                 new StringBuilder().append(parentManager.getChildIds().incrementAndGet()).toString(),
                 parentManager.getChildIds(),
                 parentManager.managers,
                 parentManager.contextId);
     }
 
     private BeanManagerImpl(
             ServiceRegistry serviceRegistry,
             List<Bean<?>> beans,
             List<Bean<?>> transitiveBeans,
             List<Decorator<?>> decorators,
             List<Interceptor<?>> interceptors,
             List<ObserverMethod<?>> observers,
             List<Stringnamespaces,
             Map<EjbDescriptor<?>, SessionBean<?>> enterpriseBeans,
             ClientProxyProvider clientProxyProvider,
             Map<Class<? extends Annotation>, List<Context>> contexts,
             Set<CurrentActivitycurrentActivities,
             ModuleEnablement enabled,
             String id,
             AtomicInteger childIds,
             Set<BeanManagerImplmanagers,
             String contextId) {
         this. = serviceRegistry;
         this. = beans;
         this. = transitiveBeans;
         this. = decorators;
         this. = interceptors;
         this. = enterpriseBeans;
         this. = clientProxyProvider;
         this. = contexts;
         this. = currentActivities;
         this. = observers;
         this. = enabled;
         this. = namespaces;
         this. = id;
         this. = new AtomicInteger();
         this. = managers;
         this. = contextId;
 
         managers.add(this);
 
         // Set up the structure to store accessible managers in
         this. = new HashSet<BeanManagerImpl>();
 
         // TODO Currently we build the accessible bean list on the fly, we need to set it in stone once bootstrap is finished...
         Transform<Bean<?>> beanTransform = new BeanTransform(this);
         this. = new TypeSafeBeanResolver(thiscreateDynamicAccessibleIterable(beanTransform));
         this. = new NameBasedResolver(thiscreateDynamicAccessibleIterable(beanTransform));
         this. = new WeldELResolver(this);
         this. = new CopyOnWriteArraySet<BeanManagerImpl>();
 
         this. = ObserverNotifier.of(contextIdaccessibleObserverResolvergetServices(), false);
         GlobalObserverNotifierService globalObserverNotifierService = .get(GlobalObserverNotifierService.class);
         this. = globalObserverNotifierService.getGlobalLenientObserverNotifier();
         this. = globalObserverNotifierService.getGlobalStrictObserverNotifier();
         globalObserverNotifierService.registerBeanManager(this);
         this. = serviceRegistry.get(ContainerLifecycleEvents.class);
         this. = getServices().get(SpecializationAndEnablementRegistry.class);
     }
 
     private <T> Iterable<T> createDynamicGlobalIterable(final Transform<T> transform) {
         return new Iterable<T>() {
             @Override
             public Iterator<T> iterator() {
                 Set<Iterable<T>> result = new HashSet<Iterable<T>>();
                 for (BeanManagerImpl manager : ) {
                     result.add(transform.transform(manager));
                 }
                 return Iterators.concat(Iterators.transform(result.iterator(), IterableToIteratorFunction.<T>instance()));
             }
         };
     }
 
     public String getContextId() {
         return ;
     }
 
     private <T> Iterable<T> createDynamicAccessibleIterable(final Transform<T> transform) {
         return new Iterable<T>() {
 
             @Override
             public Iterator<T> iterator() {
                 Set<Iterable<T>> iterable = BeanManagers.getDirectlyAccessibleComponents(BeanManagerImpl.thistransform);
                 return Iterators.concat(Iterators.transform(iterable.iterator(), IterableToIteratorFunction.<T>instance()));
             }
 
         };
     }
 
     public void addAccessibleBeanManager(BeanManagerImpl accessibleBeanManager) {
         .add(accessibleBeanManager);
         .clear();
         .clear();
         .clear();
     }
 
         return ;
     }
 
     public void addBean(Bean<?> bean) {
         addBean(bean);
     }

    
Optimization which modifies CopyOnWrite structures only once instead of once for every bean.

Parameters:
beans
 
     public void addBeans(Collection<? extends Bean<?>> beans) {
         List<Bean<?>> beanList = new ArrayList<Bean<?>>(beans.size());
         List<Bean<?>> transitiveBeans = new ArrayList<Bean<?>>(beans.size());
         for (Bean<?> bean : beans) {
             addBean(beanbeanListtransitiveBeans);
         }
         // optimize so that we do not modify CopyOnWriteLists for each Bean
         this..addAll(beanList);
         this..addAll(transitiveBeans);
         for (BeanManagerImpl childActivity : ) {
             childActivity.addBeans(beanList);
         }
     }
 
     private void addBean(Bean<?> beanList<Bean<?>> beanListList<Bean<?>> transitiveBeans) {
         if (.add(bean)) {
             if (bean.isAlternative() && !.isEnabledInAnyBeanDeployment(bean)) {
                 ..foundDisabledAlternative(bean);
             } else if (.isSpecializedInAnyBeanDeployment(bean)) {
                 ..foundSpecializedBean(bean);
             } else if (bean instanceof AbstractProducerBean<?, ?, ?>
                     && .isSpecializedInAnyBeanDeployment(((AbstractProducerBean<?, ?, ?>) bean).getDeclaringBean())) {
                 ..foundProducerOfSpecializedBean(bean);
             } else {
                 ..foundBean(bean);
                 beanList.add(bean);
                 if (bean instanceof SessionBean) {
                     SessionBean<?> enterpriseBean = (SessionBean<?>) bean;
                     .put(enterpriseBean.getEjbDescriptor(), enterpriseBean);
                 }
                 if (bean instanceof PassivationCapable) {
                     getServices().get(ContextualStore.class).putIfAbsent(bean);
                 }
                 registerBeanNamespace(bean);
                 // New beans (except for SessionBeans) and most built in beans aren't resolvable transitively
                 if (bean instanceof ExtensionBean || bean instanceof SessionBean
                         || (!(bean instanceof NewBean) && !(bean instanceof AbstractBuiltInBean<?>))) {
                     transitiveBeans.add(bean);
                 }
             }
         }
     }
 
     public void addDecorator(Decorator<?> bean) {
         .add(bean);
         getServices().get(ContextualStore.class).putIfAbsent(bean);
         .clear();
     }
 
     @Override
     public <T> Set<ObserverMethod<? super T>> resolveObserverMethods(T eventAnnotation... bindings) {
         return .resolveObserverMethods(eventbindings);
     }
 
     public void addInterceptor(Interceptor<?> bean) {
         .add(bean);
         getServices().get(ContextualStore.class).putIfAbsent(bean);
         .clear();
     }

    
Enabled Alternatives, Interceptors and Decorators

Returns:
 
     public ModuleEnablement getEnabled() {
         return ;
     }
 
     public void setEnabled(ModuleEnablement enabled) {
         this. = enabled;
     }
 
     public boolean isBeanEnabled(Bean<?> bean) {
         return Beans.isBeanEnabled(beangetEnabled());
     }
 
     @Override
     public Set<Bean<?>> getBeans(Type beanTypeAnnotation... qualifiers) {
         Resolvable resolvable = new ResolvableBuilder(beanTypethis).addQualifiers(qualifiers).create();
         return .resolve(resolvableisCacheable(qualifiers));
     }
 
     public Set<Bean<?>> getBeans(Type beanTypeSet<Annotationqualifiers) {
         return .resolve(new ResolvableBuilder(beanTypethis).addQualifiers(qualifiers).create(), isCacheable(qualifiers));
     }
 
     public Set<Bean<?>> getBeans(InjectionPoint injectionPoint) {
         boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint);
         CurrentInjectionPoint currentInjectionPoint = null;
         if (registerInjectionPoint) {
             currentInjectionPoint = .get(CurrentInjectionPoint.class);
             currentInjectionPoint.push(injectionPoint);
         }
         try {
             // We always cache, we assume that people don't use inline annotation literal declarations, a little risky but FAQd
             return .resolve(new ResolvableBuilder(injectionPointthis).create(), true);
         } finally {
             if (registerInjectionPoint) {
                 currentInjectionPoint.pop();
             }
         }
     }
 
     protected void registerBeanNamespace(Bean<?> bean) {
         if (bean.getName() != null && bean.getName().indexOf('.') > 0) {
             .add(bean.getName().substring(0, bean.getName().lastIndexOf('.')));
         }
     }

    
Gets the class-mapped beans. For internal use.

Returns:
The bean map
 
     public Map<EjbDescriptor<?>, SessionBean<?>> getEnterpriseBeans() {
         return ;
     }

    
The beans registered with the Web Bean manager which are resolvable. Does not include interceptor and decorator beans

Returns:
The list of known beans
 
     public List<Bean<?>> getBeans() {
         return Collections.unmodifiableList();
     }
 
     List<Bean<?>> getSharedBeans() {
         return Collections.unmodifiableList();
     }
 
     public List<Decorator<?>> getDecorators() {
         return Collections.unmodifiableList();
     }
 
     public List<Interceptor<?>> getInterceptors() {
         return Collections.unmodifiableList();
     }
 
     public Iterable<Bean<?>> getAccessibleBeans() {
         return createDynamicAccessibleIterable(new BeanTransform(this));
     }
 
         return createDynamicAccessibleIterable(new InterceptorTransform());
     }
 
     public Iterable<Decorator<?>> getAccessibleDecorators() {
         return createDynamicAccessibleIterable(new DecoratorTransform());
     }
 
     public void addContext(Context context) {
         Class<? extends Annotationscope = context.getScope();
         if (isPassivatingScope(scope)) {
             context = PassivatingContextWrapper.wrap(context.get(ContextualStore.class));
         }
         List<ContextcontextList = .get(scope);
         if (contextList == null) {
             contextList = new CopyOnWriteArrayList<Context>();
             .put(scopecontextList);
         }
         contextList.add(context);
     }

    
Does the actual observer registration

Parameters:
observer =
 
     public void addObserver(ObserverMethod<?> observer) {
         //checkEventType(observer.getObservedType());
         .add(observer);
         for (BeanManagerImpl childActivity : ) {
             childActivity.addObserver(observer);
         }
     }

    
Fires an event object with given event object for given bindings

Parameters:
event The event object to pass along
qualifiers The binding types to match
See also:
javax.enterprise.inject.spi.BeanManager.fireEvent(java.lang.Object, java.lang.annotation.Annotation[])
 
     @Override
     public void fireEvent(Object eventAnnotation... qualifiers) {
         Preconditions.checkArgumentNotNull(event"event");
         Type eventType = Types.getCanonicalType(event.getClass());
         Resolvable resolvable = .buildEventResolvable(eventTypequalifiers);
         EventPacket<?> packet = EventPacket.of(eventqualifiers);
         .fireEvent(resolvablepacket);
     }

    
Gets an active context of the given scope. Throws an exception if there are no active contexts found or if there are too many matches

Parameters:
scopeType The scope to match
Returns:
A single active context of the given scope
Throws:
IllegalStateException if there are multiple active scopes for a given context
See also:
javax.enterprise.inject.spi.BeanManager.getContext(java.lang.Class)
 
     @Override
     public Context getContext(Class<? extends AnnotationscopeType) {
         Context activeContext = internalGetContext(scopeType);
         if (activeContext == null) {
             throw ..contextNotActive(scopeType.getName());
         }
         return activeContext;
     }
 
     public Context getUnwrappedContext(Class<? extends AnnotationscopeType) {
         return PassivatingContextWrapper.unwrap(getContext(scopeType));
     }

    
Indicates whether there is an active context for a given scope.

Parameters:
scopeType
Returns:
true if there is an active context for a given scope, false otherwise
Throws:
IllegalStateException if there are multiple active scopes for a given context
 
     public boolean isContextActive(Class<? extends AnnotationscopeType) {
         return internalGetContext(scopeType) != null;
     }
 
     private Context internalGetContext(Class<? extends AnnotationscopeType) {
         Context activeContext = null;
         final List<Contextctx = .get(scopeType);
         if (ctx == null) {
             return null;
         }
         for (Context context : ctx) {
             if (context.isActive()) {
                 if (activeContext == null) {
                     activeContext = context;
                 } else {
                     throw ..duplicateActiveContexts(scopeType.getName());
                 }
             }
         }
         return activeContext;
     }
 
     public Object getReference(Bean<?> beanType requestedTypeCreationalContext<?> creationalContextboolean noProxy) {
         if (creationalContext instanceof CreationalContextImpl<?>) {
             creationalContext = ((CreationalContextImpl<?>) creationalContext).getCreationalContext(bean);
         }
         if (!noProxy && isProxyRequired(bean)) {
             if (creationalContext != null || getContext(bean.getScope()).get(bean) != null) {
                 if (requestedType == null) {
                     return .getClientProxy(bean);
                 } else {
                     return .getClientProxy(beanrequestedType);
                 }
             } else {
                 return null;
             }
         } else {
             return getContext(bean.getScope()).get(Reflections.<Contextual>cast(bean), creationalContext);
         }
     }
 
     private boolean isProxyRequired(Bean<?> bean) {
         if (bean instanceof RIBean<?>) {
             return ((RIBean<?>) bean).isProxyRequired();
         } else {
             return isNormalScope(bean.getScope());
         }
     }
 
     @Override
     public Object getReference(Bean<?> beanType requestedTypeCreationalContext<?> creationalContext) {
         Preconditions.checkArgumentNotNull(bean"bean");
         Preconditions.checkArgumentNotNull(requestedType"requestedType");
         Preconditions.checkArgumentNotNull(creationalContext);
         if (!BeanTypeAssignabilityRules.instance().matches(requestedTypebean.getTypes())) {
             throw ..specifiedTypeNotBeanType(requestedTypebean);
         }
         return getReference(beanrequestedTypecreationalContextfalse);
     }

    
The name of this method was misleading, use getInjectableReference(InjectionPoint, Bean, CreationalContext) instead.

Deprecated:
Use getInjectableReference(InjectionPoint, Bean, CreationalContext) instead
Parameters:
injectionPoint
resolvedBean
creationalContext
Returns:
the injectable reference
 
     @Deprecated
     public Object getReference(InjectionPoint injectionPointBean<?> resolvedBeanCreationalContext<?> creationalContext) {
         return getInjectableReference(injectionPointresolvedBeancreationalContext);
     }

    
Get a reference, registering the injection point used.

Parameters:
injectionPoint the injection point to register
resolvedBean the bean to get a reference to
creationalContext the creationalContext
Returns:
the injectable reference
 
     public Object getInjectableReference(InjectionPoint injectionPointBean<?> resolvedBeanCreationalContext<?> creationalContext) {
         Preconditions.checkArgumentNotNull(resolvedBean"resolvedBean");
         Preconditions.checkArgumentNotNull(creationalContext);
 
         boolean registerInjectionPoint = isRegisterableInjectionPoint(injectionPoint);
         boolean delegateInjectionPoint = injectionPoint != null && injectionPoint.isDelegate();
 
         CurrentInjectionPoint currentInjectionPoint = null;
         if (registerInjectionPoint) {
             currentInjectionPoint = .get(CurrentInjectionPoint.class);
             currentInjectionPoint.push(injectionPoint);
         }
         try {
             Type requestedType = null;
             if (injectionPoint != null) {
                 requestedType = injectionPoint.getType();
             }
 
             if (injectionPoint != null && injectionPoint.getBean() != null) {
                 // For certain combinations of scopes, the container is permitted to optimize an injectable reference lookup
                 // This should also partially solve circular @PostConstruct invocation
                 CreationalContextImpl<?> weldCreationalContext = null;
                 Bean<?> bean = injectionPoint.getBean();
 
                 // Do not optimize for self injection
                 if(!bean.equals(resolvedBean)) {
 
                     if (creationalContext instanceof CreationalContextImpl) {
                         weldCreationalContext = (CreationalContextImpl<?>) creationalContext;
                     }
 
                     if (weldCreationalContext != null && Dependent.class.equals(bean.getScope()) && isNormalScope(resolvedBean.getScope())) {
                         bean = findNormalScopedDependant(weldCreationalContext);
                     }
 
                     if (InjectionPoints.isInjectableReferenceLookupOptimizationAllowed(beanresolvedBean)) {
                         if (weldCreationalContext != null) {
                             final Object incompleteInstance = weldCreationalContext.getIncompleteInstance(resolvedBean);
                             if (incompleteInstance != null) {
                                 return incompleteInstance;
                             }
                         }
                         Context context = internalGetContext(resolvedBean.getScope());
                         if(context != null) {
                             @java.lang.SuppressWarnings({ "unchecked""rawtypes" })
                             final Object existinInstance = context.get(Reflections.<Contextual>cast(resolvedBean));
                             if(existinInstance != null) {
                                 return existinInstance;
                             }
                         }
                     }
                 }
             }
             return getReference(resolvedBeanrequestedTypecreationalContextdelegateInjectionPoint);
 
         } finally {
             if (registerInjectionPoint) {
                 currentInjectionPoint.pop();
             }
         }
     }
 
     @Override
     public Object getInjectableReference(InjectionPoint injectionPointCreationalContext<?> creationalContext) {
         if (injectionPoint.isDelegate()) {
             return DecorationHelper.peek().getNextDelegate(injectionPointcreationalContext);
         } else {
             Bean<?> resolvedBean = getBean(new ResolvableBuilder(injectionPointthis).create());
             return getInjectableReference(injectionPointresolvedBeancreationalContext);
         }
     }
 
     public <T> Bean<T> getBean(Resolvable resolvable) {
         // We can always cache as this is only ever called by Weld where we avoid non-static inner classes for annotation literals
         Bean<T> bean = cast(resolve(.resolve(resolvabletrue)));
         if (bean == null) {
             throw ..unresolvableElement(resolvable);
         }
 
         if (isNormalScope(bean.getScope()) && !Beans.isBeanProxyable(beanthis)) {
             throw Proxies.getUnproxyableTypesException(bean);
         }
         return bean;
     }
 
     @Override
     public Set<Bean<?>> getBeans(String name) {
         return .resolve(name);
     }
 
     @Override
     public List<Decorator<?>> resolveDecorators(Set<TypetypesAnnotation... qualifiers) {
         checkResolveDecoratorsArguments(types);
         return .resolve(new DecoratorResolvableBuilder(this).addTypes(types).addQualifiers(qualifiers).create(), isCacheable(qualifiers));
     }
 
     public List<Decorator<?>> resolveDecorators(Set<TypetypesSet<Annotationqualifiers) {
         checkResolveDecoratorsArguments(types);
         return .resolve(new DecoratorResolvableBuilder(this).addTypes(types).addQualifiers(qualifiers).create(), true);
     }
 
     private void checkResolveDecoratorsArguments(Set<Typetypes) {
         if (types.isEmpty()) {
             throw ..noDecoratorTypes();
         }
     }

    
Resolves a list of interceptors based on interception type and interceptor bindings. Transitive interceptor bindings of the interceptor bindings passed as a parameter are considered in the resolution process.

Parameters:
type The interception type to resolve
interceptorBindings The binding types to match
Returns:
A list of matching interceptors
See also:
javax.enterprise.inject.spi.BeanManager.resolveInterceptors(javax.enterprise.inject.spi.InterceptionType, java.lang.annotation.Annotation[])
 
     @Override
     public List<Interceptor<?>> resolveInterceptors(InterceptionType typeAnnotation... interceptorBindings) {
         if (interceptorBindings.length == 0) {
             throw ..interceptorBindingsEmpty();
         }
         for (Annotation annotation : interceptorBindings) {
             if (!isInterceptorBinding(annotation.annotationType())) {
                throw ..notInterceptorBindingType(annotation);
             }
         }
         Set<AnnotationflattenedInterceptorBindings = Interceptors.flattenInterceptorBindings(this, Arrays.asList(interceptorBindings), truetrue);
         return resolveInterceptors(typeflattenedInterceptorBindings);
     }

    
Resolves a list of interceptors based on interception type and interceptor bindings. Transitive interceptor bindings of the interceptor bindings passed as a parameter are NOT considered in the resolution process. Therefore, the caller is responsible for filtering of transitive interceptor bindings in order to comply with interceptor binding inheritance and overriding (See JSR-346 9.5.2). This is a Weld-specific method.

Parameters:
type The interception type to resolve
interceptorBindings The binding types to match
Returns:
A list of matching interceptors
 
     public List<Interceptor<?>> resolveInterceptors(InterceptionType typeCollection<AnnotationinterceptorBindings) {
         // We can always cache as this is only ever called by Weld where we avoid non-static inner classes for annotation literals
         InterceptorResolvable interceptorResolvable = new InterceptorResolvableBuilder(Object.classthis)
         .setInterceptionType(type)
         .addQualifiers(interceptorBindings)
         .create();
         return .resolve(interceptorResolvableisCacheable(interceptorBindings));
     }

    
Get the web bean resolver. For internal use

Returns:
The resolver
 
         return ;
     }

    
Get the decorator resolver. For internal use

Returns:
The resolver
 
         return ;
     }
 
         return ;
     }
 
         return ;
     }

    
Get the lenient observer notifier for accessible observer methods. Should never be exposed to an application.

Returns:
The ObserverNotifier
 
         return ;
     }

    
Get the lenient global observer notifier. Should never be exposed to an application.

Returns:
The ObserverNotifier
 
         return ;
     }

    
Get the Strict global observer notifier. This one should be used for firing application / extension events.

Returns:
The ObserverNotifier
 
         return ;
     }

    
Gets a string representation

Returns:
A string representation
 
     @Override
     public String toString() {
        return "Weld BeanManager for " + getId() + " [bean count=" + getBeans().size() + "]";
    }
    @Override
    @SuppressWarnings("EQ_CHECK_FOR_OPERAND_NOT_COMPATIBLE_WITH_THIS")
    public boolean equals(Object obj) {
        if (obj instanceof ForwardingBeanManager) {
            ForwardingBeanManager proxy = (ForwardingBeanManagerobj;
            obj = proxy.delegate();
        }
        if (obj instanceof BeanManagerImpl) {
            BeanManagerImpl that = (BeanManagerImplobj;
            return this.getId().equals(that.getId());
        } else {
            return false;
        }
    }
    @Override
    public int hashCode() {
        return getId().hashCode();
    }
    @Override
    public BeanManagerImpl createActivity() {
        BeanManagerImpl childActivity = newChildActivityManager(this);
        .add(childActivity);
        Container.instance().addActivity(childActivity);
        return childActivity;
    }
    @Override
    public BeanManagerImpl setCurrent(Class<? extends AnnotationscopeType) {
        if (!isNormalScope(scopeType)) {
            throw new IllegalArgumentException(..nonNormalScope(scopeType));
        }
        .add(new CurrentActivity(getContext(scopeType), this));
        return this;
    }
    @Override
    public BeanManagerImpl getCurrent() {
        CurrentActivity activeCurrentActivity = null;
        for (CurrentActivity currentActivity : ) {
            if (currentActivity.getContext().isActive()) {
                if (activeCurrentActivity == null) {
                    activeCurrentActivity = currentActivity;
                }
                else {
                    throw ..tooManyActivities(WeldCollections.toMultiRowString());
                }
            }
        }
        if (activeCurrentActivity == null) {
            return this;
        } else {
            return activeCurrentActivity.getManager();
        }
    }
    @Override
    public ServiceRegistry getServices() {
        return ;
    }
    // Serialization
    protected Object readResolve() throws ObjectStreamException {
        return Container.instance().activityManager();
    }
        return ;
    }
    protected Map<Class<? extends Annotation>, List<Context>> getContexts() {
        return ;
    }

    

Returns:
the namespaces
    protected List<StringgetNamespaces() {
        return ;
    }
        // TODO Cache this
    }