Search in sources :

Example 41 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class BmpHandleTests method setUp.

protected void setUp() throws Exception {
    super.setUp();
    final Object obj = initialContext.lookup("client/tests/entity/bmp/BasicBmpHome");
    ejbHome = (BasicBmpHome) obj;
    ejbObject = ejbHome.createObject("Fifth Bean");
    ejbHandle = ejbObject.getHandle();
}
Also used : EJBObject(javax.ejb.EJBObject)

Example 42 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class BmpRmiIiopTests method test40_returnEJBObject.

/*-------------------------------------------------*/
/*  EJBObject                                      */
/*-------------------------------------------------*/
public void test40_returnEJBObject() {
    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_40 BmpBean");
        assertNotNull("The EJBObject created is null", expected);
        final EncBmpObject actual = (EncBmpObject) ejbObject.returnEJBObject(expected);
        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());
    }
}
Also used : EJBObject(javax.ejb.EJBObject) RemoteException(java.rmi.RemoteException)

Example 43 with EJBObject

use of javax.ejb.EJBObject in project tomee by apache.

the class SingletonAllowedOperationsTests method setUp.

protected void setUp() throws Exception {
    super.setUp();
    final Object obj = initialContext.lookup("client/tests/singleton/BasicSingletonHome");
    ejbHome = (BasicSingletonHome) obj;
    ejbObject = ejbHome.createObject();
    ejbHandle = ejbObject.getHandle();
    timerSync = (TimerSync) initialContext.lookup("TimerSyncBeanBusinessRemote");
    // setUp_ejbActivate_Passivate();
    /* These tests will only work if the specified
         * method has already been called by the container.
         *
         * TO DO:
         * Implement a little application senario to ensure
         * that all methods tested for below have been called
         * by the container.
         */
    ejbObject.businessMethod("activate me please");
}
Also used : EJBObject(javax.ejb.EJBObject)

Example 44 with EJBObject

use of javax.ejb.EJBObject in project Payara by payara.

the class SafeProperties method createRemoteReferenceWithId.

/**
 * Create an EJBObject reference from the instanceKey
 *	Called from EJBObjectOutputStream.SerializableRemoteRef
 *	during deserialization of a remote-ref
 * @param instanceKey instanceKey of the ejbobject
 * @param generatedRemoteBusinessIntf non-null, this is a remote business view and the param
 *           is the name of the generated remote business interface.
 *           Otherwise, this is for the RemoteHome view
 */
public java.rmi.Remote createRemoteReferenceWithId(byte[] instanceKey, String generatedRemoteBusinessIntf) {
    final Thread currentThread = Thread.currentThread();
    final ClassLoader previousClassLoader = currentThread.getContextClassLoader();
    final ClassLoader myClassLoader = loader;
    try {
        if (System.getSecurityManager() == null) {
            currentThread.setContextClassLoader(myClassLoader);
        } else {
            java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {

                public java.lang.Object run() {
                    currentThread.setContextClassLoader(myClassLoader);
                    return null;
                }
            });
        }
        java.rmi.Remote remoteRef = null;
        if (generatedRemoteBusinessIntf == null) {
            remoteRef = remoteHomeRefFactory.createRemoteReference(instanceKey);
        } else {
            RemoteReferenceFactory remoteBusinessRefFactory = remoteBusinessIntfInfo.get(generatedRemoteBusinessIntf).referenceFactory;
            remoteRef = remoteBusinessRefFactory.createRemoteReference(instanceKey);
        }
        return remoteRef;
    } finally {
        if (System.getSecurityManager() == null) {
            currentThread.setContextClassLoader(previousClassLoader);
        } else {
            java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {

                public java.lang.Object run() {
                    currentThread.setContextClassLoader(previousClassLoader);
                    return null;
                }
            });
        }
    }
}
Also used : RemoteReferenceFactory(org.glassfish.enterprise.iiop.api.RemoteReferenceFactory) EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject)

Example 45 with EJBObject

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;
}
Also used : EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject)

Aggregations

EJBObject (javax.ejb.EJBObject)109 RemoteException (java.rmi.RemoteException)46 Handle (javax.ejb.Handle)28 EJBLocalObject (javax.ejb.EJBLocalObject)12 ObjectGraph (org.apache.openejb.test.object.ObjectGraph)12 EJBException (javax.ejb.EJBException)11 RemoveException (javax.ejb.RemoveException)9 SystemException (javax.transaction.SystemException)9 CreateException (javax.ejb.CreateException)8 NoSuchObjectLocalException (javax.ejb.NoSuchObjectLocalException)8 EncCmpObject (org.apache.openejb.test.entity.cmp.EncCmpObject)7 RmiIiopCmpObject (org.apache.openejb.test.entity.cmp.RmiIiopCmpObject)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 MarshalledObject (java.rmi.MarshalledObject)6 FinderException (javax.ejb.FinderException)6 EncCmpHome (org.apache.openejb.test.entity.cmp.EncCmpHome)6 Test (org.junit.Test)5 NoSuchObjectException (java.rmi.NoSuchObjectException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3