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.util;
 
 import static org.jboss.weld.util.collections.WeldCollections.immutableSet;
 import static org.jboss.weld.util.reflection.Reflections.cast;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
Helper class for bean inspection

Author(s):
Pete Muir
David Allen
Marius Bogoevici
Ales Justin
Jozef Hartinger
public class Beans {
    private Beans() {
    }

    
Indicates if a bean's scope type is passivating

Parameters:
bean The bean to inspect
Returns:
True if the scope is passivating, false otherwise
    public static boolean isPassivatingScope(Bean<?> beanBeanManagerImpl manager) {
        if (bean == null) {
            return false;
        } else {
            return manager.getServices().get(MetaAnnotationStore.class).getScopeModel(bean.getScope()).isPassivating();
        }
    }

    
Tests if a bean is capable of having its state temporarily stored to secondary storage

Parameters:
bean The bean to inspect
Returns:
True if the bean is passivation capable
    public static boolean isPassivationCapableBean(Bean<?> bean) {
        if (bean instanceof RIBean<?>) {
            return ((RIBean<?>) bean).isPassivationCapableBean();
        } else {
            return bean instanceof PassivationCapable;
        }
    }

    
Tests if a bean is capable of having its state temporarily stored to secondary storage

Parameters:
bean The bean to inspect
Returns:
True if the bean is passivation capable
    public static boolean isPassivationCapableDependency(Bean<?> bean) {
        if (bean instanceof RIBean<?>) {
            return ((RIBean<?>) bean).isPassivationCapableDependency();
        }
        return bean instanceof PassivationCapable;
    }

    
Indicates if a bean is proxyable

Parameters:
bean The bean to test
Returns:
True if proxyable, false otherwise
    public static boolean isBeanProxyable(Bean<?> beanBeanManagerImpl manager) {
        if (bean instanceof RIBean<?>) {
            return ((RIBean<?>) bean).isProxyable();
        } else {
            return Proxies.isTypesProxyable(bean.getTypes(), manager.getServices());
        }
    }
    public static List<AnnotatedMethod<?>> getInterceptableMethods(AnnotatedType<?> type) {
        List<AnnotatedMethod<?>> annotatedMethods = new ArrayList<AnnotatedMethod<?>>();
        for (AnnotatedMethod<?> annotatedMethod : type.getMethods()) {
            boolean businessMethod = !annotatedMethod.isStatic() && !annotatedMethod.isAnnotationPresent(Inject.class)
                    && !annotatedMethod.getJavaMember().isBridge();
            if (businessMethod && !isInterceptorMethod(annotatedMethod)) {
                annotatedMethods.add(annotatedMethod);
            }
        }
        return annotatedMethods;
    }
    private static boolean isInterceptorMethod(AnnotatedMethod<?> annotatedMethod) {
        for (InterceptionType interceptionType : InterceptionTypeRegistry.getSupportedInterceptionTypes()) {
            if (annotatedMethod.isAnnotationPresent(InterceptionTypeRegistry.getAnnotationClass(interceptionType))) {
                return true;
            }
        }
        return false;
    }

    
Checks that all the qualifiers in the set requiredQualifiers are in the set of qualifiers. Qualifier equality rules for annotation members are followed.

Parameters:
requiredQualifiers The required qualifiers
qualifiers The set of qualifiers to check
Returns:
True if all matches, false otherwise
    public static boolean containsAllQualifiers(Set<QualifierInstancerequiredQualifiersSet<QualifierInstancequalifiers) {
        return qualifiers.containsAll(requiredQualifiers);
    }
    public static boolean containsAllInterceptionBindings(Set<AnnotationexpectedBindings,
            Set<QualifierInstanceexistingBindingsBeanManagerImpl manager) {
        final Set<QualifierInstanceexpected = manager.extractInterceptorBindingsForQualifierInstance(QualifierInstance.of(expectedBindingsmanager.getServices().get(MetaAnnotationStore.class)));
        return manager.extractInterceptorBindingsForQualifierInstance(existingBindings).containsAll(expected);
    }
    public static boolean findInterceptorBindingConflicts(BeanManagerImpl managerSet<Annotationbindings) {
        Map<Class<? extends Annotation>, AnnotationfoundAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
        for (Annotation binding : bindings) {
            if (foundAnnotations.containsKey(binding.annotationType())) {
                InterceptorBindingModel<?> bindingType = manager.getServices().get(MetaAnnotationStore.class)
                        .getInterceptorBindingModel(binding.annotationType());
                if (!bindingType.isEqual(bindingfoundAnnotations.get(binding.annotationType()), false)) {
                    return true;
                }
            } else {
                foundAnnotations.put(binding.annotationType(), binding);
            }
        }
        return false;
    }

    
Retains only beans which are enabled.

Parameters:
beans The beans to filter
beanManager The bean manager
registry
Returns:
An immutable set of enabled beans
    public static <T extends Bean<?>> Set<T> removeDisabledBeans(Set<T> beansfinal BeanManagerImpl beanManager,
            final SpecializationAndEnablementRegistry registry) {
        if (beans.size() == 0) {
            return beans;
        } else {
            ImmutableSet.Builder<T> builder = ImmutableSet.builder();
            for (T bean : beans) {
                if (isBeanEnabled(beanbeanManager.getEnabled())) {
                    builder.add(bean);
                }
            }
            return builder.build();
        }
    }
    public static boolean isBeanEnabled(Bean<?> beanModuleEnablement enabled) {
        if (bean.isAlternative()) {
            if (enabled.isEnabledAlternativeClass(bean.getBeanClass())) {
                return true;
            } else {
                for (Class<? extends Annotationstereotype : bean.getStereotypes()) {
                    if (enabled.isEnabledAlternativeStereotype(stereotype)) {
                        return true;
                    }
                }
                return false;
            }
        } else if (bean instanceof AbstractProducerBean<?, ?, ?>) {
            AbstractProducerBean<?, ?, ?> receiverBean = (AbstractProducerBean<?, ?, ?>) bean;
            return isBeanEnabled(receiverBean.getDeclaringBean(), enabled);
        } else if (bean instanceof DecoratorImpl<?>) {
            return enabled.isDecoratorEnabled(bean.getBeanClass());
        } else if (bean instanceof InterceptorImpl<?>) {
            return enabled.isInterceptorEnabled(bean.getBeanClass());
        } else {
            return true;
        }
    }

    
Check if any of the beans is an alternative

Parameters:
beans the beans to check
Returns:
true if any bean is an alternative
    public static boolean isAlternativePresent(Set<Bean<?>> beans) {
        for (Bean<?> bean : beans) {
            if (bean.isAlternative()) {
                return true;
            }
        }
        return false;
    }

    
Is alternative.

Parameters:
annotated the annotated
mergedStereotypes merged stereotypes
Returns:
true if alternative, false otherwise
    public static boolean isAlternative(EnhancedAnnotated<?, ?> annotatedMergedStereotypes<?, ?> mergedStereotypes) {
        return annotated.isAnnotationPresent(Alternative.class) || mergedStereotypes.isAlternative();
    }
        EnhancedAnnotatedConstructor<T> constructor = getBeanConstructor(type);
        if (constructor == null) {
            throw ..unableToFindConstructor(type);
        }
        return constructor;
    }
    public static <T> EnhancedAnnotatedConstructor<T> getBeanConstructor(EnhancedAnnotatedType<T> type) {
        Collection<EnhancedAnnotatedConstructor<T>> initializerAnnotatedConstructors = type
                .getEnhancedConstructors(Inject.class);
        ..foundInjectableConstructors(initializerAnnotatedConstructorstype);
        EnhancedAnnotatedConstructor<T> constructor = null;
        if (initializerAnnotatedConstructors.size() > 1) {
            throw ..ambiguousConstructor(typeinitializerAnnotatedConstructors);
        } else if (initializerAnnotatedConstructors.size() == 1) {
            constructor = initializerAnnotatedConstructors.iterator().next();
            ..foundOneInjectableConstructor(constructortype);
        } else if (type.getNoArgsEnhancedConstructor() != null) {
            constructor = type.getNoArgsEnhancedConstructor();
            ..foundDefaultConstructor(constructortype);
        }
        if (constructor != null) {
            if (!constructor.getEnhancedParameters(Disposes.class).isEmpty()) {
                throw ..parameterAnnotationNotAllowedOnConstructor("@Disposes"constructor);
            }
            if (!constructor.getEnhancedParameters(Observes.class).isEmpty()) {
                throw ..parameterAnnotationNotAllowedOnConstructor("@Observes"constructor);
            }
        }
        return constructor;
    }

    
