Search in sources :

Example 1 with MessageDrivenContext

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

the class ContextLookupMdbBean method lookupMessageDrivenContext.

@Override
public void lookupMessageDrivenContext() throws TestFailureException {
    try {
        try {
            final InitialContext ctx = new InitialContext();
            Assert.assertNotNull("The InitialContext is null", ctx);
            // lookup in enc
            final MessageDrivenContext sctx = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
            Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx);
            // lookup using global name
            final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
            Assert.assertNotNull("The MessageDrivenContext got from java:comp/EJBContext is null ", ejbCtx);
            // verify context was set via legacy set method
            Assert.assertNotNull("The MessageDrivenContext is null from setter method", mdbContext);
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : EJBContext(javax.ejb.EJBContext) MessageDrivenContext(javax.ejb.MessageDrivenContext) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) InitialContext(javax.naming.InitialContext) JMSException(javax.jms.JMSException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 2 with MessageDrivenContext

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

the class ContextLookupMdbPojoBean method lookupMessageDrivenContext.

public void lookupMessageDrivenContext() throws TestFailureException {
    try {
        try {
            final InitialContext ctx = new InitialContext();
            Assert.assertNotNull("The InitialContext is null", ctx);
            // lookup in enc
            final MessageDrivenContext sctx = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
            Assert.assertNotNull("The MessageDrivenContext got from java:comp/env/mdbcontext is null", sctx);
            // lookup using global name
            final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
            Assert.assertNotNull("The MessageDrivenContext got from java:comp/EJBContext is null ", ejbCtx);
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : EJBContext(javax.ejb.EJBContext) MessageDrivenContext(javax.ejb.MessageDrivenContext) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) InitialContext(javax.naming.InitialContext) NamingException(javax.naming.NamingException) JMSException(javax.jms.JMSException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 3 with MessageDrivenContext

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

the class EncMdbBean method lookupMessageDrivenContext.

@Override
public void lookupMessageDrivenContext() throws TestFailureException {
    try {
        try {
            final InitialContext ctx = new InitialContext();
            Assert.assertNotNull("The InitialContext is null", ctx);
            // lookup in enc
            final MessageDrivenContext messageDrivenContext = (MessageDrivenContext) ctx.lookup("java:comp/env/mdbcontext");
            Assert.assertNotNull("The SessionContext got from java:comp/env/mdbcontext is null", messageDrivenContext);
            // lookup using global name
            final EJBContext ejbCtx = (EJBContext) ctx.lookup("java:comp/EJBContext");
            Assert.assertNotNull("The SessionContext got from java:comp/EJBContext is null ", ejbCtx);
            // verify context was set via legacy set method
            Assert.assertNotNull("The MdbContext is null from setter method", mdbContext);
        } catch (final Exception e) {
            Assert.fail("Received Exception " + e.getClass() + " : " + e.getMessage());
        }
    } catch (final AssertionFailedError afe) {
        throw new TestFailureException(afe);
    }
}
Also used : EJBContext(javax.ejb.EJBContext) MessageDrivenContext(javax.ejb.MessageDrivenContext) TestFailureException(org.apache.openejb.test.TestFailureException) AssertionFailedError(junit.framework.AssertionFailedError) InitialContext(javax.naming.InitialContext) JMSException(javax.jms.JMSException) EJBException(javax.ejb.EJBException) TestFailureException(org.apache.openejb.test.TestFailureException)

Example 4 with MessageDrivenContext

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

the class MessageDrivenBeanSetMessageDrivenContextInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext context) throws Exception {
    final MessageDrivenComponentInstance componentInstance = (MessageDrivenComponentInstance) context.getPrivateData(ComponentInstance.class);
    final MessageDrivenContext messageDrivenContext = (MessageDrivenContext) componentInstance.getEjbContext();
    ((MessageDrivenBean) context.getTarget()).setMessageDrivenContext(messageDrivenContext);
    return context.proceed();
}
Also used : MessageDrivenBean(javax.ejb.MessageDrivenBean) ComponentInstance(org.jboss.as.ee.component.ComponentInstance) MessageDrivenContext(javax.ejb.MessageDrivenContext)

Aggregations

MessageDrivenContext (javax.ejb.MessageDrivenContext)4 EJBContext (javax.ejb.EJBContext)3 EJBException (javax.ejb.EJBException)3 JMSException (javax.jms.JMSException)3 InitialContext (javax.naming.InitialContext)3 AssertionFailedError (junit.framework.AssertionFailedError)3 TestFailureException (org.apache.openejb.test.TestFailureException)3 MessageDrivenBean (javax.ejb.MessageDrivenBean)1 NamingException (javax.naming.NamingException)1 ComponentInstance (org.jboss.as.ee.component.ComponentInstance)1