FileDocCategorySizeDatePackage
OpenEjbFactory.javaAPI DocGlassfish v2 API3925Fri May 04 22:33:00 BST 2007org.apache.naming.factory

OpenEjbFactory

public class OpenEjbFactory extends Object implements ObjectFactory
Object factory for EJBs.
author
Jacek Laskowski
author
Remy Maucherat
version
$Revision: 1.3 $ $Date: 2007/05/05 05:33:00 $

Fields Summary
protected static final String
DEFAULT_OPENEJB_FACTORY
Constructors Summary
Methods Summary
public java.lang.ObjectgetObjectInstance(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)
Crete a new EJB instance using OpenEJB.

param
obj The reference object describing the DataSource



    // -------------------------------------------------- ObjectFactory Methods


                         
           
                                     
          

        Object beanObj = null;

        if (obj instanceof EjbRef) {

            Reference ref = (Reference) obj;

            String factory = DEFAULT_OPENEJB_FACTORY;
            RefAddr factoryRefAddr = ref.get("openejb.factory");
            if (factoryRefAddr != null) {
                // Retrieving the OpenEJB factory
                factory = factoryRefAddr.getContent().toString();
            }

            Properties env = new Properties();
            env.put(Context.INITIAL_CONTEXT_FACTORY, factory);

            RefAddr linkRefAddr = ref.get("openejb.link");
            if (linkRefAddr != null) {
                String ejbLink = linkRefAddr.getContent().toString();
                beanObj = (new InitialContext(env)).lookup(ejbLink);
            }

        }

        return beanObj;