Java 类javax.ejb.EJBObject 实例源码

项目:tomee    文件:BmpRmiIiopTests.java   
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());
    }
}
项目:tomee    文件:BmpRmiIiopTests.java   
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());
    }
}
项目:tomee    文件:Unknown2HandleTests.java   
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final Handle copy = (Handle) ois.readObject();

        final EJBObject object = copy.getEJBObject();
        assertNotNull("The EJBObject is null", object);
        assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:Complex2HandleTests.java   
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final Handle copy = (Handle) ois.readObject();

        final EJBObject object = copy.getEJBObject();
        assertNotNull("The EJBObject is null", object);
        assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:Cmp2RmiIiopTests.java   
public void Xtest44_returnEJBObjectArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
        final EncCmpHome home = (EncCmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncCmpObject[] expected = new EncCmpObject[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = home.create("test_44 CmpBean");
            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 EJBObejcts are not identical", expected[i].isIdentical(actual[i]));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:Cmp2RmiIiopTests.java   
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
        final EncCmpHome home = (EncCmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncCmpObject object = home.create("test_50 CmpBean");
        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());
    }
}
项目:tomee    文件:Cmp2HandleTests.java   
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final Handle copy = (Handle) ois.readObject();

        final EJBObject object = copy.getEJBObject();
        assertNotNull("The EJBObject is null", object);
        assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:CmpRmiIiopTests.java   
