Search in sources :

Example 1 with AcceptingHttpContextActivationFilter

use of org.jboss.weld.servlet.spi.helpers.AcceptingHttpContextActivationFilter in project core by weld.

the class ServletUtils method getContextActivationFilter.

/**
 * Returns the right {@link HttpContextActivationFilter}. If one is set through the SPI it has precedence. Otherwise, if a mapping is set using web.xml, a
 * new {@link RegexHttpContextActivationFilter} is constructed and returned. By default, {@link AcceptingHttpContextActivationFilter} is used.
 *
 * @param manager
 * @param context
 * @return
 */
public static HttpContextActivationFilter getContextActivationFilter(BeanManagerImpl manager, ServletContext context) {
    HttpContextActivationFilter filter = manager.getServices().get(HttpContextActivationFilter.class);
    final String pattern = context.getInitParameter(InitParameters.CONTEXT_MAPPING);
    if (filter == AcceptingHttpContextActivationFilter.INSTANCE) {
        // SPI has precedence. If a filter was not set through SPI let's see if a mapping is set in web.xml
        if (pattern != null) {
            return new RegexHttpContextActivationFilter(pattern);
        }
    } else if (pattern != null) {
        ServletLogger.LOG.webXmlMappingPatternIgnored(pattern);
    }
    return filter;
}
Also used : RegexHttpContextActivationFilter(org.jboss.weld.servlet.spi.helpers.RegexHttpContextActivationFilter) AcceptingHttpContextActivationFilter(org.jboss.weld.servlet.spi.helpers.AcceptingHttpContextActivationFilter) HttpContextActivationFilter(org.jboss.weld.servlet.spi.HttpContextActivationFilter) RegexHttpContextActivationFilter(org.jboss.weld.servlet.spi.helpers.RegexHttpContextActivationFilter)

Aggregations

HttpContextActivationFilter (org.jboss.weld.servlet.spi.HttpContextActivationFilter)1 AcceptingHttpContextActivationFilter (org.jboss.weld.servlet.spi.helpers.AcceptingHttpContextActivationFilter)1 RegexHttpContextActivationFilter (org.jboss.weld.servlet.spi.helpers.RegexHttpContextActivationFilter)1