Injects EJBs and other EE resources.

Parameters:
resourceInjectionsHierarchy
beanInstance
ctx
    public static <T> void injectEEFields(Iterable<Set<ResourceInjection<?>>> resourceInjectionsHierarchy,
            T beanInstanceCreationalContext<T> ctx) {
        for (Set<ResourceInjection<?>> resourceInjections : resourceInjectionsHierarchy) {
            for (ResourceInjection<?> resourceInjection : resourceInjections) {
                resourceInjection.injectResourceReference(beanInstancectx);
            }
        }
    }

    
Gets the declared bean type

Returns:
The bean type
    public static Type getDeclaredBeanType(Class<?> clazz) {
        Type[] actualTypeArguments = Reflections.getActualTypeArguments(clazz);
        if (actualTypeArguments.length == 1) {
            return actualTypeArguments[0];
        } else {
            return null;
        }
    }

    
Injects bound fields

Parameters:
instance The instance to inject into
    public static <T> void injectBoundFields(T instanceCreationalContext<T> creationalContextBeanManagerImpl manager,
            Iterable<? extends FieldInjectionPoint<?, ?>> injectableFields) {
        for (FieldInjectionPoint<?, ?> injectableField : injectableFields) {
            injectableField.inject(instancemanagercreationalContext);
        }
    }
    public static <T> void injectFieldsAndInitializers(T instanceCreationalContext<T> ctxBeanManagerImpl beanManager,
            List<? extends Iterable<? extends FieldInjectionPoint<?, ?>>> injectableFields,
            List<? extends Iterable<? extends MethodInjectionPoint<?, ?>>> initializerMethods) {
        if (injectableFields.size() != initializerMethods.size()) {
            throw ..invalidQuantityInjectableFieldsAndInitializerMethods(injectableFieldsinitializerMethods);
        }
        for (int i = 0; i < injectableFields.size(); i++) {
            injectBoundFields(instancectxbeanManagerinjectableFields.get(i));
            callInitializers(instancectxbeanManagerinitializerMethods.get(i));
        }
    }

    
