users@glassfish.java.net

Re: Accessing EJBs from a POJO

From: heapifyman <heapifyman_at_gmail.com>
Date: Fri, 30 Jan 2009 16:36:44 +0100

glassfish_at_javadesktop.org schrieb:
> Sorry about the confusion with what I'm trying to do. Let me be more specific.
>
> What I'm trying to do is use the JPA lifecycle callbacks to do auditing/history for who changes an entity and when. I want to be able to get a handle on the stateful session bean which holds information about the person who is logged in and using @PostLoad is simply an easy way for me to verify whether I can or not. Because the entity listener POJO is called by the JPA provider and does not participate in the lifecycle of the container I can't use injection which is why I was trying to follow the Glassfish tutorial on how to access the Ejb FROM the POJO.
>
> I guess the easiest option for me then is to create a remote interface for my stateful session bean so that it will get placed into the global namespace. Does that sound correct?

Couldn't one also send a message from the JPA POJO to an MDB, which in
turn calls your auditing EJB?

But this is probably oversized...