public class JNDIObjectLocator extends Object implements Serializable
Implements the ServiceLocator design pattern.
Major features are:
Example:
locator = JNDIObjectLocator.builder().build();
MyEJB myEJB1 = locator.getObject(MyEJB.class);
MyEJB myEJB2 = locator.getObject("java:module/MyEJB");
Modifier and Type | Class and Description |
---|---|
static class |
JNDIObjectLocator.JNDIObjectLocatorBuilder
The builder of the
JNDIObjectLocator . |
Modifier and Type | Method and Description |
---|---|
static JNDIObjectLocator.JNDIObjectLocatorBuilder |
builder()
Returns the builder of the
JNDIObjectLocator . |
void |
clearCache()
Clears object cache.
|
<T> T |
getEnvEntry(String name)
Same as
JNDI.getEnvEntry(String) , except that this is cached. |
<T> T |
getObject(Class<T> beanClass)
Returns an object from JNDI based on beanClass.
|
<T> T |
getObject(String jndiName)
Returns an object based on JNDI name.
|
<T> T |
getObjectNoCache(String jndiName)
Return an object based on JNDI name, bypassing the cache.
|
String |
prependNamespaceIfNecessary(String fieldName)
Utility method used in matching fields to EJB injection points to try to find appropriate JNDI object to use for injection.
|
protected Object |
readResolve()
This deals with transient final fields correctly.
|
public static JNDIObjectLocator.JNDIObjectLocatorBuilder builder()
JNDIObjectLocator
.JNDIObjectLocator
.public <T> T getEnvEntry(String name)
JNDI.getEnvEntry(String)
, except that this is cached.T
- The expected return type.name
- the environment entry name relative to "java:comp/env".null
if there is none.ClassCastException
- When T
is of wrong type.JNDI.getEnvEntry(String)
public <T> T getObject(Class<T> beanClass)
T
- Object type.beanClass
- Type of object to look up in JNDI.null
if there is none.public <T> T getObject(String jndiName)
T
- The expected return type.jndiName
- The JNDI name of the object to be retrieved.null
if there is none.ClassCastException
- When T
is of wrong type.public <T> T getObjectNoCache(String jndiName)
T
- The expected return type.jndiName
- The JNDI name of the object to be retrieved.null
if there is none.ClassCastException
- When T
is of wrong type.public void clearCache()
public String prependNamespaceIfNecessary(String fieldName)
JNDI.JNDI_NAMESPACE_PREFIX
.fieldName
- The field name to prepend with this locator's name space if necessary.protected Object readResolve()
Copyright © 2012–2022 OmniFaces. All rights reserved.