use of org.apache.openejb.BeanContext in project tomee by apache.
the class EjbHomeProxyHandler method createHomeProxy.
public static Object createHomeProxy(final BeanContext beanContext, final InterfaceType interfaceType, final List<Class> objectInterfaces, final Class mainInterface) {
if (!interfaceType.isHome()) {
throw new IllegalArgumentException("InterfaceType is not a Home type: " + interfaceType);
}
try {
final EjbHomeProxyHandler handler = createHomeHandler(beanContext, interfaceType, objectInterfaces, mainInterface);
final List<Class> proxyInterfaces = new ArrayList<>(2);
final Class homeInterface = beanContext.getInterface(interfaceType);
proxyInterfaces.add(homeInterface);
proxyInterfaces.add(IntraVmProxy.class);
if (BeanType.STATEFUL.equals(beanContext.getComponentType()) || BeanType.MANAGED.equals(beanContext.getComponentType())) {
proxyInterfaces.add(BeanContext.Removable.class);
}
return ProxyManager.newProxyInstance(proxyInterfaces.toArray(new Class[proxyInterfaces.size()]), handler);
} catch (final Exception e) {
throw new OpenEJBRuntimeException("Can't create EJBHome stub" + e.getMessage(), e);
}
}
use of org.apache.openejb.BeanContext in project tomee by apache.
the class EjbHomeProxyHandler method homeMethod.
/*-------------------------------------------------*/
/* Home interface methods */
/*-------------------------------------------------*/
protected Object homeMethod(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
checkAuthorization(method);
final BeanContext beanContext = getBeanContext();
if (beanContext.isAsynchronous(method)) {
return beanContext.getModuleContext().getAppContext().getAsynchronousPool().invoke(new CUCallable<Object>(new Callable<Object>() {
@Override
public Object call() throws Exception {
try {
return homeMethodInvoke(interfce, method, args);
} catch (final ApplicationException ae) {
logger.error("EjbHomeProxyHandler: Asynchronous call to '" + interfce.getSimpleName() + "' on '" + method.getName() + "' failed", ae);
throw ae;
}
}
}), method.getReturnType() == Void.TYPE);
} else {
return homeMethodInvoke(interfce, method, args);
}
}
use of org.apache.openejb.BeanContext in project tomee by apache.
the class EjbSelect method execute_void.
/**
* Perform a select operation when the return value is
* a void. This one is slightly different from the
* rest, as the container operation performed is an
* update() rather than a select() because there's
* no value to return.
*
* @param obj The ejb object we're executing on behalf of.
* @param methodSignature The signature of the selectxxxx method being invoked.
* @param args The arguments to the select. These need to match
* the method signature.
* @throws FinderException
*/
public static void execute_void(final Object obj, final String methodSignature, final Object... args) throws FinderException {
final BeanContext beanContext = (BeanContext) obj;
final Container container = beanContext.getContainer();
if (!(container instanceof CmpContainer)) {
throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
}
final CmpContainer cmpContainer = (CmpContainer) container;
cmpContainer.update(beanContext, methodSignature, args);
}
use of org.apache.openejb.BeanContext in project tomee by apache.
the class EjbSelect method execute_Object.
/**
* The single execution stub for all non-primitive
* select operations. This method has an additional
* returnType parameter used to instantiate the return
* value.
*
* @param obj The EJB object we're operating against.
* @param methodSignature The signature of the ejbSelectxxxx method.
* @param returnType The return type signature of the method.
* @param args The select arguments.
* @return An object of the specified type...which might be
* one of the collection types.
* @throws FinderException
*/
public static Object execute_Object(final Object obj, final String methodSignature, final String returnType, final Object... args) throws FinderException {
final BeanContext beanContext = (BeanContext) obj;
final Container container = beanContext.getContainer();
if (!(container instanceof CmpContainer)) {
throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
}
final CmpContainer cmpContainer = (CmpContainer) container;
return cmpContainer.select(beanContext, methodSignature, returnType, args);
}
use of org.apache.openejb.BeanContext in project tomee by apache.
the class EjbSelect method execute_char.
public static char execute_char(final Object obj, final String methodSignature, final Object... args) throws FinderException {
final BeanContext beanContext = (BeanContext) obj;
final Container container = beanContext.getContainer();
if (!(container instanceof CmpContainer)) {
throw new FinderException("Deployment is not connected to a CmpContainer " + beanContext.getDeploymentID());
}
final CmpContainer cmpContainer = (CmpContainer) container;
final Character result = (Character) cmpContainer.select(beanContext, methodSignature, "char", args);
return result;
}
Aggregations