Discussion:
[jboss-user] [EJB3] - Obtaining an EJB proxy from a CDI Interceptor
Paul Robinson
2013-01-30 14:27:37 UTC
Permalink
Paul Robinson [https://community.jboss.org/people/paul.robinson] created the discussion

"Obtaining an EJB proxy from a CDI Interceptor"

To view the discussion, visit: https://community.jboss.org/message/795148#795148

--------------------------------------------------------------
Hello,

I have a CDI interceptor that when placed on an EJB method (of a SLSB) enlists the EJB in a protocol for which it will later receive callbacks that enable it to participate in the protocol.

Here's a simplified version of the code:


@ServiceRequest
@Interceptor
public class ServiceRequestInterceptor {
 
    @AroundInvoke
    public Object intercept(InvocationContext ic) throws Throwable {
 
        Object targetInstance = ic.getTarget();
        //register targetInstance in the protcol
    }
}


Reflection is then used to make invocations on 'targetInstance' as the protocol progresses. The problem is that 'targetInstance' is the actual java instance, so invocations bypass the whole EJB stack. I imagine causes problems for instance management as I'm accessing the bean without the EJB container knowing. But, the more immediate problem I'm seeing is that this approach prevents EJB features like CMT from working.

I think the solution to my problem is to somehow lookup the right EJB proxy in the interceptor. However, I'm unsure how to do this as I won't know the details such as the appName or moduleName. The interceptor does have access to the .class of the bean implementation, if this helps?

Any ideas would be much appreciated.

Paul.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/795148#795148]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Loading...