You can configure custom valves and Catalina listeners for web modules or virtual servers by defining properties. A valve class must implement the org.apache.catalina.Valve interface from Tomcat or previous Enterprise Server releases, or the org.glassfish.web.valve.GlassFishValve interface from the current Enterprise Server release. A listener class for a virtual server must implement the org.apache.catalina.ContainerListener or org.apache.catalina.LifecycleListener interface. A listener class for a web module must implement the org.apache.catalina.ContainerListener, org.apache.catalina.LifecycleListener, or org.apache.catalina.InstanceListener interface.
In the sun-web.xml file, valve and listener properties for a web module look like this:
<sun-web-app ...> ... <property name="valve_1" value="org.glassfish.extension.Valve"/> <property name="listener_1" value="org.glassfish.extension.MyLifecycleListener"/> </sun-web-app>
In the domain.xml file, valve and listener properties for a virtual server look like this:
<virtual-server ...> ... <property name="valve_1" value="org.glassfish.extension.Valve"/> <property name="listener_1" value="org.glassfish.extension.MyLifecycleListener"/> </virtual-server>
You can define these properties for a virtual server in one of the following ways, then restart the server:
You can define properties using the asadmin set command. For example:
asadmin set server-config.http-service.virtual-server.MyVS.property.valve_1="org.glassfish.extension.Valve" |
You can define virtual server properties using the Administration Console. Select the HTTP Service component under the relevant configuration, select Virtual Servers, and select the desired virtual server. Select Add Property, enter the property name and value, check the enable box, and select Save. For details, click the Help button in the Administration Console.