Search in sources :

Example 1 with SlimAnnotatedTypeStore

use of org.jboss.weld.annotated.slim.SlimAnnotatedTypeStore in project core by weld.

the class SubclassedComponentInstantiator method getInterceptionModelsForType.

private Set<InterceptionModel> getInterceptionModelsForType(EnhancedAnnotatedType<T> type, BeanManagerImpl manager, Bean<?> bean) {
    // if the bean has decorators consider all methods as intercepted
    if (bean != null && !manager.resolveDecorators(bean.getTypes(), bean.getQualifiers()).isEmpty()) {
        return null;
    }
    SlimAnnotatedTypeStore store = manager.getServices().get(SlimAnnotatedTypeStore.class);
    Set<InterceptionModel> models = new HashSet<InterceptionModel>();
    WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(type.slim()));
    for (SlimAnnotatedType<?> slimType : store.get(type.getJavaClass())) {
        WeldCollections.addIfNotNull(models, manager.getInterceptorModelRegistry().get(slimType));
    }
    for (InterceptionModel model : models) {
        if (model.hasTargetClassInterceptors() && model.getTargetClassInterceptorMetadata().isEligible(InterceptionType.AROUND_INVOKE)) {
            // returning null here means that all methods will be overridden and will delegate to MethodHandler
            return null;
        }
    }
    return models;
}
Also used : SlimAnnotatedTypeStore(org.jboss.weld.annotated.slim.SlimAnnotatedTypeStore) InterceptionModel(org.jboss.weld.interceptor.spi.model.InterceptionModel) HashSet(java.util.HashSet)

Example 2 with SlimAnnotatedTypeStore

use of org.jboss.weld.annotated.slim.SlimAnnotatedTypeStore in project core by weld.

the class EjbSupportImpl method createNewSessionBeans.

@Override
public void createNewSessionBeans(BeanDeployerEnvironment environment, BeanManagerImpl manager) {
    final SlimAnnotatedTypeStore store = manager.getServices().get(SlimAnnotatedTypeStore.class);
    final ClassTransformer classTransformer = manager.getServices().get(ClassTransformer.class);
    for (Type type : environment.getNewBeanTypes()) {
        Class<?> clazz = Reflections.getRawType(type);
        if (isEjb(clazz)) {
            EnhancedAnnotatedType<?> enhancedType = classTransformer.getEnhancedAnnotatedType(clazz, type, manager.getId());
            InternalEjbDescriptor<?> descriptor = ejbDescriptors.getUnique(clazz);
            environment.addSessionBean(createNewSessionBean(enhancedType, descriptor, manager, store));
        }
    }
}
Also used : EnhancedAnnotatedType(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType) Type(java.lang.reflect.Type) SlimAnnotatedType(org.jboss.weld.annotated.slim.SlimAnnotatedType) SlimAnnotatedTypeStore(org.jboss.weld.annotated.slim.SlimAnnotatedTypeStore) ClassTransformer(org.jboss.weld.resources.ClassTransformer)

Aggregations

SlimAnnotatedTypeStore (org.jboss.weld.annotated.slim.SlimAnnotatedTypeStore)2 Type (java.lang.reflect.Type)1 HashSet (java.util.HashSet)1 EnhancedAnnotatedType (org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType)1 SlimAnnotatedType (org.jboss.weld.annotated.slim.SlimAnnotatedType)1 InterceptionModel (org.jboss.weld.interceptor.spi.model.InterceptionModel)1 ClassTransformer (org.jboss.weld.resources.ClassTransformer)1