I've been able to achieve this by binding to the MBean that represents the Host
and calling the Pipeline.addValve() method as shown here:
| ObjectName objectName = null;
| Object resource = null;
| Valve someValve = (Valve) new SomeValve();
| try {
| objectName = new
ObjectName("jboss.web:type=Host,host=localhost");
| resource = (Object) server.getAttribute(objectName,
"managedResource");
| if (resource != null && someValve != null) {
| StandardHost standardHost = (StandardHost) resource;
| standardHost.getPipeline().addValve(someValve);
| }
| else {
| //TODO Error Checking
| }
| }
| catch (Exception e) {
| //TODO Error Checking
| }
|
|
My MBean instanceates the valve in the start() lifecycle method and keeps a
reference to it so it can also call removeValve in the same fashion in the stop
lifecycle method. This way the valve is installed when the SAR (or MBean) is
deployed and uninstalled when the SAR is undeployed. Of course this can also be
controlled via the JMX console as well.
I did have to do a couple of other tricks... I had to move this code into a
utility class to avoid class loader issues (namely Valve and ValveBase aren't
available until Tomcat has started). I also had to set up a BarrierController
on Tomcat so I can make my MBean depend on Tomcat starting.
Hope this helps,
Josh Freeman
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3952460#3952460
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3952460
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user