Calls all initializers of the bean

Parameters:
instance The bean instance
    public static <T> void callInitializers(T instanceCreationalContext<T> creationalContextBeanManagerImpl manager,
            Iterable<? extends MethodInjectionPoint<?, ?>> initializerMethods) {
        for (MethodInjectionPoint<?, ?> initializer : initializerMethods) {
            initializer.invoke(instancenullmanagercreationalContextCreationException.class);
        }
    }
    public static <T> boolean isInterceptor(AnnotatedType<T> annotatedItem) {
        return annotatedItem.isAnnotationPresent(javax.interceptor.Interceptor.class);
    }
    public static <T> boolean isDecorator(EnhancedAnnotatedType<T> annotatedItem) {
        return annotatedItem.isAnnotationPresent(Decorator.class);
    }
    public static Set<AnnotationmergeInQualifiers(BeanManagerImpl managerCollection<AnnotationqualifiersAnnotation[] newQualifiers) {
        Set<Annotationresult = new HashSet<Annotation>();
        if (qualifiers != null && !(qualifiers.isEmpty())) {
            result.addAll(qualifiers);
        }
        if (newQualifiers != null && newQualifiers.length > 0) {
            final MetaAnnotationStore store = manager.getServices().get(MetaAnnotationStore.class);
            Set<AnnotationcheckedNewQualifiers = new HashSet<Annotation>();
            for (Annotation qualifier : newQualifiers) {
                if (!store.getBindingTypeModel(qualifier.annotationType()).isValid()) {
                    throw ..annotationNotQualifier(qualifier);
                }
                final Class<? extends AnnotationannotationType = qualifier.annotationType();
                for (Annotation annotation : checkedNewQualifiers) {
                    if(annotationType.equals(annotation.annotationType())) {
                        throw ..redundantQualifier(qualifier, Arrays.toString(newQualifiers));
                    }
                }
                checkedNewQualifiers.add(qualifier);
            }
            result.addAll(checkedNewQualifiers);
        }
        return result;
    }

    
