axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willy Dobé <willyd...@aol.com>
Subject Solution: End user service configuration via deployment descriptor
Date Thu, 31 Mar 2005 13:38:47 GMT
Hi all,

I found out myself and thought it might be helpful for others.

> Which class of the AXIS framework allows to access this information?
It's the MessageContext which can be obtainied from the AxisServer class.

   MessageContext mc = AxisServer.getCurrentMessageContext();

> Which methods do so?
To access values configured in the service element of the deployment 
descriptor, one have to obtain the SOAPService instance of the current 
message context and to call getProperty() on that.

   String value = mc.getService().getProperty(name);


For the customer database example posted earlier it would look like this:

   public class CustomerService {
     ...
     MessageContext mc = AxisServer.getCurrentMessageContext();
     String dbUrl      = mc.getService().getProperty("dbUrl");
     String dbUser     = mc.getService().getProperty("dbUser");
     String dbPassword = mc.getService().getProperty("dbPassword");
     ...
   }

Of course it's a good idea to delegate initialization to a singleton 
which reads the configuration on the first invocation of the service and 
preservs it for later invocations.

Have fun
Willy




willydobe@aol.com schrieb:
> Hello friends,
> 
> stand alone JAVA programs usually come with a configuration file that 
> allows the end user to tweak program's behavior. For example: programs 
> that use databases need connectivity parameters such as database URL, 
> user, password, ...
> 
> When having a web service instead of a simple JAVA program I thought the 
> deployment descriptor would be the right place to add configuration 
> params but I have no idea how to read the parameters' values from my 
> service implementation.
> 
> Example: Class CustomerDatabase implements a web service that grants 
> access to the corporate customer database over JDBC. Thus, 
> CustomerDatabase needs to read connectivity params configured in this 
> deployment descriptor:
> 
>   <deployment ...>
>     <service name="CustomerDatabase" ...>
>       <parameter name="dbUrl" value="jdbc:odbc:customerdb"/>
>       <parameter name="dbUser" value="CustomerDatabaseService"/>
>       <parameter name="dbPassword" value="secret"/>
>       ...
>       <parameter name="className" value="package.CustomerService"/>
>       <parameter name="allowedMethods" value="*"/>
>       ...
>     </service>
>   </deployment>
> 
> Which class of the AXIS framework allows to access this information? 
> Which methods do so?
> 
> Thanks for help
> Willy
> 


Mime
View raw message