----- Original Message ----- From: "Martin Gainty" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Saturday, October 04, 2008 11:39 PM
Subject: RE: adding servlet definition to context on the fly :Tomcat 5.5



doctor john

to followup with the addChild method and if an exception is thrown and you determine your container doesnt support child containers..what then?

your diagnosis doctor..

Martin
---------------------------------------
I dont know the history... too young to remember TC 4 ;)
He probably lost his call when filters or something like that was introduced... but heres the coders explanation, perhaps it makes sense to you...
I just looked at what he was calling before... and its gone ;)
addChild is still functional in container... but in wrapper its an exception... some history here somewhere... risk one takes if they work outside the intended API... unless that is in the servlet spec... doubt it...

/**
* A <b>Wrapper</b> is a Container that represents an individual servlet
* definition from the deployment descriptor of the web application.  It
* provides a convenient mechanism to use Interceptors that see every single
* request to the servlet represented by this definition.
* <p>
* Implementations of Wrapper are responsible for managing the servlet life
* cycle for their underlying servlet class, including calling init() and
* destroy() at appropriate times, as well as respecting the existence of
* the SingleThreadModel declaration on the servlet class itself.
* <p>
* The parent Container attached to a Wrapper will generally be an
* implementation of Context, representing the servlet context (and
* therefore the web application) within which this servlet executes.
* <p>
* Child Containers are not allowed on Wrapper implementations, so the
* <code>addChild()</code> method should throw an
* <code>IllegalArgumentException</code>.
*
* @author Craig R. McClanahan
* @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
*/

--------------------.


From: [EMAIL PROTECTED]
To: users@tomcat.apache.org
Subject: Re: adding servlet definition to context on the fly :Tomcat 5.5
Date: Sat, 4 Oct 2008 21:20:39 +0200


----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <users@tomcat.apache.org>
Sent: Saturday, October 04, 2008 5:34 PM
Subject: adding servlet definition to context on the fly :Tomcat 5.5


> Hi,
> I had written some code to dynamically add a servlet to a context in a
> deployed applicaiton in Tomcat 4.1. This code basically uses the > catalina
> loader to obtain the server->engine->host->and context, and invokes the
> addChild method after configuring a StandardWwrapper to represent the
> servlet I am adding. This all works fine in Tomcat4.1 and I am able to
> access the servlet through the right url immediately, without having to
> restart Tomcat.

I'd luv to see that code... the stuff you playing with is in Tomcat core...
must have been difficult to debug... perhaps its an embedded app?

But I think this answers your question...

    public void addChild(Container child) {

        throw new IllegalStateException
            (sm.getString("standardWrapper.notChild"));

    }

    is what addChild now looks like in 6... if they did allow it, now they
dont (;

Dont think you can blame TC... whoever made that app was doing open heart
surgery ;)

I've never tried this, but its really interesting... I think I would start
by having a good look at...

    HttpServlet source code... its an abstract class with a little
introspection...

but I (think... maybe) that the way to go is to make a servlet... that does what HttpServlet servlet does... and then load your sevlet classes into your
servlet... and call them...

I (think... maybe) maybe that it will come down to doing your own servlet
mapping... and detection of new classes added... possibly your own uri to a
"manager" function...

ie I think you can make a servlet intelligent enough to do this... without
climbing into the engine and doing a liver transplant... and then because
you now inside the official API... this will never happen again.

In the end it will be something like
http://domain/contect/addons/ANY_ADD_ON_SERVLETS

... I'd give that a bash... dont think its a good idea trying the current
method even if you do find an open vein ;)

Good Luck...

---------------------------------------------------------------------------
HARBOR : http://www.kewlstuff.co.za/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
See it in Action : http://www.kewlstuff.co.za/cd_tut_swf/whatisejb1.htm
---------------------------------------------------------------------------


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


_________________________________________________________________
Get more out of the Web. Learn 10 hidden secrets of Windows Live.
http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns!550F681DAD532637!5295.entry?ocid=TXT_TAGLM_WL_domore_092008

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to