public static InterceptorClassDescription mergeInterceptorConfig(final Class<?> clazz, final EEModuleClassDescription classDescription, final ComponentDescription description, final boolean metadataComplete) { final InterceptorClassDescription interceptorConfig; if (classDescription != null && !metadataComplete) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), description.interceptorClassOverrides.get(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, description.interceptorClassOverrides.get(clazz.getName())); } return interceptorConfig; }
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME); if(classAroundInvokes.size() > 1) { throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size()); } validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
@Override public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException { final InterceptorClassDescription interceptorConfig; if (classDescription != null) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), moduleDescription.getInterceptorClassOverride(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, moduleDescription.getInterceptorClassOverride(clazz.getName())); } // get the container-interceptor class' constructor final ClassReflectionIndex interceptorClassReflectionIndex = deploymentReflectionIndex.getClassIndex(interceptorClass); final Constructor<?> interceptorClassConstructor = interceptorClassReflectionIndex.getConstructor(EMPTY_CLASS_ARRAY); if (interceptorClassConstructor == null) { throw EeLogger.ROOT_LOGGER.defaultConstructorNotFound(interceptorClass); } final MethodIdentifier aroundInvokeMethodIdentifier = interceptorConfig.getAroundInvoke(); final InterceptorFactory aroundInvokeInterceptorFactory = createInterceptorFactory(clazz, aroundInvokeMethodIdentifier, interceptorClassConstructor); if (aroundInvokeInterceptorFactory != null) { this.aroundInvokeInterceptorFactories.add(aroundInvokeInterceptorFactory); } if (ejbComponentDescription.isTimerServiceRequired()) { final MethodIdentifier aroundTimeoutMethodIdentifier = interceptorConfig.getAroundTimeout(); final InterceptorFactory aroundTimeoutInterceptorFactory = createInterceptorFactory(clazz, aroundTimeoutMethodIdentifier, interceptorClassConstructor); if (aroundTimeoutInterceptorFactory != null) { this.aroundTimeoutInterceptorFactories.add(aroundTimeoutInterceptorFactory); } } }
private void processAroundInvoke(final AnnotationTarget target, final EEModuleDescription eeModuleDescription) { if (!(target instanceof MethodInfo)) { throw EjbLogger.ROOT_LOGGER.annotationApplicableOnlyForMethods(AROUND_TIMEOUT_ANNOTATION_NAME.toString()); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); validateArgumentType(classInfo, methodInfo); final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundTimeout(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
private void processLifeCycle(final EEModuleDescription eeModuleDescription, final AnnotationTarget target, final DotName annotationType, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(annotationType); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final Type[] args = methodInfo.args(); if (args.length > 1) { ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidNumberOfArguments(methodInfo.name(), annotationType, classInfo.name())); return; } else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) { ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidSignature(methodInfo.name(), annotationType, classInfo.name(), "void methodName(InvocationContext ctx)")); return; } final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); if (annotationType == POST_CONSTRUCT_ANNOTATION) { builder.setPostConstruct(getMethodIdentifier(args, methodInfo)); } else if (annotationType == PRE_DESTROY_ANNOTATION) { builder.setPreDestroy(getMethodIdentifier(args, methodInfo)); } else if(annotationType == AROUND_CONSTRUCT_ANNOTATION){ builder.setAroundConstruct(getMethodIdentifier(args, methodInfo)); } classDescription.setInterceptorClassDescription(builder.build()); }
methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name(), InvocationContext.class); final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); if (annotationType == POST_ACTIVATE) { builder.setPostActivate(methodIdentifier);
final InterceptorClassDescription interceptorConfig; if (classDescription != null && !metadataComplete) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), moduleDescription.getInterceptorClassOverride(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, moduleDescription.getInterceptorClassOverride(clazz.getName()));
public static InterceptorClassDescription mergeInterceptorConfig(final Class<?> clazz, final EEModuleClassDescription classDescription, final ComponentDescription description, final boolean metadataComplete) { final InterceptorClassDescription interceptorConfig; if (classDescription != null && !metadataComplete) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), description.interceptorClassOverrides.get(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, description.interceptorClassOverrides.get(clazz.getName())); } return interceptorConfig; }
public static InterceptorClassDescription mergeInterceptorConfig(final Class<?> clazz, final EEModuleClassDescription classDescription, final ComponentDescription description, final boolean metadataComplete) { final InterceptorClassDescription interceptorConfig; if (classDescription != null && !metadataComplete) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), description.interceptorClassOverrides.get(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, description.interceptorClassOverrides.get(clazz.getName())); } return interceptorConfig; }
public static InterceptorClassDescription mergeInterceptorConfig(final Class<?> clazz, final EEModuleClassDescription classDescription, final ComponentDescription description, final boolean metadataComplete) { final InterceptorClassDescription interceptorConfig; if (classDescription != null && !metadataComplete) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), description.interceptorClassOverrides.get(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, description.interceptorClassOverrides.get(clazz.getName())); } return interceptorConfig; }
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME); if(classAroundInvokes.size() > 1) { throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size()); } validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final List<AnnotationInstance> classAroundInvokes = classInfo.annotations().get(AROUND_INVOKE_ANNOTATION_NAME); if(classAroundInvokes.size() > 1) { throw EeLogger.ROOT_LOGGER.aroundInvokeAnnotationUsedTooManyTimes(classInfo.name(), classAroundInvokes.size()); } validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
@Override public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException { final InterceptorClassDescription interceptorConfig; if (classDescription != null) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), moduleDescription.getInterceptorClassOverride(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, moduleDescription.getInterceptorClassOverride(clazz.getName())); } // get the container-interceptor class' constructor final ClassReflectionIndex<?> interceptorClassReflectionIndex = deploymentReflectionIndex.getClassIndex(interceptorClass); final Constructor<?> interceptorClassConstructor = interceptorClassReflectionIndex.getConstructor(EMPTY_CLASS_ARRAY); if (interceptorClassConstructor == null) { throw MESSAGES.defaultConstructorNotFound(interceptorClass); } final MethodIdentifier aroundInvokeMethodIdentifier = interceptorConfig.getAroundInvoke(); final InterceptorFactory aroundInvokeInterceptorFactory = createInterceptorFactory(clazz, aroundInvokeMethodIdentifier, interceptorClassConstructor); if (aroundInvokeInterceptorFactory != null) { this.aroundInvokeInterceptorFactories.add(aroundInvokeInterceptorFactory); } if (ejbComponentDescription.isTimerServiceApplicable()) { final MethodIdentifier aroundTimeoutMethodIdentifier = interceptorConfig.getAroundTimeout(); final InterceptorFactory aroundTimeoutInterceptorFactory = createInterceptorFactory(clazz, aroundTimeoutMethodIdentifier, interceptorClassConstructor); if (aroundTimeoutInterceptorFactory != null) { this.aroundTimeoutInterceptorFactories.add(aroundTimeoutInterceptorFactory); } } }
private void processAroundInvoke(final EEModuleDescription eeModuleDescription, final AnnotationTarget target) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw MESSAGES.methodOnlyAnnotation(AROUND_INVOKE_ANNOTATION_NAME); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); validateArgumentType(classInfo, methodInfo); InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundInvoke(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
private void processAroundInvoke(final AnnotationTarget target, final EEModuleDescription eeModuleDescription) { if (!(target instanceof MethodInfo)) { throw MESSAGES.annotationApplicableOnlyForMethods(AROUND_TIMEOUT_ANNOTATION_NAME.toString()); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); validateArgumentType(classInfo, methodInfo); final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); builder.setAroundTimeout(MethodIdentifier.getIdentifier(Object.class, methodInfo.name(), InvocationContext.class)); classDescription.setInterceptorClassDescription(builder.build()); }
@Override public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException { mergeInjectionsForClass(clazz, classDescription, moduleDescription, description, configuration, context, injectors, contextKey, uninjectors, metadataComplete); final InterceptorClassDescription interceptorConfig; if (classDescription != null && !metadataComplete) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), moduleDescription.getInterceptorClassOverride(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, moduleDescription.getInterceptorClassOverride(clazz.getName())); } // Only class level interceptors are processed for postconstruct/predestroy methods. // Method level interceptors aren't supposed to be processed for postconstruct/predestroy lifecycle // methods, as per interceptors spec if (interceptorHasLifecycleCallbacks) { final MethodIdentifier postConstructMethodIdentifier = interceptorConfig.getPostConstruct(); handleInterceptorClass(clazz, postConstructMethodIdentifier, userPostConstructByInterceptorClass, true, true); final MethodIdentifier preDestroyMethodIdentifier = interceptorConfig.getPreDestroy(); handleInterceptorClass(clazz, preDestroyMethodIdentifier, userPreDestroyByInterceptorClass, true, true); } final MethodIdentifier aroundInvokeMethodIdentifier = interceptorConfig.getAroundInvoke(); handleInterceptorClass(clazz, aroundInvokeMethodIdentifier, userAroundInvokesByInterceptorClass, false, false); if (description.isTimerServiceApplicable()) { final MethodIdentifier aroundTimeoutMethodIdentifier = interceptorConfig.getAroundTimeout(); handleInterceptorClass(clazz, aroundTimeoutMethodIdentifier, userAroundTimeoutsByInterceptorClass, false, false); } if (description.isPassivationApplicable()) { handleInterceptorClass(clazz, interceptorConfig.getPrePassivate(), userPrePassivatesByInterceptorClass, false, false); handleInterceptorClass(clazz, interceptorConfig.getPostActivate(), userPostActivatesByInterceptorClass, false, false); } }
private void processLifeCycle(final EEModuleDescription eeModuleDescription, final AnnotationTarget target, final DotName annotationType, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(annotationType); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final Type[] args = methodInfo.args(); if (args.length > 1) { ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidNumberOfArguments(methodInfo.name(), annotationType, classInfo.name())); return; } else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) { ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidSignature(methodInfo.name(), annotationType, classInfo.name(), "void methodName(InvocationContext ctx)")); return; } final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); if (annotationType == POST_CONSTRUCT_ANNOTATION) { builder.setPostConstruct(getMethodIdentifier(args, methodInfo)); } else if (annotationType == PRE_DESTROY_ANNOTATION) { builder.setPreDestroy(getMethodIdentifier(args, methodInfo)); } else if(annotationType == AROUND_CONSTRUCT_ANNOTATION){ builder.setAroundConstruct(getMethodIdentifier(args, methodInfo)); } classDescription.setInterceptorClassDescription(builder.build()); }
private void processLifeCycle(final EEModuleDescription eeModuleDescription, final AnnotationTarget target, final DotName annotationType, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException { if (!(target instanceof MethodInfo)) { throw EeLogger.ROOT_LOGGER.methodOnlyAnnotation(annotationType); } final MethodInfo methodInfo = MethodInfo.class.cast(target); final ClassInfo classInfo = methodInfo.declaringClass(); final EEModuleClassDescription classDescription = eeModuleDescription.addOrGetLocalClassDescription(classInfo.name().toString()); final Type[] args = methodInfo.args(); if (args.length > 1) { ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidNumberOfArguments(methodInfo.name(), annotationType, classInfo.name())); return; } else if (args.length == 1 && !args[0].name().toString().equals(InvocationContext.class.getName())) { ROOT_LOGGER.warn(EeLogger.ROOT_LOGGER.invalidSignature(methodInfo.name(), annotationType, classInfo.name(), "void methodName(InvocationContext ctx)")); return; } final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); if (annotationType == POST_CONSTRUCT_ANNOTATION) { builder.setPostConstruct(getMethodIdentifier(args, methodInfo)); } else if (annotationType == PRE_DESTROY_ANNOTATION) { builder.setPreDestroy(getMethodIdentifier(args, methodInfo)); } else if(annotationType == AROUND_CONSTRUCT_ANNOTATION){ builder.setAroundConstruct(getMethodIdentifier(args, methodInfo)); } classDescription.setInterceptorClassDescription(builder.build()); }
methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodInfo.name(), InvocationContext.class); final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(classDescription.getInterceptorClassDescription()); if (annotationType == POST_CONSTRUCT_ANNOTATION) { builder.setPostConstruct(methodIdentifier);
final InterceptorClassDescription interceptorConfig; if (classDescription != null && !metadataComplete) { interceptorConfig = InterceptorClassDescription.merge(classDescription.getInterceptorClassDescription(), moduleDescription.getInterceptorClassOverride(clazz.getName())); } else { interceptorConfig = InterceptorClassDescription.merge(null, moduleDescription.getInterceptorClassOverride(clazz.getName()));