Search in sources :

Example 11 with InterceptionModel

use of org.jboss.weld.interceptor.spi.model.InterceptionModel in project core by weld.

the class SubclassedComponentInstantiator method createEnhancedSubclass.

protected Class<T> createEnhancedSubclass(EnhancedAnnotatedType<T> type, Bean<?> bean, BeanManagerImpl manager) {
    Set<InterceptionModel> models = getInterceptionModelsForType(type, manager, bean);
    Set<MethodSignature> enhancedMethodSignatures = new HashSet<MethodSignature>();
    Set<MethodSignature> interceptedMethodSignatures = (models == null) ? enhancedMethodSignatures : new HashSet<MethodSignature>();
    for (AnnotatedMethod<?> method : Beans.getInterceptableMethods(type)) {
        enhancedMethodSignatures.add(MethodSignatureImpl.of(method));
        if (models != null) {
            for (InterceptionModel model : models) {
                if (!model.getInterceptors(InterceptionType.AROUND_INVOKE, method.getJavaMember()).isEmpty()) {
                    interceptedMethodSignatures.add(MethodSignatureImpl.of(method));
                    break;
                }
            }
        }
    }
    Set<Type> types = null;
    if (bean == null) {
        types = Collections.<Type>singleton(type.getJavaClass());
    } else {
        types = bean.getTypes();
    }
    return new InterceptedSubclassFactory<T>(manager.getContextId(), type.getJavaClass(), types, bean, enhancedMethodSignatures, interceptedMethodSignatures).getProxyClass();
}
Also used : InterceptionType(org.jboss.weld.interceptor.spi.model.InterceptionType) Type(java.lang.reflect.Type) SlimAnnotatedType(org.jboss.weld.annotated.slim.SlimAnnotatedType) EnhancedAnnotatedType(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType) MethodSignature(org.jboss.weld.annotated.enhanced.MethodSignature) InterceptionModel(org.jboss.weld.interceptor.spi.model.InterceptionModel) HashSet(java.util.HashSet)

Example 12 with InterceptionModel

use of org.jboss.weld.interceptor.spi.model.InterceptionModel in project wildfly by wildfly.

the class WeldInterceptorBindingsService method getInterceptorBindings.

private InterceptorBindings getInterceptorBindings(final String ejbName, final BeanManagerImpl manager) {
    InterceptorBindings retVal = null;
    if (ejbName != null) {
        retVal = interceptorSupport.getInterceptorBindings(ejbName, manager);
    } else {
        // This is a managed bean
        SlimAnnotatedType<?> type = (SlimAnnotatedType<?>) manager.createAnnotatedType(componentClass);
        if (!manager.getInterceptorModelRegistry().containsKey(type)) {
            EnhancedAnnotatedType<?> enhancedType = manager.getServices().get(ClassTransformer.class).getEnhancedAnnotatedType(type);
            InterceptionModelInitializer.of(manager, enhancedType, null).init();
        }
        InterceptionModel model = manager.getInterceptorModelRegistry().get(type);
        if (model != null) {
            retVal = new InterceptorBindingsAdapter(manager.getInterceptorModelRegistry().get(type));
        }
    }
    return retVal != null ? retVal : NullInterceptorBindings.INSTANCE;
}
Also used : InterceptorBindingsAdapter(org.jboss.weld.bean.interceptor.InterceptorBindingsAdapter) InterceptorBindings(org.jboss.weld.ejb.spi.InterceptorBindings) ClassTransformer(org.jboss.weld.resources.ClassTransformer) InterceptionModel(org.jboss.weld.interceptor.spi.model.InterceptionModel) SlimAnnotatedType(org.jboss.weld.annotated.slim.SlimAnnotatedType)

Aggregations

InterceptionModel (org.jboss.weld.interceptor.spi.model.InterceptionModel)12 BasicInjectionTarget (org.jboss.weld.injection.producer.BasicInjectionTarget)3 Type (java.lang.reflect.Type)2 HashSet (java.util.HashSet)2 Decorator (javax.enterprise.inject.spi.Decorator)2 SlimAnnotatedType (org.jboss.weld.annotated.slim.SlimAnnotatedType)2 InterceptorBindingsAdapter (org.jboss.weld.bean.interceptor.InterceptorBindingsAdapter)2 InterceptionType (org.jboss.weld.interceptor.spi.model.InterceptionType)2 ClassTransformer (org.jboss.weld.resources.ClassTransformer)2 TemplatesImpl (com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl)1 Annotation (java.lang.annotation.Annotation)1 Constructor (java.lang.reflect.Constructor)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Bean (javax.enterprise.inject.spi.Bean)1 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 Interceptor (javax.enterprise.inject.spi.Interceptor)1 ProcessAnnotatedType (javax.enterprise.inject.spi.ProcessAnnotatedType)1 ProcessSyntheticAnnotatedType (javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType)1 EnhancedAnnotatedType (org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType)1 MethodSignature (org.jboss.weld.annotated.enhanced.MethodSignature)1