use of javax.ejb.EJBObject in project tomee by apache.
the class EntityEjbHomeHandler method removeByPrimaryKey.
protected Object removeByPrimaryKey(final Class interfce, final Method method, final Object[] args, final Object proxy) throws Throwable {
final Object primKey = args[0];
// Check for the common mistake of passing the ejbObject instead of ejbObject.getPrimaryKey()
if (primKey instanceof EJBLocalObject) {
final Class ejbObjectProxyClass = primKey.getClass();
String ejbObjectName = null;
for (final Class clazz : ejbObjectProxyClass.getInterfaces()) {
if (EJBLocalObject.class.isAssignableFrom(clazz)) {
ejbObjectName = clazz.getSimpleName();
break;
}
}
throw new RemoveException("Invalid argument '" + ejbObjectName + "', expected primary key. Update to ejbLocalHome.remove(" + lcfirst(ejbObjectName) + ".getPrimaryKey())");
} else if (primKey instanceof EJBObject) {
final Class ejbObjectProxyClass = primKey.getClass();
String ejbObjectName = null;
for (final Class clazz : ejbObjectProxyClass.getInterfaces()) {
if (EJBObject.class.isAssignableFrom(clazz)) {
ejbObjectName = clazz.getSimpleName();
break;
}
}
throw new RemoveException("Invalid argument '" + ejbObjectName + "', expected primary key. Update to ejbHome.remove(" + lcfirst(ejbObjectName) + ".getPrimaryKey())");
}
container.invoke(deploymentID, interfaceType, interfce, method, args, primKey);
/*
* This operation takes care of invalidating all the EjbObjectProxyHandlers associated with
* the same RegistryId. See this.createProxy().
*/
invalidateAllHandlers(EntityEjbObjectHandler.getRegistryId(container, deploymentID, primKey));
return null;
}
use of javax.ejb.EJBObject in project tomee by apache.
the class BmpRmiIiopTests method test50_returnHandle.
/*-------------------------------------------------*/
/* Handle */
/*-------------------------------------------------*/
public void test50_returnHandle() {
try {
final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean");
final EncBmpHome home = (EncBmpHome) obj;
assertNotNull("The EJBHome returned from JNDI is null", home);
final EncBmpObject object = home.create("test_50 BmpBean");
assertNotNull("The EJBObject created is null", object);
final Handle expected = object.getHandle();
assertNotNull("The EJBObject Handle returned is null", expected);
assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject());
final Handle actual = ejbObject.returnHandle(expected);
assertNotNull("The EJBObject Handle returned is null", actual);
assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject());
final EJBObject exp = expected.getEJBObject();
final EJBObject act = actual.getEJBObject();
assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
use of javax.ejb.EJBObject in project tomee by apache.
the class BmpRmiIiopTests method test44_returnEJBObjectArray.
public void test44_returnEJBObjectArray() {
try {
final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean");
final EncBmpHome home = (EncBmpHome) obj;
assertNotNull("The EJBHome returned from JNDI is null", home);
final EncBmpObject[] expected = new EncBmpObject[3];
for (int i = 0; i < expected.length; i++) {
expected[i] = home.create("test_44 BmpBean");
assertNotNull("The EJBObject created is null", expected[i]);
}
final EJBObject[] actual = ejbObject.returnEJBObjectArray(expected);
assertNotNull("The EJBObject array returned is null", actual);
assertEquals(expected.length, actual.length);
for (int i = 0; i < actual.length; i++) {
assertTrue("The EJBObjects are not identical", expected[i].isIdentical(actual[i]));
}
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
use of javax.ejb.EJBObject in project tomee by apache.
the class BmpRmiIiopTests method setUp.
protected void setUp() throws Exception {
super.setUp();
final Object obj = initialContext.lookup("client/tests/entity/bmp/RMI-over-IIOP/EJBHome");
ejbHome = (RmiIiopBmpHome) obj;
ejbObject = ejbHome.create("RMI-IIOP TestBean");
}
use of javax.ejb.EJBObject in project tomee by apache.
the class BmpRmiIiopTests method test42_returnNestedEJBObject.
public void test42_returnNestedEJBObject() {
try {
final Object obj = initialContext.lookup("client/tests/entity/bmp/EncBean");
final EncBmpHome home = (EncBmpHome) obj;
assertNotNull("The EJBHome returned from JNDI is null", home);
final EncBmpObject expected = home.create("test_42 BmpBean");
assertNotNull("The EJBObject created is null", expected);
final ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
assertNotNull("The ObjectGraph is null", graph);
final EncBmpObject actual = (EncBmpObject) (EncBmpObject) graph.getObject();
assertNotNull("The EJBObject returned is null", actual);
assertTrue("The EJBObejcts are not identical", expected.isIdentical(actual));
} catch (final Exception e) {
fail("Received Exception " + e.getClass() + " : " + e.getMessage());
}
}
Aggregations