7 Replies Latest reply on Sep 26, 2007 7:55 PM by supernovasoftware.com

    Duplicate Factory method error from CVS head

      I upgraded to CVS head and my application no longer deploys.

      I am receiving an error due to a duplicate factory method.

      I am using a custom script to generate a large number of manager components. Out of these there are a few that new customization so I extend the base component and override some methods.

      I use the same component same and give the new one precedence. This worked fine in CR1, but CVS now throws an error due to duplicate factories.

      I do not think that this error should be thrown if the original component is not deployed as a Seam component due to another with a higher precedence.

        • 1. Re: Duplicate Factory method error from CVS head
          pmuir

          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

            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

              That's great, I wanted to ensure I understood exactly.

              • 4. Re: Duplicate Factory method error from CVS head
                pmuir
                • 5. Re: Duplicate Factory method error from CVS head
                  pmuir

                  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

                    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

                      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.