javax.ejb.EJBHome Java Examples

The following examples show how to use javax.ejb.EJBHome. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Unknown2HomeHandleTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHomeHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final HomeHandle copy = (HomeHandle) ois.readObject();

        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());
    }
}
 
Example #2
Source File: Complex2HomeHandleTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHomeHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final HomeHandle copy = (HomeHandle) ois.readObject();

        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());
    }
}
 
Example #3
Source File: Cmp2RmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void Xtest39_returnEJBHomeArray() {
    try {

        final EncCmpHome[] expected = new EncCmpHome[3];
        for (int i = 0; i < expected.length; i++) {
            final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
            expected[i] = (EncCmpHome) obj;
            assertNotNull("The EJBHome returned from JNDI is null", expected[i]);
        }

        final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected);
        assertNotNull("The EJBHome array returned is null", actual);
        assertEquals(expected.length, actual.length);

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #4
Source File: CmpRmiIiopTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void test39_returnEJBHomeArray() {
    try {

        final EncCmpHome[] expected = new EncCmpHome[3];
        for (int i = 0; i < expected.length; i++) {
            final Object obj = initialContext.lookup("client/tests/entity/cmp/EncBean");
            expected[i] = (EncCmpHome) obj;
            assertNotNull("The EJBHome returned from JNDI is null", expected[i]);
        }

        final EJBHome[] actual = ejbObject.returnEJBHomeArray(expected);
        assertNotNull("The EJBHome array returned is null", actual);
        assertEquals(expected.length, actual.length);

    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #5
Source File: ProxyFactory.java    From tomee with Apache License 2.0 6 votes vote down vote up
public ProxyFactory(final BeanContext beanContext) {
    this.beanContext = beanContext;
    keyGenerator = beanContext.getKeyGenerator();

    remoteInterface = beanContext.getRemoteInterface();
    if (remoteInterface != null) {
        final EJBHome homeProxy = beanContext.getEJBHome();
        remoteHandler = (EntityEjbHomeHandler) ProxyManager.getInvocationHandler(homeProxy);
    } else {
        remoteHandler = null;
    }

    localInterface = beanContext.getLocalInterface();
    if (localInterface != null) {
        final EJBLocalHome localHomeProxy = beanContext.getEJBLocalHome();
        localHandler = (EntityEjbHomeHandler) ProxyManager.getInvocationHandler(localHomeProxy);
    } else {
        localHandler = null;
    }
}
 
Example #6
Source File: Cmp2HomeHandleTests.java    From tomee with Apache License 2.0 6 votes vote down vote up
public void Xtest03_copyHandleBySerialize() {
    try {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(ejbHomeHandle);
        oos.flush();
        oos.close();
        final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        final ObjectInputStream ois = new ObjectInputStream(bais);
        final HomeHandle copy = (HomeHandle) ois.readObject();

        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());
    }
}
 
Example #7
Source File: StatelessHomeHandleTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbHomeHandle.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #8
Source File: StatefulEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #9
Source File: StatefulHomeHandleTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbHomeHandle.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #10
Source File: StatefulEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test03_getEjbHome() {
    try {
        final EJBHome home = ejbObject.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #11
Source File: BeanContext.java    From tomee with Apache License 2.0 5 votes vote down vote up
public InterfaceType getInterfaceType(final Class clazz) {
    final InterfaceType type = interfaces.get(clazz);
    if (type != null) {
        return type;
    }

    if (EJBLocalHome.class.isAssignableFrom(clazz)) {
        return InterfaceType.EJB_LOCAL_HOME;
    }
    if (EJBLocalObject.class.isAssignableFrom(clazz)) {
        return InterfaceType.EJB_LOCAL;
    }
    if (EJBHome.class.isAssignableFrom(clazz)) {
        return InterfaceType.EJB_HOME;
    }
    if (EJBObject.class.isAssignableFrom(clazz)) {
        return InterfaceType.EJB_OBJECT;
    }

    for (final Entry<Class, InterfaceType> entry : interfaces.entrySet()) { // for @Remote case where the loaded interface can be different from the stored one
        if (entry.getKey().getName().equals(clazz.getName())) {
            return entry.getValue();
        }
    }

    return null;
}
 
Example #12
Source File: StatelessPojoEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
/**
 * A method to test retrieving the EJBHome interface of a session bean using its EJBObject reference.
 */
public void test01_getEjbHome() {
    try {
        final EJBHome home = ejbObject.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #13
Source File: StatelessEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test03_getEjbHome() {
    try {
        final EJBHome home = ejbObject.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #14
Source File: StatelessEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {

        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #15
Source File: SingletonEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {

        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #16
Source File: BeanContext.java    From tomee with Apache License 2.0 5 votes vote down vote up
public EJBHome getEJBHome() {
    if (getHomeInterface() == null) {
        throw new IllegalStateException("This component has no home interface: " + getDeploymentID());
    }
    if (getLegacyView().ejbHomeRef == null) {
        getLegacyView().ejbHomeRef = (EJBHome) EjbHomeProxyHandler.createHomeProxy(this, InterfaceType.EJB_HOME);
    }
    return getLegacyView().ejbHomeRef;
}
 
Example #17
Source File: SingletonPojoEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
/**
 * A method to test retrieving the EJBHome interface of a session bean using its EJBObject reference.
 */
public void test01_getEjbHome() {
    try {
        final EJBHome home = ejbObject.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #18
Source File: SingletonHomeHandleTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbHomeHandle.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #19
Source File: SingletonPojoEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {

        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #20
Source File: EjbHomeProxyHandler.java    From tomee with Apache License 2.0 5 votes vote down vote up
protected Object getEJBMetaData(final Method method, final Object[] args, final Object proxy) throws Throwable {
    checkAuthorization(method);
    final IntraVmMetaData metaData = new IntraVmMetaData(getBeanContext().getHomeInterface(),
        getBeanContext().getRemoteInterface(),
        getBeanContext().getPrimaryKeyClass(),
        getBeanContext().getComponentType());
    metaData.setEJBHome((EJBHome) proxy);
    return metaData;
}
 
Example #21
Source File: StatelessPojoEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {

        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #22
Source File: CmpEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test04_getEjbHome() {
    try {
        final EJBHome home = ejbObject.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #23
Source File: CmpHomeHandleTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbHomeHandle.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #24
Source File: CmpEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #25
Source File: ComplexEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #26
Source File: UnknownEjbMetaDataTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbMetaData.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #27
Source File: UnknownEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test04_getEjbHome() {
    try {
        final EJBHome home = ejbObject.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #28
Source File: UnknownHomeHandleTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbHomeHandle.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #29
Source File: ComplexEjbObjectTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test04_getEjbHome() {
    try {
        final EJBHome home = ejbObject.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}
 
Example #30
Source File: ComplexHomeHandleTests.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void test01_getEJBHome() {
    try {
        final EJBHome home = ejbHomeHandle.getEJBHome();
        assertNotNull("The EJBHome is null", home);
    } catch (final Exception e) {
        fail("Received Exception " + e.getClass() + " : " + e.getMessage());
    }
}