Spring JNDI provider

Spring JNDI provider

Created: 27/Oct/05 08:36 AM   Updated: 22/Jul/06 04:49 AM
Component/s: SpringCORE
Affects Version/s: 1.2.5
Fix Version/s: None

 

Time Tracking:
Not Specified

 

File Attachments: 1. SpringContext.java (18 kb)
2. SpringInitialContextFactory.java (3 kb)
3. springURLContextFactory.java (4 kb)

 

Virtual Machine: Sun JVM - 1.4.2

 

 Description   « Hide
Spring cannot be used through JNDI. I have developped a Spring JNDI provider. It has been tested against Tomcat 4.1.31, WebLogic 8.1 and JBoss 3.2 and 4.0.

The principe is the following: if you want to load a Bean from an ApplicationContext, use the Bean name prefixed by spring:.
In your jndi.properties, you shoud have set:
java.naming.factory.url.pkgs=org.springframework.jndi
 and optionaly:
org.springframework.jndi.url=path to the application context file definition. If this value is not specified, then the value is extracted from Context.URL (java.naming.provider.url).
If none are found, the value of applicationContext.xml is used.

So accessing a Bean from Spring is now done through the following code:
MyInterface obj = (new InitialContext()).lookup(beanName);

which make your application completely independant from Spring !!!!

你可能感兴趣的:(java,spring,tomcat,bean,weblogic)