tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costin Manolache <cos...@eng.sun.com>
Subject Re: suggestion for XMLMapper/Setparent
Date Mon, 31 Jul 2000 16:51:35 GMT
Hi Marcel,

I'll check in the patch, but I can't do it before weekend,
I have a lot of work. If anyone has more time please check it
in - I can work on tomcat only weekends and 1-2 hours
weekdays, and I want to finish what I started first.


I'm still not sure why you need to extend ContextManager.
Please give me more data - I think Interceptors should be
used for extending tomcat.

If all you need is start/stop some resident objects you can
use the serverInit/shutdown callbacks - i.e. implement a
ContextInterceptor and add your objects as normal
interceptors to the config.

The Context events will be cleaned up and you'll have
simpler interfaces, but for now I think this should work.
Take a look at server connectors ( the recent changes -
they now implement Interceptor and no longer have
"special" code in ContextManager )

If your resource has a service method but is not a servlet
you can use Handler.

Costin



Marcel Jansen wrote:

> I wasn't actually reviewing XmlMapper, but after subclassing
> ContextManager and trying to use the subclass with XmlMapper
> I stumbled onto this: given a class, a method and its arguments
> the XmlMapper code checks for existence and then executes.
>
> An example would be
> SomeInterceptorClass.getMethod("setContextManager", new Class[]
>  "SomeContextManagerSubclass } )
> is used to find the correct method in SetParent.end(..)
>
> however, the only defined method is
> Interceptor.setContextManager(ContextManager cm)
>
> and the above won't work because
>
> Interceptor.setContextManager(SomeContextManagerSubclass cm)
>
> is not defined.
> I'm sure there's a good reason why Class.getmethod doesn't
> take this into account, I'll include a patch.
>
> I've written a number of classes to implement the UPnP service
> discovery protocol
> (http://www.upnp.org/UPnPDevice_Architecture_1.0.htm chapter 1)
> and integrated it into tomcat. For this I needed resident/daemon objects
> that weren't servlets. I thought the best place to start and stop
> these objects was from a contextManager. The tomcat 3.1 code isn't
> always very extension friendly, too bad catalina isn't quite there yet.
>
> patch for SetParent:
>
> class SetParent extends XmlAction {
>     String childM;
>     public SetParent(String c) {
>         childM=c;
>     }
>
>     public void end( SaxContext ctx) throws Exception {
>
>         boolean found = false;
>         Class current;
>         Method m;
>
>         Stack st=ctx.getObjectStack();
>
>         Object obj=st.pop();
>         Object parent=st.peek();
>         st.push( obj ); // put it back
>
>         String parentC=parent.getClass().getName();
>         if (ctx.getDebug() > 0) ctx.log("Calling " +
> obj.getClass().getName() + "." + childM +
>                                         " " + parentC);
>
>         // --MJ-- checks for the arguments for methods, however,
> superclasses
>         // as arguments will also work
>         Class params[]=new Class[1];
>         if (paramT==null) {
>             current=parent.getClass();
>         } else {
>             current=Class.forName( paramT );
>         }
>
>         while (!found && current != null) {
>             params[0]=current;
>             try {
>                 m = obj.getClass().getMethod( childM, params );
>                 m.invoke(obj, new Object[] { parent} );
>                 found = true;
>             }
>             catch (NoSuchMethodException nsme) {
>                 current = current.getSuperclass();
>             }
>         }
>         if (!found)
>             throw new NoSuchMethodException(childM.toString());
>     }
> }
>
> Marcel
>
> -----Original Message-----
> From: Costin Manolache <cmanolache@yahoo.com>
> To: tomcat-dev@jakarta.apache.org <tomcat-dev@jakarta.apache.org>
> Date: Friday, July 28, 2000 16:34
> Subject: Re: suggestion for XMLMapper/Setparent
>
> >I'm glad someone is reviewing XMLMapper :-)
> >Can you give more details ( and maybe a patch )?
> >
> >Also, what kind of extension do you need to ContextManager?
> >
> >Costin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message