Illegal bean types are ignored except fo array and primitive types and unless javax.enterprise.inject.Typed is used.

Returns:
the set of bean types from an annotated element
    public static Set<TypegetTypes(EnhancedAnnotated<?, ?> annotated) {
        // array and primitive types require special treatment
        if (annotated.getJavaClass().isArray() || annotated.getJavaClass().isPrimitive()) {
            return new ArraySet<Type>(annotated.getBaseType(), Object.class);
        } else {
            if (annotated.isAnnotationPresent(Typed.class)) {
                return new ArraySet<Type>(getTypedTypes(Reflections.buildTypeMap(annotated.getTypeClosure()),
                        annotated.getJavaClass(), annotated.getAnnotation(Typed.class)));
            } else {
                if (annotated.getJavaClass().isInterface()) {
                    return getLegalBeanTypes(annotated.getTypeClosure(), annotatedObject.class);
                }
                return getLegalBeanTypes(annotated.getTypeClosure(), annotated);
            }
        }
    }

    
Bean types of a session bean.
    public static <T> Set<TypegetTypes(EnhancedAnnotated<T, ?> annotatedEjbDescriptor<T> ejbDescriptor) {
        ArraySet<Typetypes = new ArraySet<Type>();
        // session beans
        Map<Class<?>, TypetypeMap = new LinkedHashMap<Class<?>, Type>();
        HierarchyDiscovery beanClassDiscovery = HierarchyDiscovery.forNormalizedType(ejbDescriptor.getBeanClass());
        for (BusinessInterfaceDescriptor<?> businessInterfaceDescriptor : ejbDescriptor.getLocalBusinessInterfaces()) {
            // first we need to resolve the local interface
            Type resolvedLocalInterface = beanClassDiscovery.resolveType(Types.getCanonicalType(businessInterfaceDescriptor.getInterface()));
            SessionBeanHierarchyDiscovery interfaceDiscovery = new SessionBeanHierarchyDiscovery(resolvedLocalInterface);
            if (beanClassDiscovery.getTypeMap().containsKey(businessInterfaceDescriptor.getInterface())) {
                // WELD-1675 Only add types also included in Annotated.getTypeClosure()
                for (Entry<Class<?>, Typeentry : interfaceDiscovery.getTypeMap().entrySet()) {
                    if (annotated.getTypeClosure().contains(entry.getValue())) {
                        typeMap.put(entry.getKey(), entry.getValue());
                    }
                }
            } else {
                // Session bean class does not implement the business interface and @javax.ejb.Local applied to the session bean class
                typeMap.putAll(interfaceDiscovery.getTypeMap());
            }
        }
        if (annotated.isAnnotationPresent(Typed.class)) {
            types.addAll(getTypedTypes(typeMapannotated.getJavaClass(), annotated.getAnnotation(Typed.class)));
        } else {
            typeMap.put(Object.classObject.class);
            types.addAll(typeMap.values());
        }
        return immutableSet(types);
    }

    
Bean types of a bean that uses the javax.enterprise.inject.Typed annotation.
    public static Set<TypegetTypedTypes(Map<Class<?>, TypetypeClosureClass<?> rawTypeTyped typed) {
        Set<Typetypes = new HashSet<Type>();
        for (Class<?> specifiedClass : typed.value()) {
            Type tmp = typeClosure.get(specifiedClass);
            if (tmp != null) {
                types.add(tmp);
            } else {
                throw ..typedClassNotInHierarchy(specifiedClass.getName(), rawType);
            }
        }
        types.add(Object.class);
        return types;
    }

    
Indicates if the type is a simple Web Bean

