use of org.apache.openejb.core.cmp.CmpContainer in project tomee by apache.
the class EjbSelect method execute_byte.
public static byte execute_byte(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 Number result = (Number) cmpContainer.select(beanContext, methodSignature, "byte", args);
return result.byteValue();
}
use of org.apache.openejb.core.cmp.CmpContainer in project tomee by apache.
the class EjbSelect method execute_short.
public static short execute_short(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 Number result = (Number) cmpContainer.select(beanContext, methodSignature, "short", args);
return result.shortValue();
}
use of org.apache.openejb.core.cmp.CmpContainer in project tomee by apache.
the class EjbSelect method execute_float.
public static float execute_float(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 Number result = (Number) cmpContainer.select(beanContext, methodSignature, "float", args);
return result.floatValue();
}
use of org.apache.openejb.core.cmp.CmpContainer in project tomee by apache.
the class Cmp2Util method getEjbProxy.
public static <Proxy extends EJBLocalObject> Proxy getEjbProxy(final BeanContext beanContext, final EntityBean entity) {
if (entity == null) {
return null;
}
// build the primary key
final Object primaryKey = getPrimaryKey(beanContext, entity);
// get the cmp container
if (!(beanContext.getContainer() instanceof CmpContainer)) {
throw new IllegalArgumentException("Proxy is not connected to a CMP container but is conect to " + beanContext.getContainer().getClass().getName());
}
final Proxy proxy = (Proxy) EjbObjectProxyHandler.createProxy(beanContext, primaryKey, InterfaceType.EJB_LOCAL_HOME, beanContext.getLocalInterface());
return proxy;
}
use of org.apache.openejb.core.cmp.CmpContainer in project tomee by apache.
the class Cmp2Util method getEntityBean.
public static <Bean extends EntityBean> Bean getEntityBean(final EJBObject proxy) {
if (proxy == null) {
return null;
}
final EjbObjectProxyHandler handler = (EjbObjectProxyHandler) ProxyManager.getInvocationHandler(proxy);
if (handler.container == null) {
return null;
}
if (!(handler.container instanceof CmpContainer)) {
throw new IllegalArgumentException("Proxy is not connected to a CMP container but is conect to " + handler.container.getClass().getName());
}
final CmpContainer container = (CmpContainer) handler.container;
final Bean entity = (Bean) container.getEjbInstance(handler.getBeanContext(), handler.primaryKey);
return entity;
}
Aggregations