Skip to content

Commit

Permalink
WFLY-7109 Move CDI request request scope activation to the view inter…
Browse files Browse the repository at this point in the history
…ceptor
  • Loading branch information
stuartwdouglas committed Sep 15, 2016
1 parent 954154e commit 2a93a9e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -37,7 +37,6 @@ public static final class Component {

public static final int INITIAL_INTERCEPTOR = 0x100;
public static final int CONCURRENT_CONTEXT = 0x180;
public static final int CDI_REQUEST_SCOPE = 0x320;
public static final int SYNCHRONIZATION_INTERCEPTOR = 0x500;
public static final int REENTRANCY_INTERCEPTOR = 0x501;
public static final int BMT_TRANSACTION_INTERCEPTOR = 0x520;
Expand Down Expand Up @@ -191,6 +190,7 @@ public static final class View {
public static final int INVOCATION_CONTEXT_INTERCEPTOR = 0x400;
// should happen before the CMT/BMT interceptors
public static final int REMOTE_TRANSACTION_PROPAGATION_INTERCEPTOR = 0x450;
public static final int CDI_REQUEST_SCOPE = 0x480;
public static final int CMT_TRANSACTION_INTERCEPTOR = 0x500;
public static final int HOME_METHOD_INTERCEPTOR = 0x600;
public static final int ASSOCIATING_INTERCEPTOR = 0x700;
Expand Down
Expand Up @@ -38,6 +38,7 @@
import org.jboss.as.ee.component.DependencyConfigurator;
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.component.InterceptorDescription;
import org.jboss.as.ee.component.ViewConfiguration;
import org.jboss.as.ee.component.interceptors.InterceptorOrder;
import org.jboss.as.ee.component.interceptors.UserInterceptorFactory;
import org.jboss.as.ee.managedbean.component.ManagedBeanComponentDescription;
Expand Down Expand Up @@ -110,6 +111,16 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
} else {
beanName = null;
}
component.getConfigurators().add((context, description, configuration) -> {

//add interceptor to activate the request scope if required
final EjbRequestScopeActivationInterceptor.Factory requestFactory = new EjbRequestScopeActivationInterceptor.Factory(weldBootstrapService);

for(ViewConfiguration view : configuration.getViews()) {
view.addViewInterceptor(requestFactory, InterceptorOrder.View.CDI_REQUEST_SCOPE);
}
configuration.addTimeoutViewInterceptor(requestFactory, InterceptorOrder.View.CDI_REQUEST_SCOPE);
});
component.getConfigurators().addFirst(new ComponentConfigurator() {
@Override
public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException {
Expand Down Expand Up @@ -165,9 +176,6 @@ public void configureDependency(final ServiceBuilder<?> serviceBuilder, Componen

final ServiceName bindingServiceName = addWeldInterceptorBindingService(target, configuration, componentClass, beanName, weldServiceName, weldStartService, beanDeploymentArchiveId);

//add interceptor to activate the request scope if required
final EjbRequestScopeActivationInterceptor.Factory requestFactory = new EjbRequestScopeActivationInterceptor.Factory(weldServiceName);
configuration.addComponentInterceptor(requestFactory, InterceptorOrder.Component.CDI_REQUEST_SCOPE, false);

addJsr299BindingsCreateInterceptor(configuration, description, beanName, weldServiceName, builder, bindingServiceName);

Expand Down

0 comments on commit 2a93a9e

Please sign in to comment.