tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marcel Jansen" <>
Subject Re: suggestion for XMLMapper/Setparent
Date Mon, 31 Jul 2000 08:34:27 GMT
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
( 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) {

    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,
        // as arguments will also work
        Class params[]=new Class[1];
        if (paramT==null) {
        } else {
            current=Class.forName( paramT );

        while (!found && current != null) {
            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());


-----Original Message-----
From: Costin Manolache <>
To: <>
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?

View raw message