@Deployment(testable = false) public static WebArchive createTestArchive() { return new WebArchiveBuilder() .withTestClassPackage(ConversationFilterTest.class) .withWebXml( Descriptors.create(WebAppDescriptor.class).createFilter().filterName(OuterFilter.class.getSimpleName()) .filterClass(OuterFilter.class.getName()).up().createFilterMapping() .filterName(OuterFilter.class.getSimpleName()).urlPattern("/*").up().createFilterMapping() .filterName("CDI Conversation Filter").urlPattern("/*").up()).build(); }
public static FilterType<WebAppDescriptor> findFilter( DeploymentContext context, String name ) { List<FilterType<WebAppDescriptor>> filters = context.getWebAppDescriptor().getAllFilter(); for( FilterType<WebAppDescriptor> filter : filters ) { if( name.equals( filter.getFilterName() ) ) { return filter; } } return null; }
private static void initialize( DeploymentContext context, Map<String,List<ProviderDeploymentContributor>> providers, Map<String,List<ServiceDeploymentContributor>> services, Map.Entry<String,ServiceDeploymentContributor> applications ) { WebAppDescriptor wad = context.getWebAppDescriptor(); String topoName = context.getTopology().getName(); if( applications == null ) { String servletName = topoName + SERVLET_NAME_SUFFIX; wad.createServlet().servletName( servletName ).servletClass( GatewayServlet.class.getName() ); wad.createServletMapping().servletName( servletName ).urlPattern( "/*" ); } else { String filterName = topoName + FILTER_NAME_SUFFIX; wad.createFilter().filterName( filterName ).filterClass( GatewayServlet.class.getName() ); wad.createFilterMapping().filterName( filterName ).urlPattern( "/*" ); } if (gatewayServices != null) { gatewayServices.initializeContribution(context); } else { log.gatewayServicesNotInitialized(); } initializeProviders( context, providers ); initializeServices( context, services ); initializeApplications( context, applications ); }
throw new DeploymentException( "Missing filter " + servletName ); } else { filter.createInitParam() .paramName( GatewayServlet.GATEWAY_DESCRIPTOR_LOCATION_PARAM ) .paramValue( "/WEB-INF/" + GatewayServlet.GATEWAY_DESCRIPTOR_LOCATION_DEFAULT );
private static void initialize( DeploymentContext context, Map<String,List<ProviderDeploymentContributor>> providers, Map<String,List<ServiceDeploymentContributor>> services, Map.Entry<String,ServiceDeploymentContributor> applications ) { WebAppDescriptor wad = context.getWebAppDescriptor(); String topoName = context.getTopology().getName(); if( applications == null ) { String servletName = topoName + SERVLET_NAME_SUFFIX; wad.createServlet().servletName( servletName ).servletClass( GatewayServlet.class.getName() ); wad.createServletMapping().servletName( servletName ).urlPattern( "/*" ); } else { String filterName = topoName + FILTER_NAME_SUFFIX; wad.createFilter().filterName( filterName ).filterClass( GatewayServlet.class.getName() ); wad.createFilterMapping().filterName( filterName ).urlPattern( "/*" ); } if (gatewayServices != null) { gatewayServices.initializeContribution(context); } else { log.gatewayServicesNotInitialized(); } initializeProviders( context, providers ); initializeServices( context, services ); initializeApplications( context, applications ); }
throw new DeploymentException( "Missing filter " + servletName ); } else { filter.createInitParam() .paramName( GatewayServlet.GATEWAY_DESCRIPTOR_LOCATION_PARAM ) .paramValue( "/WEB-INF/" + GatewayServlet.GATEWAY_DESCRIPTOR_LOCATION_DEFAULT );
public static FilterType<WebAppDescriptor> findFilter( DeploymentContext context, String name ) { List<FilterType<WebAppDescriptor>> filters = context.getWebAppDescriptor().getAllFilter(); for( FilterType<WebAppDescriptor> filter : filters ) { if( name.equals( filter.getFilterName() ) ) { return filter; } } return null; }