This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
There is Java-specific implementation of PrivilegedTemplates (FreeformProject.PrivilegedTemplatesImpl) in freeform project. Other freeform types (web, ejb) don't have possibility to change it or register new one.
I will move it to where it belongs (i.e. java/freeform) and ensure that all templates defined by natures as priviledged will be merged and shown. This is related to fix of issue 52498 which is still on my radar: should freeform project merge impls of the same interface comming from different natures or should it be documented that >1 impls are allowed in project's lookup. I will resolve that as part of this issue.
Created attachment 19542 [details] solution
As said earlier there exist following problem: freeform natures can enhance project lookup and this can result in situation where project lookup contains two entries, but lookup contract says that there will be only one. Example can be PrivilegedTemplates or ClassPathProvider which are implemented both by Java freeform nature and Web freeform nature. The solution I propose is to add support for merging of lookup entries. Mergining is domain knowledge and therefore cannot be done by the freeform core without help of project natures. Attached is diff of API and impl which works. No unit tests at the moment. Please review. Questions/suggestions welcome. LookupMerger may not be the best name.
getMergableClasses should be getMergeableClasses. This is definitely a good place to have unit tests; the lookup merging code is not obvious. BTW: clazz.equals(X.class) can be simplified to clazz == X.class. getMerg[e]ableClasses Javadoc should emphasize that the Class's are for the interfaces, not implementations. Probably obvious but can't hurt to state it. LookupMergerImpl.PrivilegedTemplatesImpl should probably remove duplicates, e.g. using a LinkedHashSet rather than an ArrayList. Otherwise, looks good to me.
Fixed for all freeforms. madamek, please see the diff and verify or update web/j2ee nature as needed. Commit: ant/freeform/manifest.mf; new revision: 1.6; previous revision: 1.5 ant/freeform/src/org/netbeans/modules/ant/freeform/FreeformProject.java; new revision: 1.32; previous revision: 1.31 ant/freeform/src/org/netbeans/modules/ant/freeform/LookupMergerImpl.java; initial revision: 1.1 ant/freeform/src/org/netbeans/modules/ant/freeform/spi/LookupMerger.java; initial revision: 1.1 ant/freeform/test/unit/src/META-INF/services/org.netbeans.modules.ant.freeform.spi.ProjectNature; initial revision: 1.1 ant/freeform/test/unit/src/org/netbeans/modules/ant/freeform/spi/ProjectNatureTest.java; initial revision: 1.1 java/freeform/nbproject/project.xml; new revision: 1.4; previous revision: 1.3 java/freeform/src/org/netbeans/modules/java/freeform/JavaProjectNature.java; new revision: 1.3; previous revision: 1.2 java/freeform/src/org/netbeans/modules/java/freeform/LookupMergerImpl.java; initial revision: 1.1 java/project/src/org/netbeans/modules/java/project/ProjectClassPathProvider.java; new revision: 1.4; previous revision: 1.3 web/freeform/nbproject/project.xml; new revision: 1.4; previous revision: 1.3 web/freeform/src/org/netbeans/modules/web/freeform/WebProjectNature.java; new revision: 1.3; previous revision: 1.2 j2ee/ejbfreeform/nbproject/project.xml; new revision: 1.5; previous revision: 1.4 j2ee/ejbfreeform/src/org/netbeans/modules/j2ee/ejbfreeform/EJBProjectNature.java; new revision: 1.5; previous revision: 1.4
Looks fine for EJB.