Parameters:
clazz The type to inspect
Returns:
True if simple Web Bean, false otherwise
    public static boolean isTypeManagedBeanOrDecoratorOrInterceptor(AnnotatedType<?> annotatedType) {
        Class<?> javaClass = annotatedType.getJavaClass();
        return !javaClass.isEnum() && !Extension.class.isAssignableFrom(javaClass)
                && Reflections.isTopLevelOrStaticNestedClass(javaClass) && !Reflections.isParameterizedTypeWithWildcard(javaClass)
                && hasSimpleCdiConstructor(annotatedType);
    }
    public static boolean isTypeManagedBeanOrDecoratorOrInterceptor(ClassFileInfo classFileInfo) {
        return ((classFileInfo.getModifiers() & .) == 0) && !classFileInfo.isAssignableTo(Extension.class)
                /*
                 * TODO:
                 * We currently cannot reliably tell if a class is a non-static inner class or not. Therefore, this method
                 * currently returns true even for non-static inner classes. This does not matter as a reflection check is performed
                 * later before a Bean instance is created.
                 */
                // && (classFileInfo.isTopLevelClass() || Modifier.isStatic(classFileInfo.getModifiers()))
                && classFileInfo.hasCdiConstructor()
                && (!Modifier.isAbstract(classFileInfo.getModifiers()) || classFileInfo.isAnnotationDeclared(Decorator.class));
    }
    public static boolean hasSimpleCdiConstructor(AnnotatedType<?> type) {
        for (AnnotatedConstructor<?> constructor : type.getConstructors()) {
            if (constructor.getParameters().isEmpty()) {
                return true;
            }
            if (constructor.isAnnotationPresent(Inject.class)) {
                return true;
            }
        }
        return false;
    }

    
Determines if this Java class should be vetoed as a result of presence of Veto annotations.
    public static boolean isVetoed(Class<?> javaClass) {
        if (javaClass.isAnnotationPresent(Vetoed.class)) {
            return true;
        }
        return isPackageVetoed(javaClass.getPackage());
    }
    public static boolean isVetoed(AnnotatedType<?> type) {
        if (type.isAnnotationPresent(Vetoed.class)) {
            return true;
        }
        return isPackageVetoed(type.getJavaClass().getPackage());
    }
    private static boolean isPackageVetoed(Package pkg) {
        return pkg != null && pkg.isAnnotationPresent(Vetoed.class);
    }

    
Generates a unique signature for javax.enterprise.inject.spi.BeanAttributes.
    public static String createBeanAttributesId(BeanAttributes<?> attributes) {
        StringBuilder builder = new StringBuilder();
        builder.append(attributes.getName());
        builder.append(",");
        builder.append(attributes.getScope().getName());
        builder.append(",");
        builder.append(attributes.isAlternative());
        builder.append(AnnotatedTypes.createAnnotationCollectionId(attributes.getQualifiers()));
        builder.append(createTypeCollectionId(attributes.getStereotypes()));
        builder.append(createTypeCollectionId(attributes.getTypes()));
        return builder.toString();
    }

    
Generates a unique signature of a collection of types.
    public static String createTypeCollectionId(Collection<? extends Typetypes) {
        StringBuilder builder = new StringBuilder();
        List<? extends TypesortedTypes = new ArrayList<Type>(types);
        Collections.sort(sortedTypes.);
        builder.append("[");
        for (Iterator<? extends Typeiterator = sortedTypes.iterator(); iterator.hasNext();) {
            builder.append(createTypeId(iterator.next()));
            if (iterator.hasNext()) {
                builder.append(",");
            }
        }
        builder.append("]");
        return builder.toString();
    }

    
Creates a unique signature for a java.lang.reflect.Type.
    private static String createTypeId(Type type) {
        if (type instanceof Class<?>) {
            return Reflections.<Class<?>> cast(type).getName();
        }
        if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedTypetype;
            StringBuilder builder = new StringBuilder();
            builder.append(createTypeId(parameterizedType.getRawType()));
            builder.append("<");
            for (int i = 0; i < parameterizedType.getActualTypeArguments().lengthi++) {
                builder.append(createTypeId(parameterizedType.getActualTypeArguments()[i]));
                if (i != parameterizedType.getActualTypeArguments().length - 1) {
                    builder.append(",");
                }
            }
            builder.append(">");
            return builder.toString();
        }
        if (type instanceof TypeVariable<?>) {
            return Reflections.<TypeVariable<?>> cast(type).getName();
        }
        if (type instanceof GenericArrayType) {
            return createTypeId(Reflections.<GenericArrayTypecast(type).getGenericComponentType());
        }
        throw new java.lang.IllegalArgumentException("Unknown type " + type);
    }
    private static class TypeComparator implements Comparator<Type>, Serializable {
        private static final long serialVersionUID = -2162735176891985078L;
        private static final TypeComparator INSTANCE = new TypeComparator();
        @Override
        public int compare(Type o1Type o2) {
            return createTypeId(o1).compareTo(createTypeId(o2));
        }
    }
    public static <T, S, X extends EnhancedAnnotated<T, S>> X checkEnhancedAnnotatedAvailable(X enhancedAnnotated) {
        if (enhancedAnnotated == null) {
            throw new IllegalStateException("Enhanced metadata should not be used at runtime.");
        }
        return enhancedAnnotated;
    }
    public static boolean hasBuiltinScope(Bean<?> bean) {
        return RequestScoped.class.equals(bean.getScope()) || SessionScoped.class.equals(bean.getScope()) || ApplicationScoped.class.equals(bean.getScope())
                || ConversationScoped.class.equals(bean.getScope()) || Dependent.class.equals(bean.getScope());
    }

    
