use of org.apache.naming.EjbRef in project tomcat by apache.
the class OpenEjbFactory method getObjectInstance.
// -------------------------------------------------- ObjectFactory Methods
/**
* Create a new EJB instance using OpenEJB.
*
* @param obj The reference object describing the DataSource
*/
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
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;
}
use of org.apache.naming.EjbRef in project Payara by payara.
the class OpenEjbFactory method getObjectInstance.
// -------------------------------------------------- ObjectFactory Methods
/**
* Crete a new EJB instance using OpenEJB.
*
* @param obj The reference object describing the DataSource
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
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;
}
Aggregations