-
1. Re: Duplicate Factory method error from CVS head
pmuir Sep 26, 2007 3:27 PM (in response to supernovasoftware.com)Can you post some code showing your problem? I did enable the check and we need to fix this.
-
2. Re: Duplicate Factory method error from CVS head
supernovasoftware.com Sep 26, 2007 3:52 PM (in response to supernovasoftware.com)I didn't clean up the code much, but I will explain. If you need me to clean it up, I can as I appreciate greatly all the help that I have been giving on this forum.
First I list the generated class that I created with a custom code generation script.
Next I listed the extended version with higher precedence. In this case I need to add a simple filter to the entity list. So I overrode@Factory("contactList") public List<Contact> getEntityList()
Now Seam sees 2 factories for "contactList", but the original should not be deployed as a Seam component as it has lower precedence.
Generated Manager Class@Stateful @Name("contactManager") @Scope(ScopeType.CONVERSATION) public class ContactManagerBean extends CrudEjb3DAOBean<Contact, Long> implements Serializable, ContactManager { public ContactManagerBean() { super(Contact.class); } @In(create=true) private ContactDAO contactDAO; @DataModel(value="contactList") protected List<Contact> contactList; @Out(required = false) @DataModelSelection(value="contactList") private Contact contactEdit; @SuppressWarnings("unchecked") @Factory("contactList") public List<Contact> getEntityList() { log.info("@Factory(contactList)"); return contactList = processList(contactDAO.getAll()); } /* All Contact */ @Out(required=false, scope=ScopeType.APPLICATION) private List<Contact> listContact; @Factory("listContact") public List<Contact> loadAll() { log.info("loadContact()"); return listContact = contactDAO.getAll(); } /* Active Contact */ @Out(required=false, scope=ScopeType.APPLICATION) private List<Contact> listContactActive; @Factory("listContactActive") public List<Contact> loadActive() { log.info("loadContactActive()"); return listContactActive = contactDAO.getActive(); } public void clearList() { contactList = null; } public Contact getEntityEdit() { return this.contactEdit; } public void setEntityEdit(Contact entity) { contactEdit = entity; } @Destroy @Remove public void destroy() { } @Override public GenericDAO<Contact, Long> getGenericDAO() { return contactDAO; } }
Extended and set with higher presedence@Stateful @Name("contactManager") @Install(precedence=100) public class ContactManagerExtendsBean extends ContactManagerBean implements ContactSearch { @SuppressWarnings("unchecked") @Factory("contactList") public List<Contact> getEntityList() { log.info("@Factory(contactList)"); if(strCompanyFilter==null) { return contactList = processList(((ContactDAO) getGenericDAO()).getAll()); } else { return contactList = processList(((ContactDAO) getGenericDAO()).getFilterdContacts(strCompanyFilter)); } } @In(required = false, create = true) @Out(scope = ScopeType.UNSPECIFIED, required = false) private String strCompanyFilter = "%"; public String getStrCompanyFilter() { return strCompanyFilter; } public void setStrCompanyFilter(String strCompanyFilter) { this.strCompanyFilter = strCompanyFilter; } public void filter() { contactList = ((ContactDAO) getGenericDAO()).getFilterdContacts(strCompanyFilter); contactList.add(new Contact()); } }
-
3. Re: Duplicate Factory method error from CVS head
pmuir Sep 26, 2007 4:04 PM (in response to supernovasoftware.com)That's great, I wanted to ensure I understood exactly.
-
5. Re: Duplicate Factory method error from CVS head
pmuir Sep 26, 2007 6:03 PM (in response to supernovasoftware.com)Ok, please test CVS now, I've modified the duplicate checks to make them allow for component precedence.
-
6. Re: Duplicate Factory method error from CVS head
supernovasoftware.com Sep 26, 2007 6:21 PM (in response to supernovasoftware.com)That problem appears to be fix the problem, but I have duplicate factory method where the components are not overridden.
However, this is new code that I have not tested fully. I am going to investigate and to see if what I am doing is actually logical.
I will post a reply very soon. -
7. Re: Duplicate Factory method error from CVS head
supernovasoftware.com Sep 26, 2007 7:55 PM (in response to supernovasoftware.com)That check uncovered numerous erroneous duplicates of Factories in my application. It proved quite valuable and I would love to see other validations. It will help users understand their problems before posting to the forums.
Most of my cases were just copy and paste errors where I did not clean up my mess. :)
I am working on a workaround for the new code I was working on. It involves a base class that had 3 DataModel + Factory methods. Now that I review that was obviously wrong on my part.
I was extending this class to provide specific functionality for each use case, but giving each component a new name.