/** * Adds an interceptor factory to all methods of a view * * @param interceptorFactory The factory to add * @param priority The interceptor order */ public void addViewInterceptor(InterceptorFactory interceptorFactory, int priority) { for (Method method : proxyFactory.getCachedMethods()) { addViewInterceptor(method, interceptorFactory, priority); } }
/** * Adds a client interceptor factory to all methods of a view * * @param interceptorFactory The factory to add * @param priority The interceptor order */ public void addClientInterceptor(InterceptorFactory interceptorFactory, int priority) { for (Method method : proxyFactory.getCachedMethods()) { addClientInterceptor(method, interceptorFactory, priority); } }
@Override public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException { //add equals/hashCode interceptor for (Method method : configuration.getProxyFactory().getCachedMethods()) { if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) || method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) { configuration.addClientInterceptor(method, ComponentTypeIdentityInterceptorFactory.INSTANCE, InterceptorOrder.Client.EJB_EQUALS_HASHCODE); } } // add the singleton component instance associating interceptor configuration.addViewInterceptor(SingletonComponentInstanceAssociationInterceptor.FACTORY, InterceptorOrder.View.ASSOCIATING_INTERCEPTOR); } });
@Override public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException { //add equals/hashCode interceptor //add equals/hashCode interceptor for (Method method : configuration.getProxyFactory().getCachedMethods()) { if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) || method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) { configuration.addClientInterceptor(method, ComponentTypeIdentityInterceptorFactory.INSTANCE, InterceptorOrder.Client.EJB_EQUALS_HASHCODE); } } // add the stateless component instance associating interceptor configuration.addViewInterceptor(StatelessComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR); } });
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration viewConfiguration) throws DeploymentUnitProcessingException { EJBViewDescription ejbViewDescription = (EJBViewDescription) view; //if this is a home interface we add a different interceptor if (ejbViewDescription.getMethodIntf() == MethodIntf.HOME || ejbViewDescription.getMethodIntf() == MethodIntf.LOCAL_HOME) { for (Method method : viewConfiguration.getProxyFactory().getCachedMethods()) { if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) || method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) { viewConfiguration.addClientInterceptor(method, ComponentTypeIdentityInterceptorFactory.INSTANCE, InterceptorOrder.Client.EJB_EQUALS_HASHCODE); } } } else { // interceptor factory return an interceptor which sets up the session id on component view instance creation final InterceptorFactory sessionIdGeneratingInterceptorFactory = StatefulComponentSessionIdGeneratingInterceptor.FACTORY; // add the session id generating interceptor to the start of the *post-construct interceptor chain of the ComponentViewInstance* viewConfiguration.addClientPostConstructInterceptor(sessionIdGeneratingInterceptorFactory, InterceptorOrder.ClientPostConstruct.INSTANCE_CREATE); for (Method method : viewConfiguration.getProxyFactory().getCachedMethods()) { if ((method.getName().equals("hashCode") && method.getParameterTypes().length == 0) || method.getName().equals("equals") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == Object.class) { viewConfiguration.addClientInterceptor(method, StatefulIdentityInterceptor.FACTORY, InterceptorOrder.Client.EJB_EQUALS_HASHCODE); } } } } });
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription(); for (final Method method : configuration.getProxyFactory().getCachedMethods()) { //we need the component method to get the correct declaring class final Method componentMethod = ClassReflectionIndexUtil.findMethod(deploymentReflectionIndex, componentClass, method); if (componentMethod != null) { if (componentDescription.getAsynchronousClasses().contains(componentMethod.getDeclaringClass().getName())) { addAsyncInterceptor(configuration, method, isSecurityDomainKnown); configuration.addAsyncMethod(method); } else { MethodIdentifier id = MethodIdentifier.getIdentifierForMethod(method); if (componentDescription.getAsynchronousMethods().contains(id)) { addAsyncInterceptor(configuration, method, isSecurityDomainKnown); configuration.addAsyncMethod(method); } } } } } });
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX); for (final Method method : configuration.getProxyFactory().getCachedMethods()) { if (!Modifier.isPublic(method.getModifiers()) && isNotOverriden(method, componentConfiguration.getComponentClass(), index)) { configuration.addClientInterceptor(method, new ImmediateInterceptorFactory(new NotBusinessMethodInterceptor(method)), InterceptorOrder.Client.NOT_BUSINESS_METHOD_EXCEPTION); } } } });
@Override public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException { final Method TO_STRING_METHOD; try { TO_STRING_METHOD = Object.class.getMethod("toString"); } catch (NoSuchMethodException nsme) { throw new DeploymentUnitProcessingException(nsme); } List<Method> methods = configuration.getProxyFactory().getCachedMethods(); for (Method method : methods) { if (TO_STRING_METHOD.equals(method)) { configuration.addClientInterceptor(method, new ImmediateInterceptorFactory(new ToStringMethodInterceptor(EJBComponentDescription.this.getComponentName())), InterceptorOrder.Client.TO_STRING); return; } } } });
final ProxyFactory<?> proxyFactory = viewConfiguration.getProxyFactory(); this.proxyFactory = proxyFactory; final List<Method> methods = proxyFactory.getCachedMethods(); final int methodCount = methods.size(); clientPostConstruct = Interceptors.getChainedInterceptorFactory(viewConfiguration.getClientPostConstructInterceptors());
for (final Method method : configuration.getProxyFactory().getCachedMethods()) {
@Override public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException { final StatefulComponentDescription statefulComponentDescription = (StatefulComponentDescription) componentConfiguration.getComponentDescription(); 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; } } } } });
for (Method method : configuration.getProxyFactory().getCachedMethods()) { if (method.getName().startsWith("create")) {
final List<Method> viewMethods = viewConfiguration.getProxyFactory().getCachedMethods(); for (final Method method : viewMethods) { final MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(method.getReturnType(), method.getName(), method.getParameterTypes());
final List<Method> viewMethods = viewConfiguration.getProxyFactory().getCachedMethods(); for (final Method viewMethod : viewMethods) { if (!Modifier.isPublic(viewMethod.getModifiers()) || viewMethod.getDeclaringClass() == WriteReplaceInterface.class) {
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // Create method indexes final DeploymentReflectionIndex reflectionIndex = context.getDeploymentUnit().getAttachment(REFLECTION_INDEX); final List<Method> methods = configuration.getProxyFactory().getCachedMethods(); for (final Method method : methods) { MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifierForMethod(method); Method componentMethod = ClassReflectionIndexUtil.findMethod(reflectionIndex, componentConfiguration.getComponentClass(), methodIdentifier); if (componentMethod == null && method.getDeclaringClass().isInterface() && (method.getModifiers() & (ABSTRACT | PUBLIC | STATIC)) == PUBLIC) { // no component method and the interface method is defaulted, so we really do want to invoke on the interface method componentMethod = method; } if (componentMethod != null) { if ((BRIDGE & componentMethod.getModifiers()) != 0) { Method other = findRealMethodForBridgeMethod(componentMethod, componentConfiguration, reflectionIndex, methodIdentifier); //try and find the non-bridge method to delegate to if(other != null) { componentMethod = other; } } configuration.addViewInterceptor(method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.addClientInterceptor(method, CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); configuration.getViewToComponentMethodMap().put(method, componentMethod); } } configuration.addClientPostConstructInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR); configuration.addClientPreDestroyInterceptor(Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR); }
for (Method method : view.getProxyFactory().getCachedMethods()) {
final List<Method> viewMethods = viewConfiguration.getProxyFactory().getCachedMethods(); final List<Method> methodsWithoutExplicitSecurityConfiguration = new ArrayList<Method>(); for (final Method viewMethod : viewMethods) {
/** * Adds an interceptor factory to all methods of a view * * @param interceptorFactory The factory to add * @param priority The interceptor order */ public void addViewInterceptor(InterceptorFactory interceptorFactory, int priority) { for (Method method : proxyFactory.getCachedMethods()) { addViewInterceptor(method, interceptorFactory, priority); } }
/** * Adds a client interceptor factory to all methods of a view * * @param interceptorFactory The factory to add * @param priority The interceptor order */ public void addClientInterceptor(InterceptorFactory interceptorFactory, int priority) { for (Method method : proxyFactory.getCachedMethods()) { addClientInterceptor(method, interceptorFactory, priority); } }
/** * Adds a client interceptor factory to all methods of a view * * @param interceptorFactory The factory to add * @param priority The interceptor order */ public void addClientInterceptor(InterceptorFactory interceptorFactory, int priority) { for (Method method : proxyFactory.getCachedMethods()) { addClientInterceptor(method, interceptorFactory, priority); } }