Class JndiObjectLocator
java.lang.Object
org.springframework.jndi.JndiAccessor
org.springframework.jndi.JndiLocatorSupport
org.springframework.jndi.JndiObjectLocator
- All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean
- Direct Known Subclasses:
JndiObjectFactoryBean, JndiObjectTargetSource
public abstract class JndiObjectLocator
extends JndiLocatorSupport
implements org.springframework.beans.factory.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 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
(for example, "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.
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class JndiLocatorSupport
CONTAINER_PREFIXFields inherited from class JndiAccessor
logger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidReturn the type that the located JNDI object is supposed to be assignable to, if any.Return the JNDI name to look up.protected Objectlookup()Perform the actual JNDI lookup for this locator's target resource.voidsetExpectedType(@Nullable Class<?> expectedType) Specify the type that the located JNDI object is supposed to be assignable to, if any.voidsetJndiName(@Nullable String jndiName) Specify the JNDI name to look up.Methods inherited from class JndiLocatorSupport
convertJndiName, isResourceRef, lookup, lookup, setResourceRefMethods inherited from class JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
-
Constructor Details
-
JndiObjectLocator
public JndiObjectLocator()
-
-
Method Details
-
setJndiName
-
getJndiName
-
setExpectedType
-
getExpectedType
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
IllegalArgumentExceptionNamingException
-
lookup
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 assignable to the expected type- See Also:
-