@Override public void configure( DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription viewDescription, ViewConfiguration viewConfiguration) throws DeploymentUnitProcessingException { if (componentConfiguration.getComponentDescription() instanceof EJBComponentDescription == false) { throw MESSAGES.invalidEjbComponent( componentConfiguration.getComponentName(), componentConfiguration.getComponentClass()); } final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentConfiguration.getComponentDescription(); // if security is not enabled on the EJB, then do *not* add the security related interceptors if (!ejbComponentDescription.isSecurityEnabled()) { ROOT_LOGGER.debug( "Security is *not* enabled on EJB: " + ejbComponentDescription.getEJBName() + ", no security interceptors will apply"); return; } final String viewClassName = viewDescription.getViewClassName(); // setup the security context interceptor viewConfiguration.addViewInterceptor( new SecurityContextInterceptorFactory(), InterceptorOrder.View.SECURITY_CONTEXT); // now setup the rest of the method specific security interceptor(s) final List<Method> viewMethods = viewConfiguration.getProxyFactory().getCachedMethods(); for (final Method viewMethod : viewMethods) { // TODO: proxy factory exposes non-public methods, is this a bug in the no-interface view? if (!Modifier.isPublic(viewMethod.getModifiers())) { continue; } if (viewMethod.getDeclaringClass() == WriteReplaceInterface.class) { continue; } final EJBMethodSecurityMetaData ejbMethodSecurityMetaData = new EJBMethodSecurityMetaData(componentConfiguration, viewClassName, viewMethod); // setup the authorization interceptor final Interceptor authorizationInterceptor = new AuthorizationInterceptor(ejbMethodSecurityMetaData, viewClassName, viewMethod); viewConfiguration.addViewInterceptor( viewMethod, new ImmediateInterceptorFactory(authorizationInterceptor), InterceptorOrder.View.EJB_SECURITY_AUTHORIZATION_INTERCEPTOR); } }
@Override public void configure( final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final EJBComponentDescription ejbComponentDescription = (EJBComponentDescription) componentConfiguration.getComponentDescription(); if (ejbComponentDescription.getTransactionManagementType() == TransactionManagementType.CONTAINER) { configuration.addViewInterceptor( EjbIIOPTransactionInterceptor.FACTORY, InterceptorOrder.View.EJB_IIOP_TRANSACTION); } }
@Override public void configure( final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription viewDescription, final ViewConfiguration viewConfiguration) throws DeploymentUnitProcessingException { // setup a view interceptor which propagates remote transactions. This interceptor // should appear before the CMT/BMT interceptors so that the latter interceptors know about any // existing // tx for the invocation viewConfiguration.addViewInterceptor( EJBRemoteTransactionPropagatingInterceptorFactory.INSTANCE, InterceptorOrder.View.REMOTE_TRANSACTION_PROPAGATION_INTERCEPTOR); }
@Override public void configure( final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // note that we don't have to handle all methods on the EJBObject, as some are handled client // side final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(Attachments.REFLECTION_INDEX); for (final Method method : configuration.getProxyFactory().getCachedMethods()) { if (method.getName().equals("getPrimaryKey") && method.getParameterTypes().length == 0) { configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); configuration.addViewInterceptor( method, PRIMARY_KEY_INTERCEPTOR, InterceptorOrder.View.COMPONENT_DISPATCHER); } else if (method.getName().equals("remove") && method.getParameterTypes().length == 0) { handleRemoveMethod(componentConfiguration, configuration, index, method); } else if (method.getName().equals("getEJBLocalHome") && method.getParameterTypes().length == 0) { configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); final GetHomeInterceptorFactory factory = new GetHomeInterceptorFactory(); configuration.addViewInterceptor( method, factory, InterceptorOrder.View.COMPONENT_DISPATCHER); final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription(); componentConfiguration .getStartDependencies() .add( new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency( final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException { EjbHomeViewDescription ejbLocalHomeView = componentDescription.getEjbLocalHomeView(); if (ejbLocalHomeView == null) { throw EjbLogger.ROOT_LOGGER.beanLocalHomeInterfaceIsNull( componentDescription.getComponentName()); } serviceBuilder.addDependency( ejbLocalHomeView.getServiceName(), ComponentView.class, factory.getViewToCreate()); } }); } else if (method.getName().equals("getEJBHome") && method.getParameterTypes().length == 0) { configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); final GetHomeInterceptorFactory factory = new GetHomeInterceptorFactory(); configuration.addViewInterceptor( method, factory, InterceptorOrder.View.COMPONENT_DISPATCHER); final SessionBeanComponentDescription componentDescription = (SessionBeanComponentDescription) componentConfiguration.getComponentDescription(); componentConfiguration .getStartDependencies() .add( new DependencyConfigurator<ComponentStartService>() { @Override public void configureDependency( final ServiceBuilder<?> serviceBuilder, final ComponentStartService service) throws DeploymentUnitProcessingException { EjbHomeViewDescription ejbHomeView = componentDescription.getEjbHomeView(); if (ejbHomeView == null) { throw EjbLogger.ROOT_LOGGER.beanHomeInterfaceIsNull( componentDescription.getComponentName()); } serviceBuilder.addDependency( ejbHomeView.getServiceName(), ComponentView.class, factory.getViewToCreate()); } }); } else if (method.getName().equals("getHandle") && method.getParameterTypes().length == 0) { // ignore, handled client side } else if (method.getName().equals("isIdentical") && method.getParameterTypes().length == 1 && (method.getParameterTypes()[0].equals(EJBObject.class) || method.getParameterTypes()[0].equals(EJBLocalObject.class))) { handleIsIdenticalMethod(componentConfiguration, configuration, index, method); } else { final Method componentMethod = ClassReflectionIndexUtil.findMethod( index, componentConfiguration.getComponentClass(), MethodIdentifier.getIdentifierForMethod(method)); if (componentMethod != null) { if (!Modifier.isPublic(componentMethod.getModifiers())) { throw EjbLogger.ROOT_LOGGER.ejbBusinessMethodMustBePublic(componentMethod); } configuration.addViewInterceptor( method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(componentMethod)), InterceptorOrder.View.COMPONENT_DISPATCHER); configuration.addClientInterceptor( method, ViewDescription.CLIENT_DISPATCHER_INTERCEPTOR_FACTORY, InterceptorOrder.Client.CLIENT_DISPATCHER); } else if (method.getDeclaringClass() != Object.class && method.getDeclaringClass() != WriteReplaceInterface.class) { throw EjbLogger.ROOT_LOGGER.couldNotFindViewMethodOnEjb( method, description.getViewClassName(), componentConfiguration.getComponentName()); } } } configuration.addClientPostConstructInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPostConstruct.TERMINAL_INTERCEPTOR); configuration.addClientPreDestroyInterceptor( Interceptors.getTerminalInterceptorFactory(), InterceptorOrder.ClientPreDestroy.TERMINAL_INTERCEPTOR); }