- java.lang.Object
- 
- org.omnifaces.util.JNDI
 
- 
 public final class JNDI extends Object Utility class for simplifying some web related tasks that use JNDI under the hood, such as getting the <env-entry>fromweb.xml.Note that the Faces spec defines one parameter that can optionally be defined via an env entry instead of the typical context/init parameter; ProjectStage.PROJECT_STAGE_JNDI_NAME. Mojarra defines an additional proprietary one: "java:comp/env/ClientStateSavingPassword".- Since:
- 1.6
- Author:
- Arjan Tijms
 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringJNDI_NAME_PREFIX_ENV_ENTRYJNDI name prefix for environment entries:java:comp/envstatic StringJNDI_NAMESPACE_APPLICATIONJNDI namespace to lookup local enterprise beans within the same application:java:appstatic StringJNDI_NAMESPACE_COMPONENTJNDI namespace to lookup components:java:compstatic StringJNDI_NAMESPACE_GLOBALJNDI namespace to lookup all enterprise beans:java:globalstatic StringJNDI_NAMESPACE_MODULEJNDI namespace to lookup local enterprise beans within the same module:java:modulestatic StringJNDI_NAMESPACE_PREFIXJNDI namespace prefix, including the colon:java:static PatternPATTERN_EJB_INTERFACE_SUFFIXPattern for local or remote suffix in EJB interface name.
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TgetEnvEntry(String name)Returns the named environment entry for the deployment component from where this is called.static StringguessJNDIName(Class<?> beanClass)Guess JNDI name of given bean class, which can be a local or remote EJB.static StringguessJNDIName(String className)Guess JNDI name of given fully-qualified class name.static <T> Tlookup(String name)Returns the named object from the default JNDI instance.
 
- 
- 
- 
Field Detail- 
JNDI_NAMESPACE_PREFIXpublic static final String JNDI_NAMESPACE_PREFIX JNDI namespace prefix, including the colon:java:- Since:
- 3.9
- See Also:
- Constant Field Values
 
 - 
JNDI_NAMESPACE_COMPONENTpublic static final String JNDI_NAMESPACE_COMPONENT JNDI namespace to lookup components:java:comp- Since:
- 3.9
- See Also:
- Constant Field Values
 
 - 
JNDI_NAMESPACE_GLOBALpublic static final String JNDI_NAMESPACE_GLOBAL JNDI namespace to lookup all enterprise beans:java:global- Since:
- 3.9
- See Also:
- Constant Field Values
 
 - 
JNDI_NAMESPACE_MODULEpublic static final String JNDI_NAMESPACE_MODULE JNDI namespace to lookup local enterprise beans within the same module:java:module- Since:
- 3.9
- See Also:
- Constant Field Values
 
 - 
JNDI_NAMESPACE_APPLICATIONpublic static final String JNDI_NAMESPACE_APPLICATION JNDI namespace to lookup local enterprise beans within the same application:java:app- Since:
- 3.9
- See Also:
- Constant Field Values
 
 - 
JNDI_NAME_PREFIX_ENV_ENTRYpublic static final String JNDI_NAME_PREFIX_ENV_ENTRY JNDI name prefix for environment entries:java:comp/env- Since:
- 3.9
- See Also:
- Constant Field Values
 
 - 
PATTERN_EJB_INTERFACE_SUFFIXpublic static final Pattern PATTERN_EJB_INTERFACE_SUFFIX Pattern for local or remote suffix in EJB interface name.
 
- 
 - 
Method Detail- 
getEnvEntrypublic static <T> T getEnvEntry(String name) Returns the named environment entry for the deployment component from where this is called. From within the web module this returns the<env-entry-value>of a<env-entry>inweb.xmlassociated with the given<env-entry-name>.Note that the name used here is relative to "java:comp/env", which is exactly as it appears in web.xml.Example: web.xml <env-entry> <cont>org.omnifaces.TEST_INTEGER</env-entry-name> <env-entry-type>java.lang.Integer</env-entry-type> <env-entry-value>10</env-entry-value> </env-entry>Lookup in Java using relative name Integer test = JNDI.getEnvEntry("org.omnifaces.TEST_INTEGER");Lookup in Java using full JNDI name Integer test = JNDI.lookup("java:comp/env/org.omnifaces.TEST_INTEGER");Note that even the "full JNDI name" is relative to the "deployment component" from which the lookup is done. To use a true global JNDI name an additional <lookup-name>should be specified inweb.xml.Environment entries can also be injected using Resource.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- the environment entry name relative to "java:comp/env".
- Returns:
- The environment entry value associated with the given name, or nullif there is none.
- Throws:
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.6
- See Also:
- InitialContext.lookup(String)
 
 - 
lookuppublic static <T> T lookup(String name) Returns the named object from the default JNDI instance.- Type Parameters:
- T- The expected return type.
- Parameters:
- name- the name of the object to be retrieved
- Returns:
- the named object, or nullif there is none.
- Throws:
- ClassCastException- When- Tis of wrong type.
- Since:
- 1.6
- See Also:
- InitialContext.lookup(String)
 
 - 
guessJNDINamepublic static String guessJNDIName(Class<?> beanClass) Guess JNDI name of given bean class, which can be a local or remote EJB.- Parameters:
- beanClass- The bean class to guess JNDI name for.
- Returns:
- The guessed JNDI name of the given bean class.
- Since:
- 3.9
 
 
- 
 
-