Class JndiLocator
- Direct Known Subclasses:
JndiObjectFactory,JndiRealmFactory
Note that this implementation is an almost exact combined copy of the Spring Framework's 'JndiAccessor' and 'JndiLocatorSupport' classes from their 2.5.4 distribution - we didn't want to re-invent the wheel, but not require a full dependency on the Spring framework, nor does Spring make available only its JNDI classes in a small jar, or we would have used that. Since Shiro is also Apache 2.0 licensed, all regular licenses and conditions and authors have remained in tact.
- Since:
- 1.1
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringconvertJndiName(String jndiName) Convert the given JNDI name into the actual JNDI name to use.Return the JNDI environment to use for JNDI lookups.Return the JNDI template to use for JNDI lookups.booleanReturn whether the lookup occurs in a Jakarta EE container.protected ObjectPerform an actual JNDI lookup for the given name via the JndiTemplate.protected ObjectPerform an actual JNDI lookup for the given name via the JndiTemplate.voidsetJndiEnvironment(Properties jndiEnvironment) Set the JNDI environment to use for JNDI lookups.voidsetJndiTemplate(JndiTemplate jndiTemplate) Set the JNDI template to use for JNDI lookups.voidsetResourceRef(boolean resourceRef) Set whether the lookup occurs in a Jakarta EE container, i.e.
-
Field Details
-
CONTAINER_PREFIX
-
-
Constructor Details
-
JndiLocator
public JndiLocator()
-
-
Method Details
-
setJndiTemplate
Set the JNDI template to use for JNDI lookups.You can also specify JNDI environment settings via "jndiEnvironment".
- See Also:
-
getJndiTemplate
Return the JNDI template to use for JNDI lookups. -
setJndiEnvironment
Set the JNDI environment to use for JNDI lookups.Creates a JndiTemplate with the given environment settings.
- See Also:
-
getJndiEnvironment
Return the JNDI environment to use for JNDI lookups. -
setResourceRef
Set whether the lookup occurs in a Jakarta EE container, i.e. if the prefix "java:comp/env/" needs to be added if the JNDI name doesn't already contain it. Default is "false".Note: Will only get applied if no other scheme (e.g. "java:") is given.
-
isResourceRef
Return whether the lookup occurs in a Jakarta EE container. -
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- the JNDI name to look up- Returns:
- the obtained object
- Throws:
NamingException- if the JNDI lookup failed- See Also:
-
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- 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:
-
convertJndiName
Convert the given JNDI name into the actual JNDI name to use.The default implementation applies the "java:comp/env/" prefix if "resourceRef" is "true" and no other scheme (e.g. "java:") is given.
- Parameters:
jndiName- the original JNDI name- Returns:
- the JNDI name to use
- See Also:
-