public abstract class JndiObjectLocator extends JndiLocatorSupport implements InitializingBean
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.
setJndiName(java.lang.String)
,
JndiAccessor.setJndiTemplate(org.springframework.jndi.JndiTemplate)
,
JndiAccessor.setJndiEnvironment(java.util.Properties)
,
JndiLocatorSupport.setResourceRef(boolean)
,
lookup()
CONTAINER_PREFIX
logger
Constructor and Description |
---|
JndiObjectLocator() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , 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.
|
convertJndiName, isResourceRef, lookup, lookup, setResourceRef
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
public void setJndiName(String jndiName)
jndiName
- the JNDI name to look upJndiLocatorSupport.setResourceRef(boolean)
public String getJndiName()
public void setExpectedType(Class<?> expectedType)
public Class<?> getExpectedType()
public void afterPropertiesSet() throws IllegalArgumentException, NamingException
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, 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.
afterPropertiesSet
in interface InitializingBean
IllegalArgumentException
NamingException
protected Object lookup() throws NamingException
NamingException
- if the JNDI lookup failed or if the
located JNDI object is not assigable to the expected typesetJndiName(java.lang.String)
,
setExpectedType(java.lang.Class<?>)
,
JndiLocatorSupport.lookup(String, Class)