public void test44_returnEJBObjectArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
        final EncCmpHome home = (EncCmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncCmpObject[] expected = new EncCmpObject[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = home.create("test_44 CmpBean");
            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 EJBObejcts are not identical", expected[i].isIdentical(actual[i]));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:CmpRmiIiopTests.java   
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
        final EncCmpHome home = (EncCmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncCmpObject object = home.create("test_50 CmpBean");
        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());
    }
}
项目:tomee    文件:StatefulRmiIiopTests.java   
public void test44_returnEJBObjectArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateful/EncBean");
        final EncStatefulHome home = (EncStatefulHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncStatefulObject[] expected = new EncStatefulObject[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = home.create("test_44 StatefulBean");
            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 EJBObejcts are not identical", expected[i].isIdentical(actual[i]));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:StatefulRmiIiopTests.java   
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateful/EncBean");
        final EncStatefulHome home = (EncStatefulHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncStatefulObject object = home.create("test_50 StatefulBean");
        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());
    }
}
项目:tomee    文件:StatelessRmiIiopTests.java   
public void test44_returnEJBObjectArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateless/EncBean");
        final EncStatelessHome home = (EncStatelessHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncStatelessObject[] expected = new EncStatelessObject[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = home.create();
            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 EJBObejcts are not identical", expected[i].isIdentical(actual[i]));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:StatelessRmiIiopTests.java   
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/stateless/EncBean");
        final EncStatelessHome home = (EncStatelessHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncStatelessObject object = home.create();
        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());
    }
}
项目:tomee    文件:SingletonRmiIiopTests.java   
public void test44_returnEJBObjectArray() {
    try {
        final Object obj = initialContext.lookup("client/tests/singleton/EncBean");
        final EncSingletonHome home = (EncSingletonHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncSingletonObject[] expected = new EncSingletonObject[3];
        for (int i = 0; i < expected.length; i++) {
            expected[i] = home.create();
            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 EJBObejcts are not identical", expected[i].isIdentical(actual[i]));
        }

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:SingletonRmiIiopTests.java   
public void test50_returnHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/singleton/EncBean");
        final EncSingletonHome home = (EncSingletonHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncSingletonObject object = home.create();
        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());
    }
}
项目:tomee    文件:BeanContext.java   
private void mapObjectInterface(final Class intrface) {
    if (intrface == BusinessLocalHome.class || intrface == BusinessRemoteHome.class || intrface == ServiceEndpoint.class) {
        return;
    }

    final Method[] interfaceMethods = intrface.getMethods();
    for (final Method method : interfaceMethods) {
        final Class declaringClass = method.getDeclaringClass();
        if (declaringClass == EJBObject.class || declaringClass == EJBLocalObject.class) {
            continue;
        }
        try {
            final Method beanMethod = beanClass.getMethod(method.getName(), method.getParameterTypes());
            mapMethods(method, beanMethod);
        } catch (final NoSuchMethodException nsme) {
            throw new OpenEJBRuntimeException("Invalid method [" + method + "]. Not declared by " + beanClass.getName() + " class");
        }
    }
}
项目:tomee    文件:AnnotationDeployer.java   
/**
 * Checks that the values specified via @Local and @Remote are *not*:
 * <p/>
 * - classes
 * - derived from javax.ejb.EJBObject
 * - derived from javax.ejb.EJBHome
 * - derived from javax.ejb.EJBLocalObject
 * - derived from javax.ejb.EJBLocalHome
 *
 * @param interfce
 * @param validation
 * @param ejbName
 * @param annotationName
 * @return
 */
private boolean isValidInterface(final Class interfce, final ValidationContext validation, final String ejbName, final String annotationName) {
    if (!interfce.isInterface()) {
        validation.fail(ejbName, "ann.notAnInterface", annotationName, interfce.getName());
        return false;
    } else if (EJBHome.class.isAssignableFrom(interfce)) {
        validation.fail(ejbName, "ann.remoteOrLocal.ejbHome", annotationName, interfce.getName());
        return false;
    } else if (EJBObject.class.isAssignableFrom(interfce)) {
        validation.fail(ejbName, "ann.remoteOrLocal.ejbObject", annotationName, interfce.getName());
        return false;
    } else if (EJBLocalHome.class.isAssignableFrom(interfce)) {
        validation.fail(ejbName, "ann.remoteOrLocal.ejbLocalHome", annotationName, interfce.getName());
        return false;
    } else if (EJBLocalObject.class.isAssignableFrom(interfce)) {
        validation.fail(ejbName, "ann.remoteOrLocal.ejbLocalObject", annotationName, interfce.getName());
        return false;
    }
    return true;
}
项目:tomee    文件:EntityContext.java   
public EJBObject getEJBObject() throws IllegalStateException {
    doCheck(Call.getEJBObject);

    final ThreadContext threadContext = ThreadContext.getThreadContext();
    final BeanContext di = threadContext.getBeanContext();

    if (di.getRemoteInterface() == null) {
        throw new IllegalStateException("EJB " + di.getDeploymentID() + " does not have a remote interface");
    }

    final EjbObjectProxyHandler handler = new EntityEjbObjectHandler(di.getContainer().getBeanContext(di.getDeploymentID()), threadContext.getPrimaryKey(), InterfaceType.EJB_OBJECT, new ArrayList<Class>(), di.getRemoteInterface());
    try {
        final Class[] interfaces = new Class[]{di.getRemoteInterface(), IntraVmProxy.class};
        return (EJBObject) ProxyManager.newProxyInstance(interfaces, handler);
    } catch (final IllegalAccessException iae) {
        throw new InternalErrorException("Could not create IVM proxy for " + di.getRemoteInterface() + " interface", iae);
    }
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:Ejb21EngineRemoteBean.java   
@Override
public void log() throws RemoteException {
    Principal principal = context.getCallerPrincipal();
    Map<String, Object> contextData = context.getContextData();
    EJBHome ejbHome = context.getEJBHome();
    EJBObject ejbObject = context.getEJBObject();
    Ejb21Remote RemoteEngine = context.getBusinessObject(Ejb21Remote.class);
    boolean isCallerInRole = context.isCallerInRole("admin");
    logger.info("ejb21RemoteEngineBean principal: " + principal);
    logger.info("ejb21RemoteEngineBean contextData:" + contextData);
    logger.info("ejb21RemoteEngineBean ejbHome:" + ejbHome);
    logger.info("ejb21RemoteEngineBean ejbObject:" + ejbObject);
    logger.info("ejb21RemoteEngineBean RemoteEngineBean:" + RemoteEngine);
    logger.info("ejb21RemoteEngineBean isCallerInRole:" + isCallerInRole);
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:Ejb21StateEngineRemoteBean.java   
@Override
public void log() throws RemoteException {
    Principal principal = context.getCallerPrincipal();
    Map<String, Object> contextData = context.getContextData();
    EJBHome ejbHome = context.getEJBHome();
    EJBObject ejbObject = context.getEJBObject();
    Ejb21StateRemote stateRemoteEngine = context.getBusinessObject(Ejb21StateRemote.class);
    boolean isCallerInRole = context.isCallerInRole("admin");
    logger.info("stateRemoteEngineBean principal: " + principal);
    logger.info("stateRemoteEngineBean contextData:" + contextData);
    logger.info("stateRemoteEngineBean ejbHome:" + ejbHome);
    logger.info("stateRemoteEngineBean ejbObject:" + ejbObject);
    logger.info("stateRemoteEngineBean stateRemoteEngineBean:" + stateRemoteEngine);
    logger.info("stateRemoteEngineBean isCallerInRole:" + isCallerInRole);
}
项目:lams    文件:SimpleRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the cached session bean instance, if necessary.
 */
@Override
public void destroy() {
    if (this.cacheSessionBean) {
        synchronized (this.beanInstanceMonitor) {
            if (this.beanInstance instanceof EJBObject) {
                removeSessionBeanInstance((EJBObject) this.beanInstance);
            }
        }
    }
}
项目:lams    文件:AbstractRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the given EJB instance.
 * To be invoked by concrete remote SLSB invoker subclasses.
 * @param ejb the EJB instance to remove
 * @see javax.ejb.EJBObject#remove
 */
protected void removeSessionBeanInstance(EJBObject ejb) {
    if (ejb != null && !this.homeAsComponent) {
        try {
            ejb.remove();
        }
        catch (Throwable ex) {
            logger.warn("Could not invoke 'remove' on remote EJB proxy", ex);
        }
    }
}
项目:spring4-understanding    文件:SimpleRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the cached session bean instance, if necessary.
 */
@Override
public void destroy() {
    if (this.cacheSessionBean) {
        synchronized (this.beanInstanceMonitor) {
            if (this.beanInstance instanceof EJBObject) {
                removeSessionBeanInstance((EJBObject) this.beanInstance);
            }
        }
    }
}
项目:spring4-understanding    文件:AbstractRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the given EJB instance.
 * To be invoked by concrete remote SLSB invoker subclasses.
 * @param ejb the EJB instance to remove
 * @see javax.ejb.EJBObject#remove
 */
protected void removeSessionBeanInstance(EJBObject ejb) {
    if (ejb != null && !this.homeAsComponent) {
        try {
            ejb.remove();
        }
        catch (Throwable ex) {
            logger.warn("Could not invoke 'remove' on remote EJB proxy", ex);
        }
    }
}
项目:my-spring-cache-redis    文件:SimpleRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the cached session bean instance, if necessary.
 */
@Override
public void destroy() {
    if (this.cacheSessionBean) {
        synchronized (this.beanInstanceMonitor) {
            if (this.beanInstance instanceof EJBObject) {
                removeSessionBeanInstance((EJBObject) this.beanInstance);
            }
        }
    }
}
项目:my-spring-cache-redis    文件:AbstractRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the given EJB instance.
 * To be invoked by concrete remote SLSB invoker subclasses.
 * @param ejb the EJB instance to remove
 * @see javax.ejb.EJBObject#remove
 */
protected void removeSessionBeanInstance(EJBObject ejb) {
    if (ejb != null && !this.homeAsComponent) {
        try {
            ejb.remove();
        }
        catch (Throwable ex) {
            logger.warn("Could not invoke 'remove' on remote EJB proxy", ex);
        }
    }
}
项目:spring    文件:SimpleRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the cached session bean instance, if necessary.
 */
@Override
public void destroy() {
    if (this.cacheSessionBean) {
        synchronized (this.beanInstanceMonitor) {
            if (this.beanInstance instanceof EJBObject) {
                removeSessionBeanInstance((EJBObject) this.beanInstance);
            }
        }
    }
}
项目:spring    文件:AbstractRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the given EJB instance.
 * To be invoked by concrete remote SLSB invoker subclasses.
 * @param ejb the EJB instance to remove
 * @see javax.ejb.EJBObject#remove
 */
protected void removeSessionBeanInstance(EJBObject ejb) {
    if (ejb != null && !this.homeAsComponent) {
        try {
            ejb.remove();
        }
        catch (Throwable ex) {
            logger.warn("Could not invoke 'remove' on remote EJB proxy", ex);
        }
    }
}
项目:class-guard    文件:SimpleRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the cached session bean instance, if necessary.
 */
public void destroy() {
    if (this.cacheSessionBean) {
        synchronized (this.beanInstanceMonitor) {
            if (this.beanInstance instanceof EJBObject) {
                removeSessionBeanInstance((EJBObject) this.beanInstance);
            }
        }
    }
}
项目:class-guard    文件:AbstractRemoteSlsbInvokerInterceptor.java   
/**
 * Remove the given EJB instance.
 * To be invoked by concrete remote SLSB invoker subclasses.
 * @param ejb the EJB instance to remove
 * @see javax.ejb.EJBObject#remove
 */
protected void removeSessionBeanInstance(EJBObject ejb) {
    if (ejb != null && !this.homeAsComponent) {
        try {
            ejb.remove();
        }
        catch (Throwable ex) {
            logger.warn("Could not invoke 'remove' on remote EJB proxy", ex);
        }
    }
}
项目:tomee    文件:EntityEJBHomeHandler.java   
@Override
protected Object removeWithHandle(final Method method, final Object[] args, final Object proxy) throws Throwable {
    if (args[0] == null) {
        throw new RemoteException("Handler is null");
    }

    final Handle handle = (Handle) args[0];

    final EJBObject ejbObject = handle.getEJBObject();
    if (ejbObject == null) {
        throw new NullPointerException("The handle.getEJBObject() is null.");
    }

    final Object primKey = ejbObject.getPrimaryKey();
    if (primKey == null) {
        throw new NullPointerException("The handle.getEJBObject().getPrimaryKey() is null.");
    }

    final EJBRequest req = new EJBRequest(RequestMethodCode.EJB_HOME_REMOVE_BY_HANDLE, ejb, method, args, primKey, client.getSerializer());

    final EJBResponse res = request(req);

    switch (res.getResponseCode()) {
        case ResponseCodes.EJB_ERROR:
            throw new SystemError((ThrowableArtifact) res.getResult());
        case ResponseCodes.EJB_SYS_EXCEPTION:
            throw new SystemException((ThrowableArtifact) res.getResult());
        case ResponseCodes.EJB_APP_EXCEPTION:
            throw new ApplicationException((ThrowableArtifact) res.getResult());
        case ResponseCodes.EJB_OK:
            invalidateAllHandlers(ejb.deploymentID + ":" + primKey);
            return null;
        default:
            throw new RemoteException("Received invalid response code from server: " + res.getResponseCode());
    }
}
项目:tomee    文件:EJBInvocationHandler.java   
public EJBInvocationHandler(final EJBMetaDataImpl ejb, final ServerMetaData server, final ClientMetaData client, final JNDIContext.AuthenticationInfo auth) {
    this.ejb = ejb;
    this.server = server;
    this.client = client;
    this.authenticationInfo = auth;
    final Class remoteInterface = ejb.getRemoteInterfaceClass();
    remote = remoteInterface != null && (EJBObject.class.isAssignableFrom(remoteInterface) || EJBHome.class.isAssignableFrom(remoteInterface));
}
项目:tomee    文件:EJBRequestTest.java   
public void testIsIdentical() throws Exception {
    final RequestMethodCode requestMethod = RequestMethodCode.EJB_OBJECT_IS_IDENTICAL;
    final Method method = FooObject.class.getMethod("isIdentical", new Class[]{EJBObject.class});
    final Object[] args = new Object[]{null};

    invoke(requestMethod, method, args);
}
项目:tomee    文件:BmpRmiIiopTests.java   
public void test52_returnNestedHandle() {
    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_52 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 ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        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());
    }
}
项目:tomee    文件:BmpHandleTests.java   
public void test01_getEJBObject() {

        try {
            final EJBObject object = ejbHandle.getEJBObject();
            assertNotNull("The EJBObject is null", object);
            // Wait until isIdentical is working.
            //assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
        } catch (final Exception e) {
            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    }
项目:tomee    文件:Unknown2HandleTests.java   
public void test01_getEJBObject() {

        try {
            final EJBObject object = ejbHandle.getEJBObject();
            assertNotNull("The EJBObject is null", object);
            // Wait until isIdentical is working.
            //assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
        } catch (final Exception e) {
            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    }
项目:tomee    文件:Unknown2HandleTests.java   
public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHandle);
        final Handle copy = (Handle) obj.get();

        final EJBObject object = copy.getEJBObject();
        assertNotNull("The EJBObject is null", object);
        assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:Complex2HandleTests.java   
public void test01_getEJBObject() {

        try {
            final EJBObject object = ejbHandle.getEJBObject();
            assertNotNull("The EJBObject is null", object);
            // Wait until isIdentical is working.
            //assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
        } catch (final Exception e) {
            fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    }
项目:tomee    文件:Complex2HandleTests.java   
public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHandle);
        final Handle copy = (Handle) obj.get();

        final EJBObject object = copy.getEJBObject();
        assertNotNull("The EJBObject is null", object);
        assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
项目:tomee    文件:Cmp2RmiIiopTests.java   
public void test52_returnNestedHandle() {
    try {
        final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
        final EncCmpHome home = (EncCmpHome) obj;
        assertNotNull("The EJBHome returned from JNDI is null", home);

        final EncCmpObject object = home.create("test_52 CmpBean");
        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 ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected));
        assertNotNull("The ObjectGraph is null", graph);

        final Handle actual = (Handle) graph.getObject();
        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());
    }
}