You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Frizzell <mi...@gmail.com> on 2006/04/27 20:15:08 UTC

Embedded Tomcat - adding constructed Servlet to Container

My application does runtime loading of plugins based on a xml file much like
Tomcat does. It also runs an embedded Tomcat server. I would like one of my
plugins to be a ServletPlugin. ServletPlugin extends HttpServlet and
implements my personal Plugin interface. Much like Tomcat, it loads the
plugin object at run time, firing it's default constructor as well as a
handful of functions on the Plugin interface. I then want to hand the
ServletPlugin to my embedded Tomcat with a simple servlet mapping to have it
respond to request coming in from that venue.

I tried digging through what happens when it reads the web.xml file and was
quickly overwhelmed with the whole rule-based approach. I imagine it's
awesome for what it does, just a nightmare for me to follow. Any
suggestions? A book to buy? a phrase to google? Thanks!

Re: Embedded Tomcat - adding constructed Servlet to Container

Posted by Bill Barker <wb...@wilshire.com>.
If you are using JMX-embedding, it will be a PITA.  So I'll assume that you 
are using the old-school Embedded class (the process is the same for 
JMX-embedding, you just need to do most operations via reflection).

     Wrapper wrapper = context.createWrapper();
     wrapper.setName("plugin");
     wrapper.setServletClass("com.myfirm.mypackage.ServletPlugin");
     // additional Wrapper stuff, like load-on-startup here.
     context.addChild(wrapper);
     context.addServletMapping("/plugin", "plugin");

"Mike Frizzell" <mi...@gmail.com> wrote in message 
news:7a8ea7510604271115n7b34356cnd65e51ee8d8d1d2e@mail.gmail.com...
My application does runtime loading of plugins based on a xml file much like
Tomcat does. It also runs an embedded Tomcat server. I would like one of my
plugins to be a ServletPlugin. ServletPlugin extends HttpServlet and
implements my personal Plugin interface. Much like Tomcat, it loads the
plugin object at run time, firing it's default constructor as well as a
handful of functions on the Plugin interface. I then want to hand the
ServletPlugin to my embedded Tomcat with a simple servlet mapping to have it
respond to request coming in from that venue.

I tried digging through what happens when it reads the web.xml file and was
quickly overwhelmed with the whole rule-based approach. I imagine it's
awesome for what it does, just a nightmare for me to follow. Any
suggestions? A book to buy? a phrase to google? Thanks!




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org