Hi Iain,

I had to do something similar to allow a pre-configured object to be used by spring.

The best answer for you is to use the PropertyHandlerMapping in conjunction with either the RequestSpecificProcessorFactoryFactory or StatelessRequestProcessorFactoryFactory interfaces.

I have what is necessary documented for Spring on my blog http://www.hanhuy.com/pfn/ws-xmlrpc-and-spring

You should be able to figure out something similar based on that.
(Basically, you will implement your own ProcessorFactoryFactory within your servlet, and then return the desired bean from within the factory disregarding the input. You will still need to use something like PropertyHandlerMapping in order to register the processor with the server.)

Iain Bullard wrote:
After sending the previous email I spent quite some time working on the
problem and it turns out the terms
I was using were not quite correct - let me explain some more....

Having a persistent object within my servlet is quite straight forward, its
getting that object to
the xml-rpc handler that is the problem. A better way of stating my question
would be:

"how do I pass (persistent) objects to my handler methods from my servlet
class"

I have followed the example in the FAQ entitled "How to I get the clients IP
address in a handler?"
but I cannot get it to compile correctly as the class
RequestInitializableRequestProcessor does not exist.
Errors from compiling the example code:
~>javac @sourcefiles

cannot find symbol
symbol: class RequestInitializableRequestProcessor
                       RequestInitializableRequestProcessor proc =
                       ^
MyXmlRpcServlet.java:65: cannot find symbol
symbol: class RequestInitializableRequestProcessor
                               (RequestInitializableRequestProcessor)
super.newRequestProcessor(pClass, pRequest);
                                ^
MyXmlRpcServlet.java:65: cannot find symbol
symbol  : method
newRequestProcessor(java.lang.Class,org.apache.xmlrpc.XmlRpcRequest)
location: class
org.apache.xmlrpc.server.RequestProcessorFactoryFactory.RequestSpecificProcessorFactoryFactory
                               (RequestInitializableRequestProcessor)
super.newRequestProcessor(pClass, pRequest);

^
MyXmlRpcServlet.java:70:
setRequestProcessorFactoryFactory(org.apache.xmlrpc.server.RequestProcessorFactoryFactory)
in org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping cannot be
applied to (org.apache.xmlrpc.server.PropertyHandlerMapping)
               mapping.setRequestProcessorFactoryFactory(mapping);
                      ^

At first I thought I had just not imported this class correctly from the 3.0
release, so I downloaded the source code and
searched for the class, alas it was not there. My next thought was "maybe
its in the svn repository still.." So I got the latest source code from the
svn and then ran the following commands:

~/src/xmlrpc-svn/trunk> find . -name
RequestInitializableRequestProcessor.java
~/src/xmlrpc-svn/trunk> find . -name *.java -exec grep -i
RequestInitializableRequestProcessor {} \;

These commands both produce no output and that suggests to me that there is
no file called RequestInitializableRequestProcessor.java within the source
tree nor is there any mention of it within any of the other java files.

In fact, the only place that it is mentioned within the svn repository is
the faq file. So... If someone would be able to help me,
how can I easily pass objects to my handler methods - or is there some other
way recommended way of doing this?

If I get this working correctly I will write up an example for the FAQ aimed
at people who are not as familiar with the xml-rpc source.

Thanks again for your time,

Iain.

On 10/27/06, Ryan Mitchell <[EMAIL PROTECTED]> wrote:

Everything you describe is very common and has been solved a million
times over, and are not particular to xml-rpc.  Google for articles &
tutorials on multi-tier web development with Java.  What you probably
want is an "application server", e.g. Apache Tomcat, that will provide
things like database connection pooling for you.   If you don't want
something so heavy-weight, there are stand-alone libraries to do the
same (look through Apache website).  Maybe look at Hibernate, which I
mention because you had the keywords "persistent object" in your post.

--Ryan

Iain Bullard wrote:
> Hello everyone,
>
> I need to access a (thread safe) persistent object from my xmlrpc
> servlet. I
> am currently using the
> ServletWebServer with ws-xmlrpc 3.0, I have noticed that a class
> specified
> in the XmlRpcServlet.properties
> will get initialised each time an xml-rpc request is made to it - is it
> possible to initialise some before objects and
> pass them to all my servlets init() method?
>
> In short: what is the easiest way to allow the servlet classes to access
> persistent objects and are there any examples?
>
> I would ideally like to be able to reuse a pool of existing database
> connections, which (in my mind anyway)
> would appear to be a fairly common task for an xml-rpc based server.
> As the
> concept of spawning a new db
> connection for each xml-rpc request is incredibly inefficient.
>
> Thanks,
>
> Iain.
>


--
Ryan Mitchell
Engineering Development
LogiTel Corp.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to