The moose likes Spring and the fly likes how to retrieve resource Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Reply Bookmark "how to retrieve resource " Watch "how to retrieve resource " New topic
Author

how to retrieve resource

Manon Baratt
Ranch Hand

Joined: Jan 30, 2006
Posts: 58
Hi,

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"
name="env/dataServicesURI" />
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.

Thanks!!
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1282

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.

i,e.



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.


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: how to retrieve resource
 
Similar Threads
ejb-jar.xml (Help!)
How to deploy URLs like default URL provider in websphere
security issue
how to configure a JNDI URL resource
how to configure a JNDI URL resource