You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@ws.apache.org by "Life is hard, and then you die" <ro...@innovation.ch> on 2003/11/18 03:02:48 UTC

more strongly typed invoker

  Hi,

I would like to be able provide a handler and have the methods
automatically looked up, just like the Invoker does, but export
only a subset of the available methods, as defined by an interface
(the case I'm running into this is when the handlers are avalon
components - they implement various interfaces, but only one of them is
what I'd like to export as rpc methods). One minimal change to
accomplish this would be to add another constructor to
org.apache.xmlrpc.Invoker which takes both the targetObject and the
targetClass:

     /**
      * Create a new Invoker instance which limits the methods that can be
      * invoked on the target. The invoker will only invoke methods on the
      * given target which are defined as public in the given interface class.
      *
      * @param target the object on which to invoke the methods
      * @param iface  the exported methods that can be invoked
      */
     public Invoker(Object target, Class iface)
     {
        if (!iface.isInstance(target))
            throw new IllegalArgumentException("target " + target + " is not an instance of " + iface.getName());
         invokeTarget = target;
         targetClass = iface;
     }

Does this sound like a reasonable enhancement?


  Cheers,

  Ronald


Re: more strongly typed invoker

Posted by "Life is hard, and then you die" <ro...@innovation.ch>.
[Ryan Hoegg wrote:]
> I am CC'ing xmlrpc-dev@ , please follow up there.

Fine - wasn't sure which list would be most appropriate.

> This would be lovely, I have been musing over something like that for 
> months.  +1 from me.
> 
> One change to the idea that might be nice is to do the introspection 
> once at deployment time instead of on each call.

Getting all the methods and caching them isn't hard to do, but I'm not
entirely sure whether that buys you much - current JVM's already cache
the lookups, and I think the cost of the lookup is much smaller than
the actual method (except for trivial methods, of course).

> Using an interface is 
> a nice touch, I was thinking about using method attributes (using 
> commons-attributes or something else) or a separate XML deployment 
> descriptor.  Different use case :)

The advantage of an interface is that it can't get out of synch with
the object. And of course in my scenario I already have an interface
;-)  But I'm open to discussion.


  Cheers,

  Ronald


> Life is hard, and then you die wrote:
> 
> > Hi,
> >
> >I would like to be able provide a handler and have the methods
> >automatically looked up, just like the Invoker does, but export
> >only a subset of the available methods, as defined by an interface
> >(the case I'm running into this is when the handlers are avalon
> >components - they implement various interfaces, but only one of them is
> >what I'd like to export as rpc methods). One minimal change to
> >accomplish this would be to add another constructor to
> >org.apache.xmlrpc.Invoker which takes both the targetObject and the
> >targetClass:
> >
> >    /**
> >     * Create a new Invoker instance which limits the methods that can be
> >     * invoked on the target. The invoker will only invoke methods on the
> >     * given target which are defined as public in the given interface 
> >     class.
> >     *
> >     * @param target the object on which to invoke the methods
> >     * @param iface  the exported methods that can be invoked
> >     */
> >    public Invoker(Object target, Class iface)
> >    {
> >       if (!iface.isInstance(target))
> >           throw new IllegalArgumentException("target " + target + " is 
> >           not an instance of " + iface.getName());
> >        invokeTarget = target;
> >        targetClass = iface;
> >    }
> >
> >Does this sound like a reasonable enhancement?
> >
> >
> > Cheers,
> >
> > Ronald
> >
> > 
> >
> 

Re: more strongly typed invoker

Posted by Ryan Hoegg <rh...@isisnetworks.net>.
I am CC'ing xmlrpc-dev@ , please follow up there.

This would be lovely, I have been musing over something like that for 
months.  +1 from me.

One change to the idea that might be nice is to do the introspection 
once at deployment time instead of on each call.  Using an interface is 
a nice touch, I was thinking about using method attributes (using 
commons-attributes or something else) or a separate XML deployment 
descriptor.  Different use case :)

See you on the dev list,

--
Ryan Hoegg
ISIS Networks
http://www.isisnetworks.net

Life is hard, and then you die wrote:

>  Hi,
>
>I would like to be able provide a handler and have the methods
>automatically looked up, just like the Invoker does, but export
>only a subset of the available methods, as defined by an interface
>(the case I'm running into this is when the handlers are avalon
>components - they implement various interfaces, but only one of them is
>what I'd like to export as rpc methods). One minimal change to
>accomplish this would be to add another constructor to
>org.apache.xmlrpc.Invoker which takes both the targetObject and the
>targetClass:
>
>     /**
>      * Create a new Invoker instance which limits the methods that can be
>      * invoked on the target. The invoker will only invoke methods on the
>      * given target which are defined as public in the given interface class.
>      *
>      * @param target the object on which to invoke the methods
>      * @param iface  the exported methods that can be invoked
>      */
>     public Invoker(Object target, Class iface)
>     {
>        if (!iface.isInstance(target))
>            throw new IllegalArgumentException("target " + target + " is not an instance of " + iface.getName());
>         invokeTarget = target;
>         targetClass = iface;
>     }
>
>Does this sound like a reasonable enhancement?
>
>
>  Cheers,
>
>  Ronald
>
>  
>



Re: more strongly typed invoker

Posted by Ryan Hoegg <rh...@isisnetworks.net>.
I am CC'ing xmlrpc-dev@ , please follow up there.

This would be lovely, I have been musing over something like that for 
months.  +1 from me.

One change to the idea that might be nice is to do the introspection 
once at deployment time instead of on each call.  Using an interface is 
a nice touch, I was thinking about using method attributes (using 
commons-attributes or something else) or a separate XML deployment 
descriptor.  Different use case :)

See you on the dev list,

--
Ryan Hoegg
ISIS Networks
http://www.isisnetworks.net

Life is hard, and then you die wrote:

>  Hi,
>
>I would like to be able provide a handler and have the methods
>automatically looked up, just like the Invoker does, but export
>only a subset of the available methods, as defined by an interface
>(the case I'm running into this is when the handlers are avalon
>components - they implement various interfaces, but only one of them is
>what I'd like to export as rpc methods). One minimal change to
>accomplish this would be to add another constructor to
>org.apache.xmlrpc.Invoker which takes both the targetObject and the
>targetClass:
>
>     /**
>      * Create a new Invoker instance which limits the methods that can be
>      * invoked on the target. The invoker will only invoke methods on the
>      * given target which are defined as public in the given interface class.
>      *
>      * @param target the object on which to invoke the methods
>      * @param iface  the exported methods that can be invoked
>      */
>     public Invoker(Object target, Class iface)
>     {
>        if (!iface.isInstance(target))
>            throw new IllegalArgumentException("target " + target + " is not an instance of " + iface.getName());
>         invokeTarget = target;
>         targetClass = iface;
>     }
>
>Does this sound like a reasonable enhancement?
>
>
>  Cheers,
>
>  Ronald
>
>  
>