Search in sources :

Example 1 with InterceptionType

use of javax.enterprise.inject.spi.InterceptionType in project wildfly by wildfly.

the class WeldCapabilityImpl method ignorePrecalculatedJandexForModules.

@Override
public void ignorePrecalculatedJandexForModules(DeploymentUnit deploymentUnit, String... moduleNames) {
    // Test if running in EE9 or not
    InterceptionType type = InterceptionType.AROUND_CONSTRUCT;
    boolean ee9 = !type.getClass().getName().startsWith("javax.");
    if (ee9) {
        DeploymentUnit root = deploymentUnit;
        while (root.getParent() != null) {
            root = root.getParent();
        }
        for (String module : moduleNames) {
            root.addToAttachmentList(WeldAttachments.INGORE_PRECALCULATED_JANDEX_MODULES, module);
        }
    }
}
Also used : DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) InterceptionType(javax.enterprise.inject.spi.InterceptionType)

Example 2 with InterceptionType

use of javax.enterprise.inject.spi.InterceptionType in project core by weld.

the class InterceptionModelInitializer method initClassDeclaredEjbInterceptors.

/*
     * Class-level EJB-style interceptors
     */
private void initClassDeclaredEjbInterceptors() {
    Class<?>[] classDeclaredInterceptors = interceptorsApi.extractInterceptorClasses(annotatedType);
    boolean excludeClassLevelAroundConstructInterceptors = constructor.isAnnotationPresent(ExcludeClassInterceptors.class);
    if (classDeclaredInterceptors != null) {
        for (Class<?> clazz : classDeclaredInterceptors) {
            InterceptorClassMetadata<?> interceptor = reader.getPlainInterceptorMetadata(clazz);
            for (InterceptionType interceptionType : InterceptionType.values()) {
                if (excludeClassLevelAroundConstructInterceptors && interceptionType.equals(InterceptionType.AROUND_CONSTRUCT)) {
                    /*
                         * @ExcludeClassInterceptors suppresses @AroundConstruct interceptors defined on class level
                         */
                    continue;
                }
                if (interceptor.isEligible(org.jboss.weld.interceptor.spi.model.InterceptionType.valueOf(interceptionType))) {
                    builder.interceptGlobal(interceptionType, null, Collections.<InterceptorClassMetadata<?>>singleton(interceptor), null);
                }
            }
        }
    }
}
Also used : InterceptionType(javax.enterprise.inject.spi.InterceptionType)

Example 3 with InterceptionType

use of javax.enterprise.inject.spi.InterceptionType in project core by weld.

the class InterceptionModelInitializer method initMethodDeclaredEjbInterceptors.

private void initMethodDeclaredEjbInterceptors(AnnotatedMethod<?> method) {
    Method javaMethod = method.getJavaMember();
    boolean excludeClassInterceptors = method.isAnnotationPresent(interceptorsApi.getExcludeClassInterceptorsAnnotationClass());
    if (excludeClassInterceptors) {
        builder.addMethodIgnoringGlobalInterceptors(javaMethod);
    }
    Class<?>[] methodDeclaredInterceptors = interceptorsApi.extractInterceptorClasses(method);
    if (methodDeclaredInterceptors != null && methodDeclaredInterceptors.length > 0) {
        if (Reflections.isFinal(method.getJavaMember())) {
            throw new DeploymentException(BeanLogger.LOG.finalInterceptedBeanMethodNotAllowed(method, methodDeclaredInterceptors[0].getName()));
        }
        InterceptionType interceptionType = isTimeoutAnnotationPresentOn(method) ? InterceptionType.AROUND_TIMEOUT : InterceptionType.AROUND_INVOKE;
        builder.interceptMethod(interceptionType, javaMethod, getMethodDeclaredInterceptorMetadatas(methodDeclaredInterceptors), null);
    }
}
Also used : DeploymentException(org.jboss.weld.exceptions.DeploymentException) EnhancedAnnotatedMethod(org.jboss.weld.annotated.enhanced.EnhancedAnnotatedMethod) Method(java.lang.reflect.Method) AnnotatedMethod(javax.enterprise.inject.spi.AnnotatedMethod) InterceptionType(javax.enterprise.inject.spi.InterceptionType)

Aggregations

InterceptionType (javax.enterprise.inject.spi.InterceptionType)3 Method (java.lang.reflect.Method)1 AnnotatedMethod (javax.enterprise.inject.spi.AnnotatedMethod)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 EnhancedAnnotatedMethod (org.jboss.weld.annotated.enhanced.EnhancedAnnotatedMethod)1 DeploymentException (org.jboss.weld.exceptions.DeploymentException)1