org.springframework.jndi
Class AbstractJndiLocator

java.lang.Object
  extended byorg.springframework.jndi.JndiAccessor
      extended byorg.springframework.jndi.JndiLocatorSupport
          extended byorg.springframework.jndi.JndiObjectLocator
              extended byorg.springframework.jndi.AbstractJndiLocator
All Implemented Interfaces:
InitializingBean

Deprecated. Derive from JndiObjectLocator instead, invoking the lookup method whenever the subclass needs it (instead of waiting for a "located" callback).

public abstract class AbstractJndiLocator
extends JndiObjectLocator

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 must implement the located method to cache the results of the JNDI lookup. They don't need to worry about error handling.

Assumptions: The resource obtained from JNDI can be cached.

Subclasses will often be used as singletons in a bean container. This sometimes presents a problem if that bean container pre-instantiates singletons, since this class does the JNDI lookup in its init method, but the resource being pointed to may not exist at that time, even though it may exist at the time of first usage. The solution is to tell the bean container not to pre-instantiate this object (i.e. lazily initialize it instead).

Author:
Rod Johnson, Juergen Hoeller
See Also:
located(java.lang.Object), JndiObjectLocator

Field Summary
 
Fields inherited from class org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIX
 
Fields inherited from class org.springframework.jndi.JndiAccessor
logger
 
Constructor Summary
AbstractJndiLocator()
          Deprecated.  
 
Method Summary
 void afterPropertiesSet()
          Deprecated. Check the "jndiName" property and initiate a lookup.
protected abstract  void located(Object jndiObject)
          Deprecated. Subclasses must implement this to cache the object this class has obtained from JNDI.
protected  Object lookup()
          Deprecated. Perform the actual JNDI lookup via the JndiTemplate.
 
Methods inherited from class org.springframework.jndi.JndiObjectLocator
getJndiName, setJndiName
 
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

AbstractJndiLocator

public AbstractJndiLocator()
Deprecated. 
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws NamingException
Deprecated. 
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
Overrides:
afterPropertiesSet in class JndiObjectLocator
Throws:
NamingException
See Also:
lookup()

lookup

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

Overrides:
lookup in class JndiObjectLocator
Throws:
NamingException - if the JNDI lookup failed
See Also:
located(java.lang.Object)

located

protected abstract void located(Object jndiObject)
Deprecated. 
Subclasses must implement this to cache the object this class has obtained from JNDI.

Parameters:
jndiObject - object successfully retrieved from JNDI


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