3 Replies Latest reply on Jan 19, 2011 6:40 PM by nraf

    Injection vs. Component.getInstance()

    Tanya Ruttenberg Expert

      I'm trying to understand something.


      I write a custom envers RevisionListener in which I need access to the seam identity component from the Session context.  The following code works:




      public class IdentityListener implements RevisionListener {
      
              public void newRevision(Object revisionEntity) {
                      Identity id = (Identity) Contexts.getSessionContext().get("org.jboss.seam.security.identity");
                      IdentityRevisionEntity revEntity = (IdentityRevisionEntity) revisionEntity;
              }       
      
      }
      




      Before that, however, I tried injecting the session context using




      @In
      Context sessionContext



      and various other components, context variables, etc., but in every case got null.


      What is special about this class that injection does not work?  I tried making it into a Seam component, but that didn't help either.


      Can someone explain what I'm assuming is something basic to seam and/or java?


      TDR