Custom WildFly JBossWeb Valve: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 60: Line 60:


* [[Custom WildFly JBossWeb Valve Initialization EAP 6.4.10]]
* [[Custom WildFly JBossWeb Valve Initialization EAP 6.4.10]]
==Topology==
Upon deployment, the valve is placed at the top of the Engine's pipeline. All default valves are placed after it.
==Adding a Global Valve with CLI==
{{Internal|WildFly CLI - Add a JBossWeb Global Valve|Adding a Global Valve with CLI}}


=Context Valve=
=Context Valve=

Latest revision as of 20:49, 8 March 2017

Internal

Overview

This article explains how to write and deploy a custom Tomcat valve into WildFly/EAP JBossWeb runtime. For details on how to write and deploy a custom Tomcat valve into a Tomcat container, see

Custom Tomcat Valve

A custom valve can be deployed globally as part of the JBossWeb Engine's request processing pipeline, or embedded with an application, part of the Context's request processing pipeline. If the valve is deployed globally, it must be declared in standalone.xml/domain.xml, as described in "Global Valve" section. If the valve is embedded with the application, it must be declared in jboss-web.xml, as described in "Context Valve" section.

Global Valve

A global valve is declared in standalone.xml as follows:

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" ...>
    <connector .../>

    <virtual-server name="default-host" ...>
       ...
    </virtual-server>

    <valve name="Global Valve" 
               module="io.novaordis.playground.jboss.jbossweb.global-jbossweb-valve" 
               class-name="io.novaordis.playground.jboss.jbossweb.valve.GlobalValve">
        <param param-name="someConfigurationParameter" param-value="some value"/>
    </valve>
</subsystem>

The valve code must be deployed as part of a JBoss module with the following dependencies in its module.xml:

<dependencies>
   <module name="org.slf4j"/>
   <module name="javax.api"/>
   <module name="javax.servlet.api"/>
   <module name="org.jboss.as.web"/>
</dependencies>

Code:

https://github.com/NovaOrdis/playground/tree/master/jboss/jbossweb/global-jbossweb-valve

Global Valve Configuration Parameters

A global valve can be configured with arbitrary parameters declared in the WildFly configuration file:

<valve ...>
    ...
    <param param-name="someConfigurationParameter" param-value="some value"/>
</valve>

The WildFly runtime will attempt to identify the corresponding mutator method setSomeConfigurationParameter(...) via reflection and invoke it with the value read from the configuration file.

Param names similar to "some-configuration-parameters" won't work (at least not with EAP 6.4.10).

Global Valve Initialization

Topology

Upon deployment, the valve is placed at the top of the Engine's pipeline. All default valves are placed after it.

Adding a Global Valve with CLI

Adding a Global Valve with CLI

Context Valve

A context valve is declared in jboss-web.xml as follows:

...

The valve code must be deployed as part of ...

Code:

TODO

Context Valve Configuration Parameters

A context valve can be configured with arbitrary parameters declared in the jboss-web.xml:

<valve ...>
    ...
    <param param-name="someConfigurationParameter" param-value="some value"/>
</valve>

The WildFly runtime will attempt to identify the corresponding mutator method setSomeConfigurationParameter(...) via reflection and invoke it with the value read from the configuration file.

Param names similar to "some-configuration-parameters" won't work (at least not with EAP 6.4.10).

Context Valve Initialization