Search in sources :

Example 1 with ConversationKey

use of org.apache.deltaspike.core.impl.scope.conversation.ConversationKey in project deltaspike by apache.

the class ConversationUtils method convertToConversationKey.

public static ConversationKey convertToConversationKey(Contextual<?> contextual, BeanManager beanManager) {
    if (!(contextual instanceof Bean)) {
        if (contextual instanceof PassivationCapable) {
            contextual = beanManager.getPassivationCapableBean(((PassivationCapable) contextual).getId());
        } else {
            throw new IllegalArgumentException(contextual.getClass().getName() + " is not of type " + Bean.class.getName());
        }
    }
    Bean<?> bean = (Bean<?>) contextual;
    //don't cache it (due to the support of different producers)
    ConversationGroup conversationGroupAnnotation = findConversationGroupAnnotation(bean);
    Class<?> conversationGroup;
    if (conversationGroupAnnotation != null) {
        conversationGroup = conversationGroupAnnotation.value();
    } else {
        conversationGroup = bean.getBeanClass();
    }
    Set<Annotation> qualifiers = bean.getQualifiers();
    return new ConversationKey(conversationGroup, qualifiers.toArray(new Annotation[qualifiers.size()]));
}
Also used : PassivationCapable(javax.enterprise.inject.spi.PassivationCapable) ConversationGroup(org.apache.deltaspike.core.api.scope.ConversationGroup) ConversationKey(org.apache.deltaspike.core.impl.scope.conversation.ConversationKey) Annotation(java.lang.annotation.Annotation) Bean(javax.enterprise.inject.spi.Bean)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Bean (javax.enterprise.inject.spi.Bean)1 PassivationCapable (javax.enterprise.inject.spi.PassivationCapable)1 ConversationGroup (org.apache.deltaspike.core.api.scope.ConversationGroup)1 ConversationKey (org.apache.deltaspike.core.impl.scope.conversation.ConversationKey)1