1 Reply Latest reply on Mar 26, 2008 8:15 AM by Martin

    EJB3 way of recreating Xdoclet's @jboss.audit feature?

    Martin Newbie

      Hello folks,

      Xdoclet has a feature where I can ask it to modify an entity bean with the correct last-updated time and last-modified-by user via the tag @jboss.audit (see the details at http://xdoclet.sourceforge.net/xdoclet/tags/jboss-tags.html).

      I'm trying to use an @EntityListeners entry to do the same thing. Unfortunately, I have *no* way of accessing the current context, so I can't pull out the principal from it! If the entity listener callback *were* a session bean, this would be possible, but it isn't! (Should I make it one?)

      Here's how I'm stuck:

      public class VOEntityListener
       public void prePersist(AbstractVO abstractVO)
       // how do I get the session context?

      @Resource private SessionContext ctx;

      or injecting session beans with @EJB doesn't work!

      The only thing with access to the context is a session bean, and I'm not even sure I *can* make a session bean into an entity listener. Please help!