use of javax.ejb.EJBObject in project Payara by payara.
the class SafeProperties method instantiateEJBLocalObjectImpl.
protected EJBLocalObjectImpl instantiateEJBLocalObjectImpl(Object key) throws Exception {
EJBLocalObjectImpl localObjImpl = null;
EJBLocalObjectInvocationHandler handler = new EJBLocalObjectInvocationHandler(proxyInvocationInfoMap, localIntf);
localObjImpl = handler;
try {
EJBLocalObject localObjectProxy = (EJBLocalObject) ejbLocalObjectProxyCtor.newInstance(new Object[] { handler });
handler.setProxy(localObjectProxy);
} catch (ClassCastException e) {
String msg = localStrings.getLocalString("ejb.basecontainer_invalid_local_interface", "Local component interface [{0}] is invalid since it does not extend javax.ejb.EJBLocalObject.", localIntf);
throw new IllegalArgumentException(msg, e);
}
localObjImpl.setContainer(this);
if (key != null) {
// associate the EJBObject with the key
localObjImpl.setKey(key);
}
return localObjImpl;
}
use of javax.ejb.EJBObject in project wildfly by wildfly.
the class ReferenceAnnotationDescriptorTestCase method testStateful21Interfaces.
@Test
public void testStateful21Interfaces() throws Exception {
InitialContext jndiContext = new InitialContext();
StatefulSession30Home home = (StatefulSession30Home) jndiContext.lookup("java:module/StatefulSession30!" + StatefulSession30Home.class.getName());
Assert.assertNotNull(home);
EJBMetaData metadata = home.getEJBMetaData();
Assert.assertNotNull(metadata);
Assert.assertEquals(StatefulSession30.class, metadata.getRemoteInterfaceClass());
HomeHandle homeHandle = home.getHomeHandle();
Assert.assertNotNull(homeHandle);
EJBHome ejbHome = homeHandle.getEJBHome();
Assert.assertNotNull(ejbHome);
metadata = ejbHome.getEJBMetaData();
Assert.assertNotNull(metadata);
Assert.assertEquals(StatefulSession30.class, metadata.getRemoteInterfaceClass());
StatefulSession30 session = home.create();
Assert.assertNotNull(session);
ejbHome = session.getEJBHome();
Assert.assertNotNull(ejbHome);
Handle handle = session.getHandle();
Assert.assertNotNull(handle);
EJBObject ejbObject = handle.getEJBObject();
Assert.assertNotNull(ejbObject);
ejbHome = ejbObject.getEJBHome();
Assert.assertNotNull(ejbHome);
Handle handle1 = ejbObject.getHandle();
Assert.assertNotNull(handle1);
StatefulSession30 session1 = home.create();
Assert.assertFalse(session.isIdentical(session1));
Assert.assertTrue(session.isIdentical(session));
}
use of javax.ejb.EJBObject in project wildfly by wildfly.
the class ReferenceAnnotationDescriptorTestCase method testStateless21Interfaces.
@Test
public void testStateless21Interfaces() throws Exception {
InitialContext jndiContext = new InitialContext();
Session30Home home = (Session30Home) jndiContext.lookup("java:module/Session30!" + Session30Home.class.getName());
Assert.assertNotNull(home);
EJBMetaData metadata = home.getEJBMetaData();
Assert.assertNotNull(metadata);
Assert.assertEquals(Session30.class.getName(), metadata.getRemoteInterfaceClass().getName());
HomeHandle homeHandle = home.getHomeHandle();
Assert.assertNotNull(homeHandle);
EJBHome ejbHome = homeHandle.getEJBHome();
Assert.assertNotNull(ejbHome);
metadata = ejbHome.getEJBMetaData();
Assert.assertNotNull(metadata);
Assert.assertEquals(Session30.class.getName(), metadata.getRemoteInterfaceClass().getName());
Session30 session = home.create();
Assert.assertNotNull(session);
ejbHome = session.getEJBHome();
Assert.assertNotNull(ejbHome);
Handle handle = session.getHandle();
Assert.assertNotNull(handle);
EJBObject ejbObject = handle.getEJBObject();
Assert.assertNotNull(ejbObject);
ejbHome = ejbObject.getEJBHome();
Assert.assertNotNull(ejbHome);
Handle handle1 = ejbObject.getHandle();
Assert.assertNotNull(handle1);
Session30 session1 = home.create();
Assert.assertTrue(session.isIdentical(session1));
}
use of javax.ejb.EJBObject in project wildfly by wildfly.
the class RemoveMethodUnitTestCase method testEjbRemoveInvokedOnRemoval.
/**
* Test that ejbRemove() method was invoked on the bean when the remove() is invoked on the EJBObject
* of an EJB2.x view of a bean
*
* @throws Exception
*/
@Test
public void testEjbRemoveInvokedOnRemoval() throws Exception {
// Obtain stub
Object obj = ctx.lookup("java:app/" + DD_BASED_MODULE_NAME + "/" + Ejb21ViewDDBean.class.getSimpleName() + "!" + Ejb21ViewHome.class.getName());
Ejb21ViewHome home = (Ejb21ViewHome) PortableRemoteObject.narrow(obj, Ejb21ViewHome.class);
Ejb21View bean = home.create();
// Ensure EJBObject
Assert.assertTrue(bean instanceof EJBObject);
String result = bean.test();
bean.remove();
try {
bean.test();
Assert.fail("Invocation on a removed bean was expected to fail");
} catch (NoSuchObjectException e) {
// expected
}
final RemoveMethodInvocationTracker ejbRemoveMethodInvocationTracker = (RemoveMethodInvocationTracker) ctx.lookup("java:app/" + ANNOTATION_BASED_MODULE_NAME + "/" + RemoveMethodInvocationTrackerBean.class.getSimpleName() + "!" + RemoveMethodInvocationTracker.class.getName());
Assert.assertTrue("ejbRemove() method was not invoked after bean removal", ejbRemoveMethodInvocationTracker.wasEjbRemoveCallbackInvoked());
}
use of javax.ejb.EJBObject in project tomee by apache.
the class BaseSessionContext method getEJBObject.
public EJBObject getEJBObject() throws IllegalStateException {
doCheck(Call.getEJBObject);
final ThreadContext threadContext = ThreadContext.getThreadContext();
final BeanContext di = threadContext.getBeanContext();
if (di.getHomeInterface() == null) {
throw new IllegalStateException("Bean does not have an EJBObject interface: " + di.getDeploymentID());
}
return (EJBObject) EjbObjectProxyHandler.createProxy(di, threadContext.getPrimaryKey(), InterfaceType.EJB_OBJECT, di.getRemoteInterface());
}
Aggregations