Class JndiObjectLocator

  extended byorg.springframework.jndi.JndiAccessor
      extended byorg.springframework.jndi.JndiLocatorSupport
          extended byorg.springframework.jndi.JndiObjectLocator
All Implemented Interfaces:
Direct Known Subclasses:
AbstractJndiLocator, AbstractSlsbInvokerInterceptor, JndiObjectFactoryBean, JndiObjectTargetSource, JndiRmiClientInterceptor

public abstract class JndiObjectLocator
extends JndiLocatorSupport
implements InitializingBean

Convenient superclass for JNDI-based service locators. Subclasses are JavaBeans, exposing a "jndiName" property. This may or may not include the "java:comp/env/" prefix expected by J2EE applications when accessing a locally mapped (ENC - Environmental Naming Context) resource. If it doesn't, the "java:comp/env/" prefix will be prepended if the "resourceRef" property is true (the default is false) and no other scheme like "java:" is given.

Subclasses can invoke the lookup method whenever it is appropriate. Some classes might do this on initialization, while others might do it on demand. The latter strategy is more flexible in that it allows for initialization of the locator before the JNDI object is available.

Juergen Hoeller
See Also:
setJndiName(java.lang.String), JndiAccessor.setJndiTemplate(org.springframework.jndi.JndiTemplate), JndiAccessor.setJndiEnvironment(java.util.Properties), JndiLocatorSupport.setResourceRef(boolean), lookup()

Field Summary
Fields inherited from class org.springframework.jndi.JndiLocatorSupport
Fields inherited from class org.springframework.jndi.JndiAccessor
Constructor Summary
Method Summary
 void afterPropertiesSet()
          Check the jndiName property and initiate a lookup.
 String getJndiName()
          Return the JNDI name to look up.
protected  Object lookup()
          Perform the actual JNDI lookup via the JndiTemplate.
 void setJndiName(String jndiName)
          Set the JNDI name to look up.
Methods inherited from class org.springframework.jndi.JndiLocatorSupport
convertJndiName, isResourceRef, lookup, setResourceRef
Methods inherited from class org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public JndiObjectLocator()
Method Detail


public void setJndiName(String jndiName)
Set the JNDI name to look up. If it doesn't begin with "java:comp/env/" this prefix is added if resourceRef is set to true.

jndiName - JNDI name to look up
See Also:


public String getJndiName()
Return the JNDI name to look up.


public void afterPropertiesSet()
                        throws NamingException
Check the jndiName property and initiate a lookup.

The JNDI object will thus be fetched eagerly on initialization. For refreshing the JNDI object, subclasses can invoke lookup at any later time.

Specified by:
afterPropertiesSet in interface InitializingBean
See Also:


protected Object lookup()
                 throws NamingException
Perform the actual JNDI lookup via the JndiTemplate. Invokes the located method after successful lookup.

NamingException - if the JNDI lookup failed

Copyright (C) 2003-2004 The Spring Framework Project.