4 Replies Latest reply on Mar 26, 2009 4:45 PM by d sailer

    Noob, @In not set

    d sailer Newbie

      I'm sure I'm doing something dumb here but I can't get an @In value injected.


      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("prePersistListener")
      public class PrePersistListenerImpl implements PrePersistListener {
      
        @In 
        private User user;
      
        @PreUpdate
        @PrePersist
        public void preUpdate(Object entity) {
          if (entity instanceof LastUpdateAware) {
            LastUpdateAware awareEntity = (LastUpdateAware)entity;
            awareEntity.setTimestamp(new Date());
            awareEntity.setUpdateUser(user);
          }
        }
        
        @Remove
        public void destroy() {}
      }
      



      @Local
      public interface PrePersistListener {
      
        void preUpdate(Object entity);
        public void destroy();
      
      }
      



      @Stateless
      @Name("authenticator")
      public class AuthenticatorImpl implements Authenticator {
       
        @PersistenceContext
        private EntityManager entityManager;
      
        @Out(required=false, scope = ScopeType.SESSION)
        private User user;
      
        public boolean authenticate() {
          //TODO: encrypt password
          String qryStr = "select u from User u where u.username=#{identity.username} and u.password=#{identity.password}";
          Query qry = entityManager.createQuery(qryStr);
          List results = qry.getResultList();
      
          if (results.size() == 0) {
            return false;
          } else {
            user = (User) results.get(0);
            return true;
          }
        }
      
      }
      



      debugging shows the value of user is set in authenticate() but null in preUpdate()