Class JndiObjectLocator
- java.lang.Object
- org.springframework.jndi.JndiAccessor
- org.springframework.jndi.JndiLocatorSupport
- org.springframework.jndi.JndiObjectLocator
- All Implemented Interfaces:
InitializingBean
- Direct Known Subclasses:
AbstractSlsbInvokerInterceptor
,JndiObjectFactoryBean
,JndiObjectTargetSource
,JndiRmiClientInterceptor
public abstract class JndiObjectLocator extends JndiLocatorSupport implements InitializingBean
Convenient superclass for JNDI-based service locators, providing configurable lookup of a specific JNDI resource.Exposes a
"jndiName"
property. This may or may not include the "java:comp/env/" prefix expected by J2EE applications when accessing a locally mapped (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 (e.g. "java:") is given.Subclasses may 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.
Field Summary
Fields inherited from class org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIX
Fields inherited from class org.springframework.jndi.JndiAccessor
logger
Constructor Summary
Constructors Constructor Description JndiObjectLocator()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.Class<?>
getExpectedType()
Return the type that the located JNDI object is supposed to be assignable to, if any.String
getJndiName()
Return the JNDI name to look up.protected Object
lookup()
Perform the actual JNDI lookup for this locator's target resource.void
setExpectedType(Class<?> expectedType)
Specify the type that the located JNDI object is supposed to be assignable to, if any.void
setJndiName(String jndiName)
Specify the JNDI name to look up.Methods inherited from class org.springframework.jndi.JndiLocatorSupport
convertJndiName, isResourceRef, lookup, lookup, setResourceRef
Methods inherited from class org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
Constructor Detail
JndiObjectLocator
public JndiObjectLocator()
Method Detail
setJndiName
public void setJndiName(String jndiName)
Specify the JNDI name to look up. If it doesn't begin with "java:comp/env/" this prefix is added automatically if "resourceRef" is set to "true".- Parameters:
jndiName
- the JNDI name to look up- See Also:
JndiLocatorSupport.setResourceRef(boolean)
getJndiName
public String getJndiName()
Return the JNDI name to look up.
setExpectedType
public void setExpectedType(Class<?> expectedType)
Specify the type that the located JNDI object is supposed to be assignable to, if any.
getExpectedType
public Class<?> getExpectedType()
Return the type that the located JNDI object is supposed to be assignable to, if any.
afterPropertiesSet
public void afterPropertiesSet() throws IllegalArgumentException, NamingException
Description copied from interface:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
IllegalArgumentException
NamingException
lookup
protected Object lookup() throws NamingException
Perform the actual JNDI lookup for this locator's target resource.- Returns:
- the located target object
- Throws:
NamingException
- if the JNDI lookup failed or if the located JNDI object is not assigable to the expected type- See Also:
setJndiName(java.lang.String)
,setExpectedType(java.lang.Class<?>)
,JndiLocatorSupport.lookup(String, Class)