Weld allows to define a special activation filter component - HttpContextActivationFilter - so that only matching HTTP requests result in context activation/deactivation. Basically there are two ways to enable/configure this component. First the integrator (e.g. WildFly application server) is allowed to provide an implementation and utilize its own configuration mechanism. Secondly - if the integrator doesn't support this option - a special initialization parameter may be associated with a web application to activate a built-in regular expression-based activation filter.
E.g. to match paths with suffix ".html" and ".xhtml" place the following init param in your web.xml:
<context-param> <param-name>org.jboss.weld.context.mapping</param-name> <param-value>(.*\.html|.*\.xhtml)</param-value> </context-param>
Param value is a regular expression and is matched againts the request URI without the context path, i.e. /foo for Visual Regex Tester from ocpsoft.org to test your mappings if not sure :-). Note that Weld only supports one activation filter at a time and integrator has always precedence. You should see a warning log if your web.xml mapping definition is ignored.(try
My quick and dirty tests showed up that using built-in regular expression-based activation filter can save several milliseconds* for each request which does not require CDI services. It's not that much but it counts!
* Resource consumption was not monitored.
|Retrieving data ...|