com.opensymphony.util
Class EJBUtils

java.lang.Object
  extended by com.opensymphony.util.EJBUtils

public class EJBUtils
extends Object

Utilities for Enterprise JavaBeans (and JNDI). This is a class contains static methods only and is not meant to be instantiated.

Version:
$Revision: 1.2 $
Author:
Joe Walnes, Hani Suleiman, Dion Almaer

Constructor Summary
EJBUtils()
           
 
Method Summary
static Object createStateless(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, String id)
          Utility method for attempting to find a specific entity bean given it's home interface and primary key.
static Context getRoot()
          Get root naming context (InitialContext).
static Object lookup(String location)
          Utility method for looking up an Object via JNDI.
static Object lookup(String location, Class classType)
          Utility method for looking up and narrowing an Object via JNDI.
static Object narrow(Object o, Class classType)
          Utility method for narrowing portable object to a class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EJBUtils

public EJBUtils()
Method Detail

getRoot

public static final Context getRoot()
                             throws NamingException,
                                    RemoteException
Get root naming context (InitialContext).

Throws:
NamingException
RemoteException
See Also:
InitialContext

createStateless

public static final Object createStateless(String location)
                                    throws Throwable
Method to lookup a stateless session EJB's home interface, and create an instance using the create() method. Any exceptions thrown by the create() method shall be rethrown (java.lang.Throwable).

Throws:
Throwable

findEntity

public static final javax.ejb.EJBObject findEntity(javax.ejb.EJBHome home,
                                                   String id)
                                            throws RemoteException,
                                                   javax.ejb.FinderException
Utility method for attempting to find a specific entity bean given it's home interface and primary key.

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);
 

Parameters:
home - Reference to entity home interface.
id - Value of primary key.
Returns:
Reference to EJBObject to be casted to desired type.
Throws:
RemoteException - Rethrown if thrown by finder method.
javax.ejb.FinderException - Rethrown if thrown by finder method.

findEntity

public static final javax.ejb.EJBObject findEntity(javax.ejb.EJBHome home,
                                                   int id)
                                            throws RemoteException,
                                                   javax.ejb.FinderException
Throws:
RemoteException
javax.ejb.FinderException
See Also:
findEntity(javax.ejb.EJBHome, String)

findEntity

public static final javax.ejb.EJBObject findEntity(javax.ejb.EJBHome home,
                                                   long id)
                                            throws RemoteException,
                                                   javax.ejb.FinderException
Throws:
RemoteException
javax.ejb.FinderException
See Also:
findEntity(javax.ejb.EJBHome, String)

lookup

public static final Object lookup(String location,
                                  Class classType)
                           throws NamingException,
                                  RemoteException
Utility method for looking up and narrowing an Object via JNDI. Used when using RMI-IIOP.

Throws:
NamingException
RemoteException
See Also:
lookup(String), narrow(Object, Class)

lookup

public static final Object lookup(String location)
                           throws NamingException,
                                  RemoteException
Utility method for looking up an Object via JNDI. Prefixes java:comp/env/ to location. If that is not found, it retries without the prefix.

Parameters:
location - JNDI location
Throws:
NamingException
RemoteException

narrow

public static final Object narrow(Object o,
                                  Class classType)
Utility method for narrowing portable object to a class


OSCore Project Page