Jboss provides a way to intercept all web requests before they are dispatched to appropriate contexts.
Valve is a component that will be inserted into the request processing pipeline.
You can configure a valve ( Jboss provides a number of valves which you can use according to your need ) in the standalone.xml in the following section.
<subsystem xmlns="urn:jboss:domain:web:1.4" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl/>
</connector>
<valve name="myvalve" module="org.jboss.web-valves" class-name="org.apache.catalina.valves.AccessLogValve">
</valve>
</subsystem>
You can also write a custom valve to suit your requirement.
You need in extend the ValveBase class in order to do so, and then implement the invoke method.
Example:
package org.apache.catalina.valves; import java.io.IOException; import javax.servlet.ServletException; import org.apache.catalina.connector.Request; import org.apache.catalina.connector.Response; public class CustomValve extends ValveBase { public void invoke(Request request, Response response) throws IOException, ServletException{ // Add custom logic here getNext().invoke(request, response); } }
Then package this into a jar and add this as a module in the modules subsystem in jboss.
├── jboss-eap └── modules └── system └── layers └── base └── org └── jboss └── web-valves └── main └── valves.jar └── modules.xml
Leave a Reply