public class EJBUtils
extends java.lang.Object
Constructor and Description |
---|
EJBUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
createStateless(java.lang.String location)
Method to lookup a stateless session EJB's home interface, and create
an instance using the create() method.
|
static javax.ejb.EJBObject |
findEntity(javax.ejb.EJBHome home,
int id) |
static javax.ejb.EJBObject |
findEntity(javax.ejb.EJBHome home,
long id) |
static javax.ejb.EJBObject |
findEntity(javax.ejb.EJBHome home,
java.lang.String id)
Utility method for attempting to find a specific entity bean given it's home
interface and primary key.
|
static javax.naming.Context |
getRoot()
Get root naming context (InitialContext).
|
static java.lang.Object |
lookup(java.lang.String location)
Utility method for looking up an Object via JNDI.
|
static java.lang.Object |
lookup(java.lang.String location,
java.lang.Class classType)
Utility method for looking up and narrowing an Object via JNDI.
|
static java.lang.Object |
narrow(java.lang.Object o,
java.lang.Class classType)
Utility method for narrowing portable object to a class
|
public static final javax.naming.Context getRoot() throws javax.naming.NamingException, java.rmi.RemoteException
javax.naming.NamingException
java.rmi.RemoteException
InitialContext
public static final java.lang.Object createStateless(java.lang.String location) throws java.lang.Throwable
java.lang.Throwable
public static final javax.ejb.EJBObject findEntity(javax.ejb.EJBHome home, java.lang.String id) throws java.rmi.RemoteException, javax.ejb.FinderException
Attempts to call the following methods in order:
home.findByPrimaryKey(int id); home.findByPrimaryKey(long id); home.findByPrimaryKey(Integer id); home.findByPrimaryKey(Long id); home.findByPrimaryKey(String id);
home
- Reference to entity home interface.id
- Value of primary key.EJBObject
to be casted to desired type.java.rmi.RemoteException
- Rethrown if thrown by finder method.javax.ejb.FinderException
- Rethrown if thrown by finder method.public static final javax.ejb.EJBObject findEntity(javax.ejb.EJBHome home, int id) throws java.rmi.RemoteException, javax.ejb.FinderException
java.rmi.RemoteException
javax.ejb.FinderException
findEntity(javax.ejb.EJBHome, String)
public static final javax.ejb.EJBObject findEntity(javax.ejb.EJBHome home, long id) throws java.rmi.RemoteException, javax.ejb.FinderException
java.rmi.RemoteException
javax.ejb.FinderException
findEntity(javax.ejb.EJBHome, String)
public static final java.lang.Object lookup(java.lang.String location, java.lang.Class classType) throws javax.naming.NamingException, java.rmi.RemoteException
javax.naming.NamingException
java.rmi.RemoteException
lookup(String)
,
narrow(Object, Class)
public static final java.lang.Object lookup(java.lang.String location) throws javax.naming.NamingException, java.rmi.RemoteException
java:comp/env/
to location
. If that is not found, it retries without the prefix.location
- JNDI locationjavax.naming.NamingException
java.rmi.RemoteException
public static final java.lang.Object narrow(java.lang.Object o, java.lang.Class classType)