Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjlanuti2006-08-11 02:03:37 +0000
committerjlanuti2006-08-11 02:03:37 +0000
commit72538791546a503a251a961577e1f7b4b4ac9bb0 (patch)
tree8c6f6c056afcffc86d2bc3574b3edd6a679ec9b2
parent7cf99b35baa0ddd364b6c6d1c3df388639a29774 (diff)
downloadwebtools.javaee-72538791546a503a251a961577e1f7b4b4ac9bb0.tar.gz
webtools.javaee-72538791546a503a251a961577e1f7b4b4ac9bb0.tar.xz
webtools.javaee-72538791546a503a251a961577e1f7b4b4ac9bb0.zip
[153301] fix for deployables
-rw-r--r--plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java53
-rw-r--r--plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java92
2 files changed, 94 insertions, 51 deletions
diff --git a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java
index a10059326..454b6d4cf 100644
--- a/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java
+++ b/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jem.workbench.utility.JemProjectUtilities;
+import org.eclipse.jst.j2ee.application.Application;
import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent;
import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit;
import org.eclipse.jst.j2ee.ejb.EJBJar;
@@ -115,8 +116,14 @@ public class J2EEFlexProjDeployable extends ComponentDeployable implements IJ2EE
return J2EEProjectUtilities.getOutputContainers(project);
}
- protected boolean shouldIncludeUtilityComponent(IVirtualComponent virtualComp) {
- return virtualComp != null && virtualComp.isBinary() && !(virtualComp instanceof J2EEModuleVirtualArchiveComponent);
+ protected boolean shouldIncludeUtilityComponent(IVirtualComponent virtualComp,IVirtualReference[] references, ArtifactEdit edit) {
+ // If the component module is an EAR we know all archives are filtered out of virtual component members
+ // and we will return only those archives which are not binary J2EE modules in the EAR DD. These J2EE modules will
+ // be returned by getChildModules()
+ if (J2EEProjectUtilities.isEARProject(component.getProject()))
+ return virtualComp != null && virtualComp.isBinary() && !isNestedJ2EEModule(virtualComp, references, (EARArtifactEdit)edit);
+ else
+ return super.shouldIncludeUtilityComponent(virtualComp, references, edit);
}
protected IModuleResource[] getBinaryModuleMembers() {
@@ -167,9 +174,7 @@ public class J2EEFlexProjDeployable extends ComponentDeployable implements IJ2EE
}
if (vc != null) {
- List utilMembers = getUtilMembers(vc);
- if (!utilMembers.isEmpty())
- members.addAll(utilMembers);
+ addUtilMembers(vc);
List consumableMembers = getConsumableReferencedMembers(vc);
if (!consumableMembers.isEmpty())
members.addAll(consumableMembers);
@@ -437,9 +442,7 @@ public class J2EEFlexProjDeployable extends ComponentDeployable implements IJ2EE
if (!members.contains(mr[j]))
members.add(mr[j]);
}
- List utilMembers = getUtilMembers(consumedComponent);
- if (!utilMembers.isEmpty())
- members.addAll(utilMembers);
+ addUtilMembers(consumedComponent);
List childConsumableMembers = getConsumableReferencedMembers(consumedComponent);
if (!childConsumableMembers.isEmpty())
members.addAll(childConsumableMembers);
@@ -463,9 +466,37 @@ public class J2EEFlexProjDeployable extends ComponentDeployable implements IJ2EE
protected IModule gatherModuleReference(IVirtualComponent component, IVirtualComponent targetComponent ) {
IModule module = super.gatherModuleReference(component, targetComponent);
- // Handle binary module components
- if (J2EEProjectUtilities.isEARProject(component.getProject()) && targetComponent instanceof J2EEModuleVirtualArchiveComponent)
- module = ServerUtil.getModule(J2EEDeployableFactory.ID+":"+targetComponent.getName()); //$NON-NLS-1$
+ // Handle binary module components
+ if (targetComponent instanceof J2EEModuleVirtualArchiveComponent) {
+ if (J2EEProjectUtilities.isEARProject(component.getProject()) || targetComponent.getProject()!=component.getProject())
+ module = ServerUtil.getModule(J2EEDeployableFactory.ID+":"+targetComponent.getName()); //$NON-NLS-1$
+ }
return module;
}
+
+ /**
+ * Determine if the component is nested J2EE module on the application.xml of this EAR
+ * @param aComponent
+ * @return boolean is passed in component a nested J2EE module on this EAR
+ */
+ private boolean isNestedJ2EEModule(IVirtualComponent aComponent, IVirtualReference[] references, EARArtifactEdit edit) {
+ if (edit==null)
+ return false;
+ Application app = edit.getApplication();
+ IVirtualReference reference = getReferenceNamed(references,aComponent.getName());
+ // Ensure module URI exists on EAR DD for binary archive
+ return app.getFirstModule(reference.getArchiveName()) != null;
+ }
+
+ private IVirtualReference getReferenceNamed(IVirtualReference[] references, String name) {
+ for (int i=0; i<references.length; i++) {
+ if (references[i].getReferencedComponent().getName().equals(name))
+ return references[i];
+ }
+ return null;
+ }
+
+ protected ArtifactEdit getComponentArtifactEditForRead() {
+ return EARArtifactEdit.getEARArtifactEditForRead(component.getProject());
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java
index 6cb2304bd..8473000a3 100644
--- a/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java
+++ b/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java
@@ -26,6 +26,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.ArtifactEdit;
import org.eclipse.wst.common.componentcore.ComponentCore;
import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent;
import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
@@ -62,7 +63,9 @@ public abstract class ComponentDeployable extends ProjectModule {
* @see org.eclipse.jst.server.core.IJ2EEModule#isBinary()
*/
public boolean isBinary() {
- return false;
+ if (component==null)
+ return false;
+ return component.isBinary();
}
private void addMembersToModuleFolder(ModuleFolder mf, IModuleResource[] mr) {
@@ -103,8 +106,10 @@ public abstract class ComponentDeployable extends ProjectModule {
protected IModule gatherModuleReference(IVirtualComponent component, IVirtualComponent targetComponent ) {
// Handle workspace project module components
- if (targetComponent != null && targetComponent.getProject()!=component.getProject())
- return ServerUtil.getModule(targetComponent.getProject());
+ if (targetComponent != null && targetComponent.getProject()!=component.getProject()) {
+ if (!targetComponent.isBinary())
+ return ServerUtil.getModule(targetComponent.getProject());
+ }
return null;
}
@@ -293,9 +298,7 @@ public abstract class ComponentDeployable extends ProjectModule {
if (!members.contains(mr[j]))
members.add(mr[j]);
}
- List utilMembers = getUtilMembers(vc);
- if (!utilMembers.isEmpty())
- members.addAll(utilMembers);
+ addUtilMembers(vc);
}
IModuleResource[] mr = new IModuleResource[members.size()];
@@ -303,47 +306,56 @@ public abstract class ComponentDeployable extends ProjectModule {
return mr;
}
- protected boolean shouldIncludeUtilityComponent(IVirtualComponent virtualComp) {
- return virtualComp != null && virtualComp.isBinary();
+ protected boolean shouldIncludeUtilityComponent(IVirtualComponent virtualComp, IVirtualReference[] references, ArtifactEdit edit) {
+ return virtualComp != null && virtualComp.isBinary() && virtualComp.getProject()==component.getProject();
}
- protected List getUtilMembers(IVirtualComponent vc) {
- List utilMembers = new ArrayList();
- IVirtualReference[] components = vc.getReferences();
- for (int i = 0; i < components.length; i++) {
- IVirtualReference reference = components[i];
- IVirtualComponent virtualComp = reference.getReferencedComponent();
- if (shouldIncludeUtilityComponent(virtualComp)) {
- IPath archivePath = ((VirtualArchiveComponent)virtualComp).getWorkspaceRelativePath();
- ModuleFile mf = null;
- if (archivePath != null) { //In Workspace
- IFile utilFile = ResourcesPlugin.getWorkspace().getRoot().getFile(archivePath);
- mf = new ModuleFile(utilFile, utilFile.getName(), reference.getRuntimePath().makeRelative());
- }
- else {
- File extFile = ((VirtualArchiveComponent)virtualComp).getUnderlyingDiskFile();
- mf = new ModuleFile(extFile, extFile.getName(), reference.getRuntimePath().makeRelative());
- }
- if (mf == null)
- continue;
- IModuleResource moduleParent = getExistingModuleResource(members, mf.getModuleRelativePath());
-
- if (moduleParent != null && moduleParent instanceof ModuleFolder)
- addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[]{mf});
- else {
- if (mf.getModuleRelativePath().isEmpty())
- members.add(mf);
+ protected void addUtilMembers(IVirtualComponent vc) {
+ ArtifactEdit edit = null;
+ try {
+ edit = getComponentArtifactEditForRead();
+ IVirtualReference[] components = vc.getReferences();
+ for (int i = 0; i < components.length; i++) {
+ IVirtualReference reference = components[i];
+ IVirtualComponent virtualComp = reference.getReferencedComponent();
+ if (shouldIncludeUtilityComponent(virtualComp,components,edit)) {
+ IPath archivePath = ((VirtualArchiveComponent)virtualComp).getWorkspaceRelativePath();
+ ModuleFile mf = null;
+ if (archivePath != null) { //In Workspace
+ IFile utilFile = ResourcesPlugin.getWorkspace().getRoot().getFile(archivePath);
+ mf = new ModuleFile(utilFile, utilFile.getName(), reference.getRuntimePath().makeRelative());
+ }
+ else {
+ File extFile = ((VirtualArchiveComponent)virtualComp).getUnderlyingDiskFile();
+ mf = new ModuleFile(extFile, extFile.getName(), reference.getRuntimePath().makeRelative());
+ }
+ if (mf == null)
+ continue;
+ IModuleResource moduleParent = getExistingModuleResource(members, mf.getModuleRelativePath());
+
+ if (moduleParent != null && moduleParent instanceof ModuleFolder)
+ addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[]{mf});
else {
- if (moduleParent == null)
- moduleParent = ensureParentExists(mf.getModuleRelativePath(), (IContainer)vc.getRootFolder().getUnderlyingResource());
- addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[] {mf});
+ if (mf.getModuleRelativePath().isEmpty())
+ members.add(mf);
+ else {
+ if (moduleParent == null)
+ moduleParent = ensureParentExists(mf.getModuleRelativePath(), (IContainer)vc.getRootFolder().getUnderlyingResource());
+ addMembersToModuleFolder((ModuleFolder)moduleParent, new IModuleResource[] {mf});
+ }
}
}
- }
- }
- return utilMembers;
+ }
+ } finally {
+ if (edit!=null)
+ edit.dispose();
+ }
}
+ protected ArtifactEdit getComponentArtifactEditForRead() {
+ return null;
+ }
+
protected static boolean isProjectOfType(IProject project, String typeID) {
IFacetedProject facetedProject = null;
try {

Back to the top