Package org.jboss.invocation.proxy

Examples of org.jboss.invocation.proxy.MethodIdentifier


                    }
                }
            });

            //now lifecycle callbacks
            final MethodIdentifier ejbRemoveIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbRemove");
            final MethodIdentifier ejbActivateIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbActivate");
            final MethodIdentifier ejbPassivateIdentifier = MethodIdentifier.getIdentifier(void.class, "ejbPassivate");

            boolean ejbActivate = false, ejbPassivate = false, ejbRemove = false;
            Class<?> c  = componentClass;
            while (c != null && c != Object.class) {
                final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(c);
View Full Code Here


            if(removeMethod.getBeanMethod().getMethodParams() == null) {
                final NamedMethodMetaData methodData = removeMethod.getBeanMethod();
                final Collection<Method> methods = MethodResolutionUtils.resolveMethods(methodData, componentClass, reflectionIndex);
                for(final Method method : methods) {
                    final Boolean retainIfException = removeMethod.getRetainIfException();
                    final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method);
                    if(retainIfException == null) {
                        //if this is null we have to allow annotation values of retainIfException to take precidence
                        if(!annotationRemoveMethods.contains(methodIdentifier)) {
                            componentConfiguration.addRemoveMethod(methodIdentifier, false);
                        }
                    } else {
                        componentConfiguration.addRemoveMethod(methodIdentifier, retainIfException);
                    }
                }
            }
        }
        for (final RemoveMethodMetaData removeMethod : beanMetaData.getRemoveMethods()) {
            if(removeMethod.getBeanMethod().getMethodParams() != null) {
                final NamedMethodMetaData methodData = removeMethod.getBeanMethod();
                final Collection<Method> methods = MethodResolutionUtils.resolveMethods(methodData, componentClass, reflectionIndex);
                for(final Method method : methods) {
                    final Boolean retainIfException = removeMethod.getRetainIfException();
                    final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method);
                    if(retainIfException == null) {
                        //if this is null we have to allow annotation values of retainIfException to take precidence
                        if(!annotationRemoveMethods.contains(methodIdentifier)) {
                            componentConfiguration.addRemoveMethod(methodIdentifier, false);
                        }
View Full Code Here

                    config.addRole(role, new EJBMethodPermission(ejbName, null, null, null));
                }
            }

            for (Method method : viewClass.getClassMethods()) {
                final MethodIdentifier identifier = MethodIdentifier.getIdentifierForMethod(method);
                EJBMethodSecurityAttribute methodLevel = component.getDescriptorMethodPermissions().getAttribute(methodIntf, method.getDeclaringClass().getName(), method.getName(), identifier.getParameterTypes());
                // check method level
                if (methodLevel == null) {
                    methodLevel = component.getAnnotationMethodPermissions().getAttribute(methodIntf, method.getDeclaringClass().getName(), method.getName(), identifier.getParameterTypes());
                    if (methodLevel == null) {
                        continue;
                    }
                }
                EJBMethodPermission p = new EJBMethodPermission(ejbName, identifier.getName(), type.name(), identifier.getParameterTypes());

                if (methodLevel.isDenyAll()) {
                    config.addDeny(p);
                }
                if (methodLevel.isPermitAll()) {
View Full Code Here

        if (methodLocks == null) {
            this.methodApplicableLockTypes = Collections.emptyMap();
        } else {
            final Map<EJBBusinessMethod, LockType> locks = new HashMap<EJBBusinessMethod, LockType>();
            for (Map.Entry<MethodIdentifier, LockType> entry : methodLocks.entrySet()) {
                final MethodIdentifier ejbMethodDescription = entry.getKey();
                final EJBBusinessMethod ejbMethod = this.getEJBBusinessMethod(ejbMethodDescription);
                locks.put(ejbMethod, entry.getValue());
            }
            this.methodApplicableLockTypes = Collections.unmodifiableMap(locks);
        }

        this.beanLevelAccessTimeout = sessionBeanComponentDescription.getBeanLevelAccessTimeout();

        final Map<MethodIdentifier, AccessTimeoutDetails> methodAccessTimeouts = sessionBeanComponentDescription.getMethodApplicableAccessTimeouts();
        if (methodAccessTimeouts == null) {
            this.methodApplicableAccessTimeouts = Collections.emptyMap();
        } else {
            final Map<EJBBusinessMethod, AccessTimeoutDetails> accessTimeouts = new HashMap<EJBBusinessMethod, AccessTimeoutDetails>();
            for (Map.Entry<MethodIdentifier, AccessTimeoutDetails> entry : methodAccessTimeouts.entrySet()) {
                final MethodIdentifier ejbMethodDescription = entry.getKey();
                final EJBBusinessMethod ejbMethod = this.getEJBBusinessMethod(ejbMethodDescription);
                accessTimeouts.put(ejbMethod, entry.getValue());
            }
            this.methodApplicableAccessTimeouts = Collections.unmodifiableMap(accessTimeouts);
        }
View Full Code Here

        final Class<?> componentClass = configuration.getComponentClass();
        final ClassReflectionIndex<?> classIndex = index.getClassIndex(componentClass);
        // Mapping of method identifiers to component (target) methods
        // Mapping of component methods to corresponding instance interceptor factories
        for (Method componentMethod : classIndex.getMethods()) {
            final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(componentMethod);
            int modifiers = componentMethod.getModifiers();
            if (! Modifier.isStatic(modifiers) && ! Modifier.isFinal(modifiers)) {
                componentMethods.put(MethodIdentifier.getIdentifierForMethod(componentMethod), componentMethod);
                // assemble the final set of interceptor factories for this method.
                final List<InterceptorFactory> theInterceptorFactories = new ArrayList<InterceptorFactory>();
View Full Code Here

        final String[] argTypes = new String[methodInfo.args().length];
        int i = 0;
        for (Type argType : methodInfo.args()) {
            argTypes[i++] = argType.name().toString();
        }
        MethodIdentifier identifier =  MethodIdentifier.getIdentifier(methodInfo.returnType().name().toString(), methodInfo.name(), argTypes);
        return new InterceptorMethodDescription(declaringClass,instanceClass,identifier,declaredOnTargetClass);
    }
View Full Code Here

        if(excludeDefaultAnnotations != null ) {
            for(AnnotationInstance annotation : excludeDefaultAnnotations) {
                final AnnotationTarget target = annotation.target();
                if (target instanceof MethodInfo) {
                    final MethodInfo methodInfo = MethodInfo.class.cast(target);
                    final MethodIdentifier methodIdentifier = methodIdentifierFromMethodInfo(methodInfo);
                    componentConfiguration.excludeDefaultInterceptors(methodIdentifier);
                } else {
                    componentConfiguration.setExcludeDefaultInterceptors(true);
                }
            }
        }

        //process the ExcludeClassInterceptors annotation
        final List<AnnotationInstance> excludeClassAnnotations = classAnnotations.get(EXCLUDE_CLASS_ANNOTATION_NAME);
        if(excludeClassAnnotations != null ) {
            for(AnnotationInstance annotation : excludeClassAnnotations) {
                final AnnotationTarget target = annotation.target();
                if (target instanceof MethodInfo) {
                    final MethodInfo methodInfo = MethodInfo.class.cast(target);
                    final MethodIdentifier methodIdentifier = methodIdentifierFromMethodInfo(methodInfo);
                    componentConfiguration.excludeClassInterceptors(methodIdentifier);
                } else {
                    throw new DeploymentUnitProcessingException("ExcludeClassInterceptors not applied to method: " + target);
                }
            }
View Full Code Here

                final Collection<StatefulRemoveMethod> removeMethods = statefulComponentDescription.getRemoveMethods();
                if (removeMethods.isEmpty()) {
                    return;
                }
                for (final Method viewMethod : configuration.getProxyFactory().getCachedMethods()) {
                    final MethodIdentifier viewMethodIdentifier = MethodIdentifier.getIdentifierForMethod(viewMethod);
                    for (final StatefulRemoveMethod removeMethod : removeMethods) {
                        if (removeMethod.methodIdentifier.equals(viewMethodIdentifier)) {

                            //we do not want to add this if it is the Ejb(Local)Object.remove() method, as that is handed elsewhere
                            final boolean object = EJBObject.class.isAssignableFrom(configuration.getViewClass()) || EJBLocalObject.class.isAssignableFrom(configuration.getViewClass());
                            if (!object || !viewMethodIdentifier.getName().equals("remove") || viewMethodIdentifier.getParameterTypes().length != 0) {
                                configuration.addViewInterceptor(viewMethod, new ImmediateInterceptorFactory(new StatefulRemoveInterceptor(removeMethod.retainIfException)), InterceptorOrder.View.SESSION_REMOVE_INTERCEPTOR);
                            }
                            break;
                        }
                    }
View Full Code Here

                        // 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 handleInterceptorClass(final Class<?> clazz, final MethodIdentifier methodIdentifier, final Map<String, List<InterceptorFactory>> classMap, final boolean changeMethod, final boolean lifecycleMethod) throws DeploymentUnitProcessingException {
                        if (methodIdentifier != null) {
                            final Method method = ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, clazz, methodIdentifier);
                            if (isNotOverriden(clazz, method, interceptorClass.getModuleClass(), deploymentReflectionIndex)) {
                                final InterceptorFactory interceptorFactory = new ManagedReferenceLifecycleMethodInterceptorFactory(contextKey, method, changeMethod, lifecycleMethod);
                                List<InterceptorFactory> factories = classMap.get(interceptorClassName);
                                if (factories == null) {
                                    classMap.put(interceptorClassName, factories = new ArrayList<InterceptorFactory>());
                                }
                                factories.add(interceptorFactory);
                            }
                        }
                    }
                }.run();
            }

            final List<InterceptorFactory> userPostConstruct = new ArrayList<InterceptorFactory>();
            final List<InterceptorFactory> userPreDestroy = new ArrayList<InterceptorFactory>();
            final List<InterceptorFactory> userPrePassivate = new ArrayList<InterceptorFactory>();
            final List<InterceptorFactory> userPostActivate = new ArrayList<InterceptorFactory>();

            //now add the lifecycle interceptors in the correct order
            for (final InterceptorDescription interceptorClass : interceptorWithLifecycleCallbacks) {
                if (userPostConstructByInterceptorClass.containsKey(interceptorClass.getInterceptorClassName())) {
                    userPostConstruct.addAll(userPostConstructByInterceptorClass.get(interceptorClass.getInterceptorClassName()));
                }
                if (userPreDestroyByInterceptorClass.containsKey(interceptorClass.getInterceptorClassName())) {
                    userPreDestroy.addAll(userPreDestroyByInterceptorClass.get(interceptorClass.getInterceptorClassName()));
                }
                if (description.isPassivationApplicable()) {
                    if (userPrePassivatesByInterceptorClass.containsKey(interceptorClass.getInterceptorClassName())) {
                        userPrePassivate.addAll(userPrePassivatesByInterceptorClass.get(interceptorClass.getInterceptorClassName()));
                    }
                    if (userPostActivatesByInterceptorClass.containsKey(interceptorClass.getInterceptorClassName())) {
                        userPostActivate.addAll(userPostActivatesByInterceptorClass.get(interceptorClass.getInterceptorClassName()));
                    }
                }
            }


            new ClassDescriptionTraversal(configuration.getComponentClass(), applicationClasses) {
                @Override
                public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException {

                    final InterceptorClassDescription interceptorConfig = mergeInterceptorConfig(clazz, classDescription, description, metadataComplete);

                    handleClassMethod(clazz, interceptorConfig.getPostConstruct(), userPostConstruct, true, true);
                    handleClassMethod(clazz, interceptorConfig.getPreDestroy(), userPreDestroy, true, true);
                    handleClassMethod(clazz, interceptorConfig.getAroundInvoke(), componentUserAroundInvoke, false, false);

                    if (description.isTimerServiceApplicable()) {
                        handleClassMethod(clazz, interceptorConfig.getAroundTimeout(), componentUserAroundTimeout, false, false);
                    }

                    if (description.isPassivationApplicable()) {
                        handleClassMethod(clazz, interceptorConfig.getPrePassivate(), userPrePassivate, false, false);
                        handleClassMethod(clazz, interceptorConfig.getPostActivate(), userPostActivate, false, false);
                    }
                }

                private void handleClassMethod(final Class<?> clazz, final MethodIdentifier methodIdentifier, final List<InterceptorFactory> interceptors, boolean changeMethod, boolean lifecycleMethod) throws DeploymentUnitProcessingException {
                    if (methodIdentifier != null) {
                        final Method method = ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, clazz, methodIdentifier);
                        if (isNotOverriden(clazz, method, componentClassIndex.getIndexedClass(), deploymentReflectionIndex)) {
                            InterceptorFactory interceptorFactory = new ManagedReferenceLifecycleMethodInterceptorFactory(instanceKey, method, changeMethod, lifecycleMethod);
                            interceptors.add(interceptorFactory);
                        }
                    }
                }
            }.run();

            final InterceptorFactory tcclInterceptor = new ImmediateInterceptorFactory(new TCCLInterceptor(module.getClassLoader()));

            // Apply post-construct
            if (!injectors.isEmpty()) {
                configuration.addPostConstructInterceptor(weaved(injectors), InterceptorOrder.ComponentPostConstruct.RESOURCE_INJECTION_INTERCEPTORS);
            }
            if (!instantiators.isEmpty()) {
                configuration.addPostConstructInterceptor(weaved(instantiators), InterceptorOrder.ComponentPostConstruct.INSTANTIATION_INTERCEPTORS);
            }
            if (!userPostConstruct.isEmpty()) {
                configuration.addPostConstructInterceptor(weaved(userPostConstruct), InterceptorOrder.ComponentPostConstruct.USER_INTERCEPTORS);
            }
            configuration.addPostConstructInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ComponentPostConstruct.TERMINAL_INTERCEPTOR);
            configuration.addPostConstructInterceptor(tcclInterceptor, InterceptorOrder.ComponentPostConstruct.TCCL_INTERCEPTOR);

            // Apply pre-destroy
            if (!uninjectors.isEmpty()) {
                configuration.addPreDestroyInterceptor(weaved(uninjectors), InterceptorOrder.ComponentPreDestroy.UNINJECTION_INTERCEPTORS);
            }
            if (!destructors.isEmpty()) {
                configuration.addPreDestroyInterceptor(weaved(destructors), InterceptorOrder.ComponentPreDestroy.DESTRUCTION_INTERCEPTORS);
            }
            if (!userPreDestroy.isEmpty()) {
                configuration.addPreDestroyInterceptor(weaved(userPreDestroy), InterceptorOrder.ComponentPreDestroy.USER_INTERCEPTORS);
            }
            configuration.addPreDestroyInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ComponentPreDestroy.TERMINAL_INTERCEPTOR);
            configuration.addPreDestroyInterceptor(tcclInterceptor, InterceptorOrder.ComponentPreDestroy.TCCL_INTERCEPTOR);

            if (description.isPassivationApplicable()) {
                if (!userPrePassivate.isEmpty()) {
                    configuration.addPrePassivateInterceptor(weaved(userPrePassivate), InterceptorOrder.ComponentPassivation.USER_INTERCEPTORS);
                }
                configuration.addPrePassivateInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ComponentPassivation.TERMINAL_INTERCEPTOR);
                configuration.addPrePassivateInterceptor(tcclInterceptor, InterceptorOrder.ComponentPassivation.TCCL_INTERCEPTOR);

                if (!userPostActivate.isEmpty()) {
                    configuration.addPostActivateInterceptor(weaved(userPostActivate), InterceptorOrder.ComponentPassivation.USER_INTERCEPTORS);
                }
                configuration.addPostActivateInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ComponentPassivation.TERMINAL_INTERCEPTOR);
                configuration.addPostActivateInterceptor(tcclInterceptor, InterceptorOrder.ComponentPassivation.TCCL_INTERCEPTOR);
            }

            // @AroundInvoke interceptors
            final List<InterceptorDescription> classInterceptors = description.getClassInterceptors();
            final Map<MethodIdentifier, List<InterceptorDescription>> methodInterceptors = description.getMethodInterceptors();

            if (description.isIntercepted()) {

                for (final Method method : configuration.getDefinedComponentMethods()) {

                    //now add the interceptor that initializes and the interceptor that actually invokes to the end of the interceptor chain

                    configuration.addComponentInterceptor(method, Interceptors.getInitialInterceptorFactory(), InterceptorOrder.Component.INITIAL_INTERCEPTOR);
                    configuration.addComponentInterceptor(method, new ManagedReferenceMethodInterceptorFactory(instanceKey, method), InterceptorOrder.Component.TERMINAL_INTERCEPTOR);

                    final MethodIdentifier identifier = MethodIdentifier.getIdentifier(method.getReturnType(), method.getName(), method.getParameterTypes());

                    final List<InterceptorFactory> userAroundInvokes = new ArrayList<InterceptorFactory>();
                    final List<InterceptorFactory> userAroundTimeouts = new ArrayList<InterceptorFactory>();
                    // first add the default interceptors (if not excluded) to the deque
                    if (!description.isExcludeDefaultInterceptors() && !description.isExcludeDefaultInterceptors(identifier)) {
View Full Code Here

                // around-invoke(s) of the interceptor configured (if any) in the deployment descriptor
                AroundInvokesMetaData aroundInvokes = interceptor.getAroundInvokes();
                if (aroundInvokes != null) {
                    for (AroundInvokeMetaData aroundInvoke : aroundInvokes) {
                        String methodName = aroundInvoke.getMethodName();
                        MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, new Class<?>[]{InvocationContext.class});
                        // TODO: This constructor for InterceptorMethodDescription needs a review. How does one get hold of the "declaraingClass"
                        // for a DD based interceptor configuration. Why not just specify the instance class and then "find" the correct method
                        // internally
                        InterceptorMethodDescription aroundInvokeMethodDescription = new InterceptorMethodDescription(interceptor.getInterceptorClass(), interceptor.getInterceptorClass(), methodIdentifier, false);
                        // add the around-invoke to the interceptor description
                        interceptorDescription.addAroundInvokeMethod(aroundInvokeMethodDescription);
                    }
                }

                // post-construct(s) of the interceptor configured (if any) in the deployment descriptor
                LifecycleCallbacksMetaData postConstructs = interceptor.getPostConstructs();
                if (postConstructs != null) {
                    for (LifecycleCallbackMetaData postConstruct : postConstructs) {
                        String methodName = postConstruct.getMethodName();
                        MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodName, new Class<?>[]{InvocationContext.class});
                        // TODO: This constructor for InterceptorMethodDescription needs a review. How does one get hold of the "declaraingClass"
                        // for a DD based interceptor configuration. Why not just specify the instance class and then "find" the correct method
                        // internally
                        InterceptorMethodDescription postConstructInterceptor = new InterceptorMethodDescription(interceptor.getInterceptorClass(), interceptor.getInterceptorClass(), methodIdentifier, false);
                        // add it to the interceptor description
                        interceptorDescription.addPostConstruct(postConstructInterceptor);
                    }
                }

                // pre-destroy(s) of the interceptor configured (if any) in the deployment descriptor
                LifecycleCallbacksMetaData preDestroys = interceptor.getPreDestroys();
                if (preDestroys != null) {
                    for (LifecycleCallbackMetaData preDestroy : preDestroys) {
                        String methodName = preDestroy.getMethodName();
                        MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Void.TYPE, methodName, new Class<?>[]{InvocationContext.class});
                        // TODO: This constructor for InterceptorMethodDescription needs a review. How does one get hold of the "declaraingClass"
                        // for a DD based interceptor configuration. Why not just specify the instance class and then "find" the correct method
                        // internally
                        InterceptorMethodDescription preDestroyInterceptor = new InterceptorMethodDescription(interceptor.getInterceptorClass(), interceptor.getInterceptorClass(), methodIdentifier, false);
                        // add it to the interceptor description
View Full Code Here

TOP

Related Classes of org.jboss.invocation.proxy.MethodIdentifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.