use of javax.enterprise.inject.spi.PassivationCapable in project deltaspike by apache.
the class ViewAccessContext method get.
@Override
public <T> T get(Contextual<T> bean) {
try {
return super.get(bean);
} finally {
if (bean instanceof PassivationCapable) {
PassivationCapable pc = (PassivationCapable) bean;
viewAccessBeanAccessHistory.getAccessedBeans().add(pc.getId());
}
}
}
use of javax.enterprise.inject.spi.PassivationCapable 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()]));
}
use of javax.enterprise.inject.spi.PassivationCapable in project deltaspike by apache.
the class DeltaSpikeProxyContextualLifecycle method instantiateDelegateInvocationHandler.
protected H instantiateDelegateInvocationHandler() {
Set<Bean<H>> handlerBeans = BeanProvider.getBeanDefinitions(this.delegateInvocationHandlerClass, false, true);
if (handlerBeans.size() != 1) {
StringBuilder beanInfo = new StringBuilder();
for (Bean<H> bean : handlerBeans) {
if (beanInfo.length() != 0) {
beanInfo.append(", ");
}
beanInfo.append(bean);
if (bean instanceof PassivationCapable) {
beanInfo.append(" bean-id: ").append(((PassivationCapable) bean).getId());
}
}
throw new IllegalStateException(handlerBeans.size() + " beans found for " + this.delegateInvocationHandlerClass + " found beans: " + beanInfo.toString());
}
Bean<H> handlerBean = handlerBeans.iterator().next();
BeanManager beanManager = BeanManagerProvider.getInstance().getBeanManager();
CreationalContext<?> creationalContext = beanManager.createCreationalContext(handlerBean);
H handlerInstance = (H) beanManager.getReference(handlerBean, this.delegateInvocationHandlerClass, creationalContext);
if (handlerBean.getScope().equals(Dependent.class)) {
this.creationalContextOfDependentHandler = creationalContext;
}
return handlerInstance;
}
use of javax.enterprise.inject.spi.PassivationCapable in project deltaspike by apache.
the class ViewAccessContext method get.
@Override
public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext) {
try {
return super.get(bean, creationalContext);
} finally {
if (bean instanceof PassivationCapable) {
PassivationCapable pc = (PassivationCapable) bean;
viewAccessBeanAccessHistory.getAccessedBeans().add(pc.getId());
}
}
}
Aggregations