[323757] EAR Libraries Classpath Container picking up non MANIFEST references
diff --git a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java index 61dec22..31da0af 100644 --- a/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java +++ b/plugins/org.eclipse.jst.j2ee/common/org/eclipse/jst/j2ee/internal/common/classpath/J2EEComponentClasspathContainer.java
@@ -12,6 +12,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.List; @@ -63,11 +64,15 @@ private static IPath WEBLIB = new Path("/WEB-INF/lib"); //$NON-NLS-1$ private static ClasspathDecorationsManager decorationsManager = new ClasspathDecorationsManager(J2EEPlugin.PLUGIN_ID); - public static ClasspathDecorationsManager getDecorationsManager() { return decorationsManager; } + private static Map<String, Object> onlyManifestRefs = new HashMap<String, Object>(); + static { + onlyManifestRefs.put(IVirtualComponent.REQUESTED_REFERENCE_TYPE, J2EEModuleVirtualComponent.ONLY_MANIFEST_REFERENCES); + } + private IPath containerPath; private IJavaProject javaProject; private IJavaProjectLite javaProjectLite; @@ -114,8 +119,8 @@ if (component == null) { return false; } - - IVirtualReference[] refs = component instanceof J2EEModuleVirtualComponent ? ((J2EEModuleVirtualComponent)component).getReferences(false, true): component.getReferences(); + + IVirtualReference[] refs = component.getReferences(onlyManifestRefs); // avoid updating the container if references haven't changed if (refs.length == lastUpdate.baseRefCount) { @@ -188,8 +193,7 @@ return; } - - IVirtualReference[] refs = component instanceof J2EEModuleVirtualComponent ? ((J2EEModuleVirtualComponent)component).getReferences(false, true): component.getReferences(); + IVirtualReference[] refs = component.getReferences(onlyManifestRefs); List<IVirtualReference> refsList = new ArrayList<IVirtualReference>(); Set<IVirtualComponent> refedComps = new HashSet<IVirtualComponent>(); @@ -202,7 +206,6 @@ } lastUpdate.baseRefCount = refsList.size(); - List <IVirtualReference> earLibReferences = getBaseEARLibRefs(component); lastUpdate.baseLibRefCount = earLibReferences.size(); for(IVirtualReference earRef : earLibReferences){
diff --git a/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java b/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java index ca75072..a8cd45a 100644 --- a/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java +++ b/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/componentcore/J2EEModuleVirtualComponent.java
@@ -57,6 +57,17 @@ public static String GET_JAVA_REFS = "GET_JAVA_REFS"; //$NON-NLS-1$ public static String GET_FUZZY_EAR_REFS = "GET_FUZZY_EAR_REFS"; //$NON-NLS-1$ public static String GET_EXPANDED_LIB_REFS = "GET_EXPANDED_LIB_REFS"; //$NON-NLS-1$ + /** + * Use this value to retrieve references consisting of only META-INF/MANIFEST.MF classpath + * attributes. Do this as follows: + * <code> + * IVirtualCompoment compoment = a virtual component + * Map<String, Object> onlyManifestRefs = new HashMap<String, Object>(); + * onlyManifestRefs.put(IVirtualComponent.REQUESTED_REFERENCE_TYPE, J2EEModuleVirtualComponent.ONLY_MANIFEST_REFERENCES); + * IVirtualReference[] refs = component.getReferences(onlyManifestRefs); + * </code> + */ + public static String ONLY_MANIFEST_REFERENCES = "ONLY_MANIFEST_REFERENCES"; //$NON-NLS-1$ private long depGraphModStamp; private long jeeModStamp; @@ -122,8 +133,18 @@ public IVirtualReference[] getReferences(Map<String, Object> options) { Object val = options.get(REQUESTED_REFERENCE_TYPE); if( val != null ) { - if( HARD_REFERENCES.equals(val) || NON_DERIVED_REFERENCES.equals(val) || DISPLAYABLE_REFERENCES.equals(val)) + if( HARD_REFERENCES.equals(val) || NON_DERIVED_REFERENCES.equals(val) || DISPLAYABLE_REFERENCES.equals(val)){ return getHardReferences(); + } else if (ONLY_MANIFEST_REFERENCES.equals(val)){ + ArrayList<IVirtualReference> all = new ArrayList<IVirtualReference>(); + checkIfStillValid(); + cacheManifestReferences(); + all.addAll(Arrays.asList(parentEarManifestReferences)); + all.addAll(Arrays.asList(fuzzyEarManifestReferences)); + IVirtualReference[] refs = all.toArray(new IVirtualReference[all.size()]); + VirtualReferenceUtilities.INSTANCE.ensureReferencesHaveNames(refs); + return refs; + } } Boolean objGetJavaRefs = (Boolean)options.get(GET_JAVA_REFS); Boolean objGetFuzzyEarRefs = (Boolean)options.get(GET_FUZZY_EAR_REFS);