Search in sources :

Example 6 with HomeHandle

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

the class Complex2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.

public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
        final HomeHandle copy = (HomeHandle) obj.get();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBHome(javax.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(javax.ejb.HomeHandle)

Example 7 with HomeHandle

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

the class Cmp2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.

public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
        final HomeHandle copy = (HomeHandle) obj.get();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBHome(javax.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(javax.ejb.HomeHandle)

Example 8 with HomeHandle

use of javax.ejb.HomeHandle in project wildfly by wildfly.

the class RemoteObjectSubstitutionService method writeReplaceRemote.

@Override
public Object writeReplaceRemote(final Object object) {
    final DeploymentRepository deploymentRepository = deploymentRepositoryInjectedValue.getOptionalValue();
    //if we are not started yet just return
    if (deploymentRepository == null) {
        return object;
    }
    if (EJBClient.isEJBProxy(object)) {
        return createIIOPReferenceForBean(object, deploymentRepository);
    } else if (object instanceof EJBHandle) {
        final EJBHandle<?> handle = (EJBHandle<?>) object;
        final EJBLocator<?> locator = handle.getLocator();
        final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
        if (factory != null) {
            return factory.handleForLocator(locator);
        }
    } else if (object instanceof EJBHomeHandle) {
        final EJBHomeHandle<?> handle = (EJBHomeHandle<?>) object;
        final EJBLocator<?> locator = handle.getLocator();
        final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
        if (factory != null) {
            return factory.handleForLocator(locator);
        }
    } else if (object instanceof EJBMetaDataImpl) {
        final EJBMetaDataImpl metadata = (EJBMetaDataImpl) object;
        Class<?> pk = null;
        if (!metadata.isSession()) {
            pk = metadata.getPrimaryKeyClass();
        }
        final EJBLocator<?> locator = EJBClient.getLocatorFor(metadata.getEJBHome());
        final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
        return new EJBMetaDataImplIIOP(metadata.getRemoteInterfaceClass(), metadata.getHomeInterfaceClass(), pk, metadata.isSession(), metadata.isStatelessSession(), (HomeHandle) factory.handleForLocator(locator));
    } else if (object instanceof AbstractEJBMetaData) {
        final AbstractEJBMetaData<?, ?> metadata = (AbstractEJBMetaData<?, ?>) object;
        final EJBHomeLocator<?> locator = metadata.getHomeLocator();
        final EjbIIOPService factory = serviceForLocator(locator, deploymentRepository);
        Class<?> pk = metadata instanceof EntityEJBMetaData ? metadata.getPrimaryKeyClass() : null;
        return new EJBMetaDataImplIIOP(metadata.getRemoteInterfaceClass(), metadata.getHomeInterfaceClass(), pk, metadata.isSession(), metadata.isStatelessSession(), (HomeHandle) factory.handleForLocator(locator));
    }
    return object;
}
Also used : AbstractEJBMetaData(org.jboss.ejb.client.AbstractEJBMetaData) EntityEJBMetaData(org.jboss.ejb.client.EntityEJBMetaData) EJBHandle(org.jboss.ejb.client.EJBHandle) EJBMetaDataImpl(org.jboss.ejb.client.EJBMetaDataImpl) EJBHomeHandle(org.jboss.ejb.client.EJBHomeHandle) HomeHandle(javax.ejb.HomeHandle) EJBHomeHandle(org.jboss.ejb.client.EJBHomeHandle) EJBMetaDataImplIIOP(org.jboss.ejb.iiop.EJBMetaDataImplIIOP) DeploymentRepository(org.jboss.as.ejb3.deployment.DeploymentRepository) EJBLocator(org.jboss.ejb.client.EJBLocator)

Example 9 with HomeHandle

use of javax.ejb.HomeHandle in project wildfly by wildfly.

the class ClientEjb method getRemoteViaHomeHandleMessage.

public String getRemoteViaHomeHandleMessage() throws RemoteException {
    final HomeHandle handle = home.getHomeHandle();
    final IIOPBasicHome newHome = (IIOPBasicHome) PortableRemoteObject.narrow(handle.getEJBHome(), IIOPBasicHome.class);
    final IIOPBasicRemote object = newHome.create();
    return object.hello();
}
Also used : HomeHandle(javax.ejb.HomeHandle)

Example 10 with HomeHandle

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

the class Unknown2HomeHandleTests method Xtest02_copyHandleByMarshalledObject.

public void Xtest02_copyHandleByMarshalledObject() {
    try {
        final MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
        final HomeHandle copy = (HomeHandle) obj.get();
        assertNotNull("The HomeHandle copy is null", copy);
        final EJBHome home = copy.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
Also used : EJBHome(javax.ejb.EJBHome) MarshalledObject(java.rmi.MarshalledObject) HomeHandle(javax.ejb.HomeHandle)

Aggregations

HomeHandle (javax.ejb.HomeHandle)11 EJBHome (javax.ejb.EJBHome)8 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectInputStream (java.io.ObjectInputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 MarshalledObject (java.rmi.MarshalledObject)3 EJBMetaData (javax.ejb.EJBMetaData)3 Handle (javax.ejb.Handle)3 EJBObject (javax.ejb.EJBObject)2 InitialContext (javax.naming.InitialContext)2 Test (org.junit.Test)2 List (java.util.List)1 DeploymentRepository (org.jboss.as.ejb3.deployment.DeploymentRepository)1 Session30 (org.jboss.as.test.integration.ejb.ejb2.reference.global.Session30)1 AbstractEJBMetaData (org.jboss.ejb.client.AbstractEJBMetaData)1 EJBHandle (org.jboss.ejb.client.EJBHandle)1 EJBHomeHandle (org.jboss.ejb.client.EJBHomeHandle)1 EJBLocator (org.jboss.ejb.client.EJBLocator)1 EJBMetaDataImpl (org.jboss.ejb.client.EJBMetaDataImpl)1