[jboss-user] [JBoss Seam] - Factory.. not being called when I first use the bean?
tony.herstell@gmail.com
do-not-reply at jboss.com
Sun Apr 15 08:16:33 EDT 2007
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");
| }
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4037361#4037361
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4037361
More information about the jboss-user
mailing list