com.opensymphony.util
Class EJBUtils

java.lang.Object
  extended bycom.opensymphony.util.EJBUtils

public class EJBUtils
extends java.lang.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.1.1.1 $
Author:
Joe Walnes, Hani Suleiman, Dion Almaer

Constructor Summary
EJBUtils()
           
 
Method Summary
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
 
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 javax.naming.Context getRoot()
                                          throws javax.naming.NamingException,
                                                 java.rmi.RemoteException
Get root naming context (InitialContext).

Throws:
javax.naming.NamingException
java.rmi.RemoteException
See Also:
InitialContext

createStateless

public static final java.lang.Object createStateless(java.lang.String location)
                                              throws java.lang.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:
java.lang.Throwable

findEntity

public static final javax.ejb.EJBObject findEntity(javax.ejb.EJBHome home,
                                                   java.lang.String id)
                                            throws java.rmi.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:
java.rmi.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 java.rmi.RemoteException,
                                                   javax.ejb.FinderException
Throws:
java.rmi.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 java.rmi.RemoteException,
                                                   javax.ejb.FinderException
Throws:
java.rmi.RemoteException
javax.ejb.FinderException
See Also:
findEntity(javax.ejb.EJBHome, String)

lookup

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

Throws:
javax.naming.NamingException
java.rmi.RemoteException
See Also:
lookup(String), narrow(Object, Class)

lookup

public static final java.lang.Object lookup(java.lang.String location)
                                     throws javax.naming.NamingException,
                                            java.rmi.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:
javax.naming.NamingException
java.rmi.RemoteException

narrow

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


See www.opensymphony.com for more information.