public class JndiLocatorDelegate extends JndiLocatorSupport
JndiLocatorSupport
subclass with public lookup methods,
for convenient use as a delegate.Modifier and Type | Field and Description |
---|---|
static String |
IGNORE_JNDI_PROPERTY_NAME
System property that instructs Spring to ignore a default JNDI environment, i.e.
|
CONTAINER_PREFIX
logger
Constructor and Description |
---|
JndiLocatorDelegate() |
Modifier and Type | Method and Description |
---|---|
static JndiLocatorDelegate |
createDefaultResourceRefLocator()
Configure a
JndiLocatorDelegate with its "resourceRef" property set to
true , 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.
|
convertJndiName, isResourceRef, setResourceRef
getJndiEnvironment, getJndiTemplate, setJndiEnvironment, setJndiTemplate
public static final String IGNORE_JNDI_PROPERTY_NAME
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
.
isDefaultJndiEnvironmentAvailable()
,
JndiPropertySource
,
Constant Field Valuespublic Object lookup(String jndiName) throws NamingException
JndiLocatorSupport
If the name doesn't begin with "java:comp/env/", this prefix is added if "resourceRef" is set to "true".
lookup
in class JndiLocatorSupport
jndiName
- the JNDI name to look upNamingException
- if the JNDI lookup failedJndiLocatorSupport.setResourceRef(boolean)
public <T> T lookup(String jndiName, Class<T> requiredType) throws NamingException
JndiLocatorSupport
If the name doesn't begin with "java:comp/env/", this prefix is added if "resourceRef" is set to "true".
lookup
in class JndiLocatorSupport
jndiName
- the JNDI name to look uprequiredType
- the required type of the objectNamingException
- if the JNDI lookup failedJndiLocatorSupport.setResourceRef(boolean)
public static JndiLocatorDelegate createDefaultResourceRefLocator()
JndiLocatorDelegate
with its "resourceRef" property set to
true
, meaning that all names will be prefixed with "java:comp/env/".public static boolean isDefaultJndiEnvironmentAvailable()
true
if a default InitialContext can be used,
false
if not