public static InterceptorFactory factory(final List<SetupAction> actions) { final AdditionalSetupInterceptor interceptor = new AdditionalSetupInterceptor(actions); return new ImmediateInterceptorFactory(interceptor); } }
@Override public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException { if (MessageDrivenBean.class.isAssignableFrom(configuration.getComponentClass())) { configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(MessageDrivenBeanSetMessageDrivenContextInterceptor.INSTANCE), InterceptorOrder.ComponentPostConstruct.EJB_SET_CONTEXT_METHOD_INVOCATION_INTERCEPTOR); } } });
public static InterceptorFactory factory(final String serviceName) { return new ImmediateInterceptorFactory(new StatelessWriteReplaceInterceptor(serviceName)); } }
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, deploymentReflectionIndex)) { final InterceptorFactory interceptorFactory = new ImmediateInterceptorFactory(new ManagedReferenceLifecycleMethodInterceptor(contextKey, method, changeMethod, lifecycleMethod)); List<InterceptorFactory> factories = classMap.get(interceptorClassName); if (factories == null) { classMap.put(interceptorClassName, factories = new ArrayList<InterceptorFactory>()); } factories.add(interceptorFactory); } } } }.run();
public static InterceptorFactory factory(final Method method) { return new ImmediateInterceptorFactory(new InvokeMethodOnTargetInterceptor(method)); }
public static InterceptorFactory factory(final InterceptionType interceptionType, final ServiceBuilder<?> builder, final ServiceName interceptorBindingServiceName, final ComponentInterceptorSupport interceptorSupport) { final Supplier<InterceptorBindings> interceptorBindingsSupplier = builder.requires(interceptorBindingServiceName); return new ImmediateInterceptorFactory(new Jsr299BindingsInterceptor(interceptionType, interceptorSupport, interceptorBindingsSupplier)); }
interceptorFactories.put(InterceptorOrder.View.POLICY_CONTEXT, new ImmediateInterceptorFactory(new PolicyContextIdInterceptor(policyContextID))); final Map<String, Set<String>> principalVsRolesMap = securityRoles.getPrincipalVersusRolesMap(); if (! principalVsRolesMap.isEmpty()) { interceptorFactories.put(InterceptorOrder.View.SECURITY_ROLES, new ImmediateInterceptorFactory(new SecurityRolesAddingInterceptor("ejb", principalVsRolesMap))); interceptorFactories.put(InterceptorOrder.View.RUN_AS_PRINCIPAL, new ImmediateInterceptorFactory(new RunAsPrincipalInterceptor(runAsPrincipal))); final Set<String> extraRoles = securityRoles.getSecurityRoleNamesByPrincipal(runAsPrincipal); if (! extraRoles.isEmpty()) { interceptorFactories.put(InterceptorOrder.View.EXTRA_PRINCIPAL_ROLES, new ImmediateInterceptorFactory(new RoleAddingInterceptor("ejb", RoleMapper.constant(Roles.fromSet(extraRoles))))); roles.addAll(extraRoles); interceptorFactories.put(InterceptorOrder.View.RUN_AS_PRINCIPAL, new ImmediateInterceptorFactory(new RunAsPrincipalInterceptor(RunAsPrincipalInterceptor.ANONYMOUS_PRINCIPAL))); interceptorFactories.put(InterceptorOrder.View.RUN_AS_ROLE, new ImmediateInterceptorFactory(new RoleAddingInterceptor("ejb", RoleMapper.constant(Roles.fromSet(Collections.singleton(runAsRole)))))); roles.add(runAsRole);
@Override public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) { EjbSuspendInterceptor interceptor = null; ImmediateInterceptorFactory factory = null; for (ViewConfiguration view: configuration.getViews()) { EJBViewConfiguration ejbView = (EJBViewConfiguration) view; if (INTERFACES.contains(ejbView.getMethodIntf())) { if (factory == null) { interceptor = new EjbSuspendInterceptor(); factory = new ImmediateInterceptorFactory(interceptor); } view.addViewInterceptor(factory, InterceptorOrder.View.GRACEFUL_SHUTDOWN); } } configuration.getCreateDependencies().add(new DependencyConfigurator<EJBComponentCreateService>() { @Override public void configureDependency(ServiceBuilder<?> serviceBuilder, EJBComponentCreateService service) { serviceBuilder.addDependency(ControlPointService.serviceName(topLevelName, entryPoint), ControlPoint.class, service.getControlPointInjector()); } }); } });
private void handleClassMethod(final Class<?> clazz, final MethodIdentifier methodIdentifier, final List<InterceptorFactory> interceptors, boolean changeMethod, boolean lifecycleMethod, ComponentConfiguration configuration) throws DeploymentUnitProcessingException { if (methodIdentifier != null) { final Method method = ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, clazz, methodIdentifier); if (isNotOverriden(clazz, method, configuration.getComponentClass(), deploymentReflectionIndex)) { InterceptorFactory interceptorFactory = new ImmediateInterceptorFactory(new ManagedReferenceLifecycleMethodInterceptor(BasicComponentInstance.INSTANCE_KEY, method, changeMethod, lifecycleMethod)); interceptors.add(interceptorFactory); if(lifecycleMethod) { configuration.addLifecycleMethod(method); } } } } }.run();
@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; } } } });
@Override public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) { StartupCountdown countdown = context.getDeploymentUnit().getAttachment(Attachments.STARTUP_COUNTDOWN); for (ViewConfiguration view : configuration.getViews()) { EJBViewConfiguration ejbView = (EJBViewConfiguration) view; if (INTFS.contains(ejbView.getMethodIntf())) { ejbView.addViewInterceptor(new ImmediateInterceptorFactory(new StartupAwaitInterceptor(countdown)), InterceptorOrder.View.STARTUP_AWAIT_INTERCEPTOR); } } } });
private static void addJsr299BindingsCreateInterceptor(final ComponentConfiguration configuration, final ComponentDescription description, final String beanName, final ServiceName weldServiceName, ServiceBuilder<?> builder, final ServiceName bindingServiceName, final ComponentInterceptorSupport componentInterceptorSupport) { //add the create interceptor that creates the CDI interceptors final Supplier<WeldBootstrapService> weldContainerSupplier = builder.requires(weldServiceName); final Supplier<InterceptorBindings> interceptorBindingsSupplier = builder.requires(bindingServiceName); final Jsr299BindingsCreateInterceptor createInterceptor = new Jsr299BindingsCreateInterceptor(weldContainerSupplier, interceptorBindingsSupplier, description.getBeanDeploymentArchiveId(), beanName, componentInterceptorSupport); configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(createInterceptor), InterceptorOrder.ComponentPostConstruct.CREATE_CDI_INTERCEPTORS); }
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) {
@Override public void configure(DeploymentPhaseContext context, ComponentDescription description, ComponentConfiguration configuration) throws DeploymentUnitProcessingException { if (isInitOnStartup()) { final StartupCountdown startupCountdown = context.getDeploymentUnit().getAttachment(Attachments.STARTUP_COUNTDOWN); configuration.addPostConstructInterceptor(new ImmediateInterceptorFactory(new StartupCountDownInterceptor(startupCountdown)), InterceptorOrder.ComponentPostConstruct.STARTUP_COUNTDOWN_INTERCEPTOR); } } });
@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; } } } } });
public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { // Add MB association interceptors configuration.addClientPostConstructInterceptor(ManagedBeanCreateInterceptor.FACTORY, InterceptorOrder.ClientPostConstruct.INSTANCE_CREATE); final ClassLoader classLoader = componentConfiguration.getModuleClassLoader(); configuration.addViewInterceptor(AccessCheckingInterceptor.getFactory(), InterceptorOrder.View.CHECKING_INTERCEPTOR); configuration.addViewInterceptor(new ImmediateInterceptorFactory(new ContextClassLoaderInterceptor(classLoader)), InterceptorOrder.View.TCCL_INTERCEPTOR); } });
configuration.addViewInterceptor(method, new ImmediateInterceptorFactory(factory), InterceptorOrder.View.HOME_METHOD_INTERCEPTOR);
@Override public void configure(DeploymentPhaseContext context, ComponentConfiguration componentConfiguration, ViewDescription description, ViewConfiguration configuration) throws DeploymentUnitProcessingException { //add the invocation type to the start of the chain //TODO: is there a cleaner way to do this? configuration.addViewInterceptor(new ImmediateInterceptorFactory(new Interceptor() { @Override public Object processInvocation(final InterceptorContext context) throws Exception { context.putPrivateData(InvocationType.class, InvocationType.MESSAGE_DELIVERY); return context.proceed(); } }), InterceptorOrder.View.INVOCATION_TYPE); // add the instance associating interceptor at the start of the interceptor chain configuration.addViewInterceptor(MessageDrivenComponentInstanceAssociatingFactory.instance(), InterceptorOrder.View.ASSOCIATING_INTERCEPTOR); final MessageDrivenComponentDescription mdb = (MessageDrivenComponentDescription) componentConfiguration.getComponentDescription(); if (mdb.getTransactionManagementType() == TransactionManagementType.CONTAINER) { configuration.addViewInterceptor(CMTTxInterceptor.FACTORY, InterceptorOrder.View.CMT_TRANSACTION_INTERCEPTOR); } } });
configuration.getStartDependencies().add(new ComponentDescription.InjectedConfigurator(injectionConfiguration, configuration, context, managedReferenceFactoryValue)); injectors.addFirst(injectionConfiguration.getTarget().createInjectionInterceptorFactory(instanceKey, valueContextKey, managedReferenceFactoryValue, context.getDeploymentUnit(), injectionConfiguration.isOptional())); uninjectors.addLast(new ImmediateInterceptorFactory(new ManagedReferenceReleaseInterceptor(valueContextKey)));