FileDocCategorySizeDatePackage
OpenEjbFactory.javaAPI DocApache Tomcat 6.0.142854Fri Jul 20 04:20:34 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: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $

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;