Top Description Fields Constructors Methods
org.springframework.jndi

public abstract Class JndiObjectLocator

extends JndiLocatorSupport
implements InitializingBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.InitializingBean
Known Direct Subclasses
org.springframework.jndi.JndiObjectTargetSource, org.springframework.jndi.JndiObjectFactoryBean
Imports
javax.naming.NamingException, org.springframework.beans.factory.InitializingBean, org.springframework.lang.Nullable, org.springframework.util.Assert, .StringUtils

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 Jakarta EE 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.

Author
Juergen Hoeller
Since
1.1
See Also
setJndiName, setJndiTemplate, setJndiEnvironment, setResourceRef, lookup()

Field Summary

Modifier and TypeField and Description
private Class<?>
private String
Inherited from org.springframework.jndi.JndiLocatorSupport:
CONTAINER_PREFIX

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing 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.

public Class<?>
getExpectedType()

Return the type that the located JNDI object is supposed to be assignable to, if any.

public String
getJndiName()

Return the JNDI name to look up.

protected Object

Returns:

the located target object
lookup
()

Perform the actual JNDI lookup for this locator's target resource.

public void
setExpectedType(Class<?> expectedType)

Specify the type that the located JNDI object is supposed to be assignable to, if any.

public void
setJndiName(String
the JNDI name to look up
jndiName
)

Specify the JNDI name to look up.

Inherited from org.springframework.jndi.JndiLocatorSupport:
convertJndiNameisResourceReflookuplookupsetResourceRef

Field Detail

expectedTypeback to summary
private Class<?> expectedType
Annotations
@Nullable
jndiNameback to summary
private String jndiName
Annotations
@Nullable

Constructor Detail

JndiObjectLocatorback to summary
public JndiObjectLocator()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws IllegalArgumentException, NamingException

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Doc from org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Invoked by the containing 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.

Annotations
@Override
getExpectedTypeback to summary
public Class<?> getExpectedType()

Return the type that the located JNDI object is supposed to be assignable to, if any.

Annotations
@Nullable
getJndiNameback to summary
public String getJndiName()

Return the JNDI name to look up.

Annotations
@Nullable
lookupback to summary
protected Object lookup() throws NamingException

Perform the actual JNDI lookup for this locator's target resource.

Returns:Object

the located target object

Exceptions
NamingException:
if the JNDI lookup failed or if the located JNDI object is not assignable to the expected type
See Also
setJndiName, setExpectedType, lookup(String, Class)
setExpectedTypeback to summary
public void setExpectedType(Class<?> expectedType)

Specify the type that the located JNDI object is supposed to be assignable to, if any.

setJndiNameback to summary
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:String

the JNDI name to look up

See Also
setResourceRef