I have a spring 3.0 application where I am calling a web service and I need to retrieve the base url value. I have defined a resource in spring-app-services.xml for the web service which includes the base url.
<bean name="client" class="com.xxx.clientImpl" p:baseUrl-ref="dataServicesURI"/>
The datServicesURI has been defined in my context.xml as
<ResourceLink global="env/dataServicesURI" type="java.lang.String"
and in web.xml and server.xml.
I am trying to retrieve the baseUrl-ref in my Java code. Please provide any suggestions on how to do it.
This is dirt simple in spring 3.1. With the introduction of property sources one is automatically introduced for you in web apps for JNDI. This means that your your JNDI variables are available through the Spring Environment . Also it is registered with the propertyPlaceholderConfigurer so if this bean is defined you can use the @Value annotation.
With Spring 3.0 not as easy you can have a look at JndiObjectFactoryBean / <jee:jndi-lookup> for using it in your context otherwise if you need it in your java code you are probably looking at a plain old vanilla jndi lookup.