Returns org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType for the EJB implementation class. Throws java.lang.IllegalStateException if called after bootstrap.

Parameters:
bean
Returns:
org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType representation of this EJB's implementation class
Throws:
java.lang.IllegalStateException if called after bootstrap
    public static <T> EnhancedAnnotatedType<T> getEjbImplementationClass(SessionBean<T> bean) {
        return getEjbImplementationClass(bean.getEjbDescriptor(), bean.getBeanManager(), bean.getEnhancedAnnotated());
    }
    public static <T> EnhancedAnnotatedType<T> getEjbImplementationClass(InternalEjbDescriptor<T> ejbDescriptorBeanManagerImpl managerEnhancedAnnotatedType<T> componentType) {
        if (ejbDescriptor.getBeanClass().equals(ejbDescriptor.getImplementationClass())) {
            // no special implementation class is used
            return componentType;
        }
        ClassTransformer transformer = manager.getServices().get(ClassTransformer.class);
        EnhancedAnnotatedType<T> implementationClass = cast(transformer.getEnhancedAnnotatedType(ejbDescriptor.getImplementationClass(), manager.getId()));
        manager.getServices().get(SlimAnnotatedTypeStore.class).put(implementationClass.slim());
        return implementationClass;
    }

    

Parameters:
types The initial set of types
annotated
additionalTypes Types to add to the initial set
Returns:
the set of legal bean types
    static Set<TypegetLegalBeanTypes(Set<TypetypesEnhancedAnnotated<?, ?> annotatedType... additionalTypes) {
        if (additionalTypes != null && additionalTypes.length > 0) {
            // Micro-optimization is not possible
            return omitIllegalBeanTypes(typesannotated).add(additionalTypes).build();
        }
        for (Type type : types) {
            if (Types.isIllegalBeanType(type)) {
                return omitIllegalBeanTypes(typesannotated).build();
            }
        }
        return types;
    }
    static ImmutableSet.Builder<TypeomitIllegalBeanTypes(Set<TypetypesEnhancedAnnotated<?, ?> annotated) {
        ImmutableSet.Builder<Typebuilder = ImmutableSet.builder();
        for (Type type : types) {
            if (Types.isIllegalBeanType(type)) {
                ..illegalBeanTypeIgnored(typeannotated);
            } else {
                builder.add(type);
            }
        }
        return builder;
    }

    
    public static BeanIdentifier getIdentifier(Contextual<?> contextualContextualStore contextualStore) {
        return getIdentifier(contextualcontextualStorenull);
    }

    
    public static BeanIdentifier getIdentifier(Contextual<?> contextualServiceRegistry serviceRegistry) {
        return getIdentifier(contextualnullserviceRegistry);
    }

    
A slightly optimized way to get the bean identifier - there is not need to call ContextualStore.putIfAbsent() for passivation capable beans because it's already called during bootstrap. See also org.jboss.weld.manager.BeanManagerImpl.addBean(javax.enterprise.inject.spi.Bean).

Parameters:
contextual
contextualStore
serviceRegistry
Returns:
the identifier for the given contextual
    private static BeanIdentifier getIdentifier(Contextual<?> contextualContextualStore contextualStoreServiceRegistry serviceRegistry) {
        if (contextual instanceof RIBean<?>) {
            return ((RIBean<?>) contextual).getIdentifier();
        }
        if (contextualStore == null) {
            contextualStore = serviceRegistry.get(ContextualStore.class);
        }
        return contextualStore.putIfAbsent(contextual);
    }
New to GrepCode? Check out our FAQ X