Class JndiLocatorDelegate
- java.lang.Object
- org.springframework.jndi.JndiAccessor
- org.springframework.jndi.JndiLocatorSupport
- org.springframework.jndi.JndiLocatorDelegate
public class JndiLocatorDelegate extends JndiLocatorSupport
JndiLocatorSupport
subclass with public lookup methods, for convenient use as a delegate.- Since:
- 3.0.1
- Author:
- Juergen Hoeller
Field Summary
Fields Modifier and Type Field Description static String
IGNORE_JNDI_PROPERTY_NAME
System property that instructs Spring to ignore a default JNDI environment, i.e.Fields inherited from class org.springframework.jndi.JndiLocatorSupport
CONTAINER_PREFIX
Fields inherited from class org.springframework.jndi.JndiAccessor
logger
Constructor Summary
Constructors Constructor Description JndiLocatorDelegate()
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JndiLocatorDelegate
createDefaultResourceRefLocator()
Configure aJndiLocatorDelegate
with its "resourceRef" property set totrue
, meaning that all names will be prefixed with "java:comp/env/".static boolean
isDefaultJndiEnvironmentAvailable()
Check whether a default JNDI environment, as in a J2EE environment, is available on this JVM.Object
lookup(String jndiName)
Perform an actual JNDI lookup for the given name via the JndiTemplate.<T> T
lookup(String jndiName, Class<T> requiredType)
Perform an actual JNDI lookup for the given name via the JndiTemplate.Methods inherited from class org.springframework.jndi.JndiLocatorSupport
convertJndiName, isResourceRef, setResourceRef
Methods inherited from class org.springframework.jndi.JndiAccessor
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
Field Detail
IGNORE_JNDI_PROPERTY_NAME
public static final String IGNORE_JNDI_PROPERTY_NAME
System property that instructs Spring to ignore a default JNDI environment, i.e. to always returnfalse
fromisDefaultJndiEnvironmentAvailable()
.The default is "false", allowing for regular default JNDI access e.g. in
JndiPropertySource
. Switching this flag totrue
is an optimization for scenarios where nothing is ever to be found for such JNDI fallback searches to begin with, avoiding the repeated JNDI lookup overhead.Note that this flag just affects JNDI fallback searches, not explicitly configured JNDI lookups such as for a
DataSource
or some other environment resource. The flag literally just affects code which attempts JNDI searches based on theJndiLocatorDelegate.isDefaultJndiEnvironmentAvailable()
check: in particular,StandardServletEnvironment
andStandardPortletEnvironment
.- Since:
- 4.3
- See Also:
isDefaultJndiEnvironmentAvailable()
,JndiPropertySource
, Constant Field Values
Constructor Detail
JndiLocatorDelegate
public JndiLocatorDelegate()
Method Detail
lookup
public Object lookup(String jndiName) throws NamingException
Description copied from class:JndiLocatorSupport
Perform an actual JNDI lookup for the given name via the JndiTemplate.If the name doesn't begin with "java:comp/env/", this prefix is added if "resourceRef" is set to "true".
- Overrides:
lookup
in classJndiLocatorSupport
- Parameters:
jndiName
- the JNDI name to look up- Returns:
- the obtained object
- Throws:
NamingException
- if the JNDI lookup failed- See Also:
JndiLocatorSupport.setResourceRef(boolean)
lookup
public <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException
Description copied from class:JndiLocatorSupport
Perform an actual JNDI lookup for the given name via the JndiTemplate.If the name doesn't begin with "java:comp/env/", this prefix is added if "resourceRef" is set to "true".
- Overrides:
lookup
in classJndiLocatorSupport
- Parameters:
jndiName
- the JNDI name to look uprequiredType
- the required type of the object- Returns:
- the obtained object
- Throws:
NamingException
- if the JNDI lookup failed- See Also:
JndiLocatorSupport.setResourceRef(boolean)
createDefaultResourceRefLocator
public static JndiLocatorDelegate createDefaultResourceRefLocator()
Configure aJndiLocatorDelegate
with its "resourceRef" property set totrue
, meaning that all names will be prefixed with "java:comp/env/".
isDefaultJndiEnvironmentAvailable
public static boolean isDefaultJndiEnvironmentAvailable()
Check whether a default JNDI environment, as in a J2EE environment, is available on this JVM.- Returns:
true
if a default InitialContext can be used,false
if not