Search in sources :

Example 1 with EJBHomeHandle

use of org.jboss.ejb.client.EJBHomeHandle 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)

Aggregations

HomeHandle (javax.ejb.HomeHandle)1 DeploymentRepository (org.jboss.as.ejb3.deployment.DeploymentRepository)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 EntityEJBMetaData (org.jboss.ejb.client.EntityEJBMetaData)1 EJBMetaDataImplIIOP (org.jboss.ejb.iiop.EJBMetaDataImplIIOP)1