public static Class convertToScope()

in jee-modules/jsf-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/jsf/impl/util/ConversationUtils.java [577:624]


    public static Class<? extends Annotation> convertToScope(
            BeanManager beanManager, Class conversationGroupKey, Annotation... qualifiers)
    {
        Class<? extends Annotation> scopeType = conversationGroupToScopeCache.get(conversationGroupKey);

        if(scopeType != null)
        {
            return scopeType;
        }

        if (WindowScoped.class.isAssignableFrom(conversationGroupKey))
        {
            scopeType = WindowScoped.class;
        }
        else
        {
            //we just find a bean if the class name is used as implicit group-key
            //explicit group-keys are only supported for @ConversationScoped
            Set<Bean<?>> beans = beanManager.getBeans(conversationGroupKey, qualifiers);

            if(beans.size() == 1)
            {
                scopeType = beans.iterator().next().getScope();
            }
            else
            {
                if(!beanManager.getClass().getName().startsWith("org.apache.webbeans."))
                {
                    //workaround for weld v1.1.1
                    Bean<?> bean = WeldCache.getBean();
                    if(bean != null)
                    {
                        scopeType = bean.getScope();
                    }
                }

                //default behaviour for cdi implementations without bug
                if(scopeType == null)
                {
                    scopeType = ConversationScoped.class;
                }
            }
        }

        conversationGroupToScopeCache.put(conversationGroupKey, scopeType);

        return scopeType;
    }