Have a look at the

    RequestProcessorFactoryFactory



On Fri, Feb 12, 2010 at 4:08 PM, teemu kanstren <tkanst...@gmail.com> wrote:
> Hello all,
>
>  As I understand, each time a server receives an xmlrpc invocation a new
> object is created for the class registered to handle this. I do not wish to
> have this happen as it produces problems for me to map the invocations to
> any non-static objects especially if I have more than one xml-rpc server.
> From browsing some discussion earlier this month on the mailing list I
> gather that there is not much control provided in apache xmlrpc over this
> behaviour. In any case, I managed to hack something that seems to work and
> this is how I managed to address the issue, maybe it is of some help to
> anyone else who needs something similar..
>
> when starting the xmlrpc server I need to register a handler mapping that is
> used to find the classes to create and the methods to invoke:
>
> xmlRpcServer.setHandlerMapping(mapping);
>
> to have some control over object creation I then use my own handler mapping
> like this
>
> public class XmlRpcFooHandlerMapping implements XmlRpcHandlerMapping {
>  //this is set in the constructor and gets as a parameter the non-static
> object I wish to use..
>  private final XmlRpcFooHandler handler;
>
>  public XmlRpcFooHandlerMapping(XmlRpcFooHandler handler) {
>    this.handler = handler;
>  }
>
>  public XmlRpcHandler getHandler(String name) throws
> XmlRpcNoSuchHandlerException, XmlRpcException {
>    //.. here some simple checks on the name like it contains "Foo"..
>    return handler;
>  }
> }
>
> and the handler..
>
> public class XmlRpcFooHandler implements XmlRpcHandler {
>  //set this in the constructor and use in any way you like, it should be
> the same obejct for all invocations..
>  private final Foo foo;
>
>  public XmlRpcFooHandler(Foo foo) {
>    this.foo = foo;
>  }
>
> //here I inspire from the default implementation and use the TypeConverter
> class to conver the parameters..
> //since I know exactly the class (Foo.class) I wish to use, I can do lots of
> shortcuts such as expect method matching with just method names to be
> enough...
> }
>
> So thats it.. I hope it helps someone.
>
>  If someone can suggest something more elegant, point out some flaws in it
> or whatever I am happy to hear..
>
> Teemu
>



-- 
Germanys national anthem is the most boring in the world - how telling!

Reply via email to