Creating your own valve is really simple using NetBeans 7.2.1 along with Apache Maven.
- Create a Maven Java Application.
- Add the following dependency:
- Create your Java class and extend it from ValveBase.
- Implement
invoke(Request request, Response response) - Build your library (.jar) file
- Install the library in the ${tomcat.home}/lib directory.
- Configure
server.xmlto use your new Valve. For example:
- Start the server to see your new valve in action
ProcessingValve.java
Here is the output...INFO: Server startup in 1442 ms Dec 27, 2012 5:54:01 PM com.bluelotussoftware.tomcat.ProcessingValve invoke INFO: Header --> host Value --> localhost:8080 Dec 27, 2012 5:54:01 PM com.bluelotussoftware.tomcat.ProcessingValve invoke INFO: Header --> host Value --> localhost:8080 Dec 27, 2012 5:54:01 PM com.bluelotussoftware.tomcat.ProcessingValve invoke INFO: Header --> host Value --> localhost:8080 Dec 27, 2012 5:54:01 PM com.bluelotussoftware.tomcat.ProcessingValve invoke INFO: Header --> host Value --> localhost:8080
As you can see it was very easy to implement. Here is the code for my example: valve-example.zip
The source can also be found on Bitbucket: valve-example
2 comments:
Post a Comment