I've thought about a JMX invoker into the web container but have not had a chance to look into it. I would be starting with the Tomcat 5 source however since its the more MBean friendly architecture.
I think I found in under TC5 - I'll post the details here when I have it verified.
Ok, I've found how to get the Container object for a web application using 3.2.4 or 4.0 and TC5. Here's a snippet:
InitialContext ic = new InitialContext(); RMIAdaptor rmiServer = (RMIAdaptor) ic.lookup("jmx/rmi/RMIAdaptor"); ObjectName name = new ObjectName("jboss.web:j2eeType=WebModule,name=//localhost/<web app name here>, J2EEApplication=none,J2EEServer=none"); org.apache.catalina.Manager manager = (org.apache.catalina.Manager) rmiServer.getAttribute(name, "manager"); org.apache.catalina.core.StandardContext container = (org.apache.catalina.core.StandardContext) manager.getContainer();
That will give you the Container object that has the prized invoke(request, response) method in it. However, I'm having a very hard time building my request; there doesn't seem to be a easy way to build it so that TC5 will recognize it and call the JSP/Servlet. In TC4, there was a base class for the Request objects, TC5 is full of wrappers on wrappers.
So, this is a question for any TC5 gurus out there: how can I correctly build my request object (and response for that matter) so that I can call Container.invoke(req, resp)?