public final class JNDI extends Object
Utility class for simplifying some web related tasks that use JNDI under the hood, such as getting the
Note that the JSF spec defines one parameter that can optionally be defined via an env entry instead of the typical
ProjectStage.PROJECT_STAGE_JNDI_NAME. Mojarra defines an additional proprietary one:
|Modifier and Type||Method and Description|
Returns the named environment entry for the deployment component from where this is called.
Returns the named object from the default JNDI instance.
public static <T> T getEnvEntry(String name)
web.xmlassociated with the given
Note that the name used here is relative to "java:comp/env", which is exactly as it appears in
<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 in
Environment entries can also be injected using
T- The expected return type.
name- the environment entry name relative to "java:comp/env".
nullif there is none.
Tis of wrong type.
public static <T> T lookup(String name)
Copyright © 2012–2015 OmniFaces. All rights reserved.