use of org.jboss.weld.ejb.api.SessionObjectReference in project Payara by payara.
the class EjbServicesImpl method resolveEjb.
/**
* Request a reference to an EJB session object from the container. If the
* EJB being resolved is a stateful session bean, the container should
* ensure the session bean is created before this method returns.
*
* @param ejbDescriptor the ejb to resolve
* @return a reference to the session object
*/
@Override
public SessionObjectReference resolveEjb(EjbDescriptor<?> ejbDescriptor) {
SessionObjectReference sessionObj = null;
// All we need to do is create a reference based on one of the beans'
// client views, so just choose one and get its corresponding portable
// JNDI name.
String globalJndiName = getDefaultGlobalJndiName(ejbDescriptor);
if (globalJndiName != null) {
try {
InitialContext ic = new InitialContext();
Object ejbRef = ic.lookup(globalJndiName);
EjbContainerServices containerServices = services.getService(EjbContainerServices.class);
sessionObj = new SessionObjectReferenceImpl(containerServices, ejbRef);
} catch (NamingException ne) {
throw new IllegalStateException("Error resolving session object reference for ejb name " + ejbDescriptor.getBeanClass() + " and jndi name " + globalJndiName, ne);
}
} else {
throw new IllegalArgumentException("Not enough type information to resolve ejb for " + " ejb name " + ejbDescriptor.getBeanClass());
}
return sessionObj;
}
Aggregations