You are on page 1of 4

c(). Spring Jndi provides org. d(). 3.Spring JNDI: Template class/method automates certain work by internally performing set of operations in a sequence to complete the work. Spring Jndi programming: 1. lookup----) Close InitialContext object. EX: Normal Task Completion Task1 : a() b() c() d() Template method: public void xyz() { a(). Get JndiTemplate class object through dependency injection 2. Perform Jndi operations using that JndiTemplate class object Spring Jndi: Which allows to pass JNDI properties from Spring configuration file (which gives the flexibility of modification) 1 . 2. list. Plain JNDI programming: 1. Prepare JNDI properties Prepare InitialContext Object Perfrom JNDI operations (bind. 4. b(). While working with Spring JNDI we get abstraction layer on plain Jndi with simplifies the JNDI operations.sf.jndiTemplate class providing abstraction layer in plain JNDI and simplify JNDI operations. While working with plain Jndi we need to perform the entire programming of Jndi operations manually.

JndiTemplate class gives execute(-) to execute the logics related to Callback interface implementation classes. 2.java 4. For complete please refer JNDI\Spring JNDI\NetBeans7. For Complete program please refer JNDI\Spring JNDI\NetBeans7.naming.provider.java program 2 .1 projects\SpringJNDI(Weblogic)\src\java\ListOperationJndiCallbackInterface.jndi.naming.url Callback methods and interfaces: The methods which are called by the Container automatically are called as Callback methods. In the Plain JNDI programmer can use the constants of javax. The inrefaces which contains callback method is called as Callback interface.1 projects\SpringJNDI(Weblogic)\src\java\ListOperationJndiCallbackInterface.initialFactory Java. Example Application on Spring JNDI to implement list operation by using JndiCallback interface. The class that is acting as client application in Spring Bean is one concrete class we can take that class as Spring Bean and we can also perform dependency injections on the properties that class 3. While working with Spring JNDI it internally uses plain JNDI but as a programmer there is no need of dealing with Plain JNDI API. CONSTANT NAME CONTEXT_FACTORY PROVIDER_URL Its Value Factory.spring framework. Life cycle methods are also Callback methods Spring provides lots of Abstraction layer to make programmer implementing certain functionalities underlying plain technology when that functionality it not directly available in Spring environment.1.JndiCallback this interface gives one callback method called doInContext(Context ctx) represents the current context represented by JndiTemplate class obj. While working with Spring JNDI we must specify only their values as JNDI properties. The Spring JDNI provides Callback interface called org. main(-) is a static method so to use any variables directly in the main(-) they should be taken as static variables.ContextInterface file or its values. EX: In Spring JNDI environment list operation is not possible directly with JNID template class to make that operation possible and to gie chance to programmer to implement that functionality manually by using Plain JNDI API.

1 projects\SpringJNDI(Weblogic)\src\java\SubContextHavingBindings. Apache DBCP. With respect to code creation of one anonymous inner class implementing JndiCallback interface. 2.Example Application of Spring JNDI to create sub context having bindings using JndiCallback Interface support: For Complete Program please refer JNDI\Spring JNDI\NetBeans7. 1. 4. To overcome this problem we an use either third party Connection Pools or Server managed Connection pools in Spring applications. Q) What is the JDBC Connection Pool that we have in your Spring project? A) If Spring project is Standalone project running outside the server environment then use third party pools like C3PO. Object for anonymous inner class is created. execute method on template class is created having the above created Anonymous inner class object as argument value We should not use DriverManager class of Spring API for Connection Pooling in real time projects because it does not contain actually pool connection more over creates new connection object for every getConnection method call.java program Keep domain server in running mode. 3. In this anonymous inner class doInContext method is implemented having the logic of JNDI. If Spring project is deployable application in the Server like web application then use Server managed Connection Pool. 3 .