1 Reply Latest reply on Apr 15, 2007 8:40 AM by christian.bauer

    Factory.. not being called when I first use the bean?

    tony.herstell1

      Is this correct as initCategories is not being called!

      I can call another routine in the bean and categoriesSet is empty.

      (I have run this with breakpoints and it is really not being called)

      
      @CacheConfig(idleTimeoutSeconds=1800) // This keep the object "alive" longer than the session.
      @Stateful // A component stays in existance for the duration of the Scope (conversation in this instance).
      @Name("categoryController") // Name used within SEAM for an instance of this class.
      @Scope(ScopeType.SESSION) // Scope that this class exists in.
      public class CategoryControllerImpl implements Serializable, CategoryController {
      
       /**
       * Inject and leverage the Seam Logger.
       */
       @Logger
       private Log log;
      
       /**
       * Inject the EJB3 Persistance context in EXTENDED mode so will remain "current" over
       * multiple clinet/server round trips.
       */
       @PersistenceContext(type = EXTENDED)
       private EntityManager em;
      
       /**
       * The categories
       */
       private Set<Category> categoriesSet = new LinkedHashSet<Category>();
      
       @Factory("categoriesSet") // Is run whenever this bean is created.
       public void initCategories() {
       log.error("> initCategories");
       Query query = em.createQuery("from Category"); // TODO trim for date etc.
       List<Category> categoryList = query.getResultList();
       categoriesSet.addAll(categoryList);
       // Linked hash set preserves order (could use tree if we wanted to order them - add a coparator function).
       log.debug("< initCategories");
       }