Top Description Fields Constructors Methods
org.springframework.jndi

public Class JndiLocatorDelegate

extends JndiLocatorSupport
Class Inheritance
Imports
javax.naming.InitialContext, .NamingException, org.springframework.core.SpringProperties, org.springframework.lang.Nullable

JndiLocatorSupport subclass with public lookup methods, for convenient use as a delegate.
Author
Juergen Hoeller
Since
3.0.1

Field Summary

Modifier and TypeField and Description
public static final String
IGNORE_JNDI_PROPERTY_NAME

System property that instructs Spring to ignore a default JNDI environment, i.e. to always return false from isDefaultJndiEnvironmentAvailable().

private static final boolean
Inherited from org.springframework.jndi.JndiLocatorSupport:
CONTAINER_PREFIX

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static JndiLocatorDelegate
createDefaultResourceRefLocator()

Configure a JndiLocatorDelegate with its "resourceRef" property set to true, meaning that all names will be prefixed with "java:comp/env/".

public static boolean

Returns:

true if a default InitialContext can be used, false if not
isDefaultJndiEnvironmentAvailable
()

Check whether a default JNDI environment, as in a Jakarta EE environment, is available on this JVM.

public Object
lookup(String
the JNDI name to look up
jndiName
)

Overrides org.springframework.jndi.JndiLocatorSupport.lookup.

Perform an actual JNDI lookup for the given name via the JndiTemplate.
public <T> T
lookup(String
the JNDI name to look up
jndiName
,
Class<T>
the required type of the object
requiredType
)

Overrides org.springframework.jndi.JndiLocatorSupport.lookup.

Perform an actual JNDI lookup for the given name via the JndiTemplate.
Inherited from org.springframework.jndi.JndiLocatorSupport:
convertJndiNameisResourceRefsetResourceRef

Field Detail

IGNORE_JNDI_PROPERTY_NAMEback to summary
public static final String IGNORE_JNDI_PROPERTY_NAME

System property that instructs Spring to ignore a default JNDI environment, i.e. to always return false from isDefaultJndiEnvironmentAvailable().

The default is "false", allowing for regular default JNDI access e.g. in JndiPropertySource. Switching this flag to true 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 the JndiLocatorDelegate.isDefaultJndiEnvironmentAvailable() check: in particular, StandardServletEnvironment and StandardPortletEnvironment.

Since
4.3
See Also
isDefaultJndiEnvironmentAvailable(), JndiPropertySource
shouldIgnoreDefaultJndiEnvironmentback to summary
private static final boolean shouldIgnoreDefaultJndiEnvironment

Constructor Detail

JndiLocatorDelegateback to summary
public JndiLocatorDelegate()

Method Detail

createDefaultResourceRefLocatorback to summary
public static JndiLocatorDelegate createDefaultResourceRefLocator()

Configure a JndiLocatorDelegate with its "resourceRef" property set to true, meaning that all names will be prefixed with "java:comp/env/".

See Also
setResourceRef
isDefaultJndiEnvironmentAvailableback to summary
public static boolean isDefaultJndiEnvironmentAvailable()

Check whether a default JNDI environment, as in a Jakarta EE environment, is available on this JVM.

Returns:boolean

true if a default InitialContext can be used, false if not

lookupback to summary
public Object lookup(String jndiName) throws NamingException

Overrides org.springframework.jndi.JndiLocatorSupport.lookup.

Doc from org.springframework.jndi.JndiLocatorSupport.lookup.

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".

Parameters
jndiName:String

the JNDI name to look up

Returns:Object

the obtained object

Annotations
@Override
Exceptions
NamingException:
if the JNDI lookup failed
lookupback to summary
public <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException

Overrides org.springframework.jndi.JndiLocatorSupport.lookup.

Doc from org.springframework.jndi.JndiLocatorSupport.lookup.

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".

Parameters
jndiName:String

the JNDI name to look up

requiredType:Class<T>

the required type of the object

Returns:T

the obtained object

Annotations
@Override
Exceptions
NamingException:
if the JNDI lookup failed