You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by Derek Brown <db...@emeta.com> on 2001/08/18 00:02:34 UTC

Provider class obtaining init params?

I haven't come across a clean way for the provider class I write (that
gets instantiated to implement the service) to obtain init parameters,
such as a server name and port that it needs to connect to in response
to a client method call.

It appears that RPCRouterServlet has access to the <init-param>
elements and their values, but the provider class is standalone,
without any servlet context.  Ideally there would be some
"setInitParams" the provider could implement to receive whatever init
params were defined in the XML file, but I haven't seen such a thing.

One solution that works is subclassing RPCRouterServlet; in the
constructor save a static reference to "this"; provide static accessor
methods (e.g., getSomeParam()) that would return the result of
calling getInitParameter() on the saved instance.  The provider class
can call those static accessor methods to obtain the init-param
values.

This works, but is a bit hack-y.  Is there a more elegant solution?

Thanks,
Derek