### Eclipse Workspace Patch 1.0 #P org.eclipse.jst.jee.ui Index: src/org/eclipse/jst/jee/ui/internal/deployables/EJBDeployableArtifactAdapterUtil.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee.ui/src/org/eclipse/jst/jee/ui/internal/deployables/EJBDeployableArtifactAdapterUtil.java,v retrieving revision 1.11 diff -u -r1.11 EJBDeployableArtifactAdapterUtil.java --- src/org/eclipse/jst/jee/ui/internal/deployables/EJBDeployableArtifactAdapterUtil.java 13 Oct 2009 17:25:11 -0000 1.11 +++ src/org/eclipse/jst/jee/ui/internal/deployables/EJBDeployableArtifactAdapterUtil.java 20 Nov 2009 21:08:57 -0000 @@ -26,13 +26,13 @@ import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jem.util.emf.workbench.ProjectUtilities; import org.eclipse.jst.j2ee.internal.J2EEConstants; +import org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable; import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; import org.eclipse.jst.javaee.ejb.EJBJar; import org.eclipse.jst.javaee.ejb.EntityBean; import org.eclipse.jst.javaee.ejb.MessageDrivenBean; import org.eclipse.jst.javaee.ejb.SessionBean; -import org.eclipse.jst.jee.internal.deployables.JEEFlexProjDeployable; import org.eclipse.jst.jee.ui.plugin.JEEUIPlugin; import org.eclipse.jst.server.core.EJBBean; import org.eclipse.wst.common.componentcore.ComponentCore; @@ -214,7 +214,7 @@ String jndiName = null; if (ejbName != null) { module.loadAdapter(ModuleDelegate.class, new NullProgressMonitor()); - JEEFlexProjDeployable moduleDelegate = (JEEFlexProjDeployable)module.getAdapter(ModuleDelegate.class); + J2EEFlexProjDeployable moduleDelegate = (J2EEFlexProjDeployable)module.getAdapter(ModuleDelegate.class); jndiName = moduleDelegate.getJNDIName(ejbName); return new EJBBean(module, jndiName, remote, local,EJBBean.EJB_30); } @@ -228,7 +228,7 @@ String jndiName = null; if (ejbName != null) { module.loadAdapter(ModuleDelegate.class, new NullProgressMonitor()); - JEEFlexProjDeployable moduleDelegate = (JEEFlexProjDeployable)module.getAdapter(ModuleDelegate.class); + J2EEFlexProjDeployable moduleDelegate = (J2EEFlexProjDeployable)module.getAdapter(ModuleDelegate.class); jndiName = moduleDelegate.getJNDIName(ejbName, interfaceName); return new EJBBean(module, jndiName, remote, local,EJBBean.EJB_30, interfaceName); } #P org.eclipse.jst.jee Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee/plugin.xml,v retrieving revision 1.23 diff -u -r1.23 plugin.xml --- plugin.xml 18 Nov 2009 22:26:25 -0000 1.23 +++ plugin.xml 20 Nov 2009 21:08:59 -0000 @@ -83,38 +83,6 @@ - - - - - - - - - - - - - - - - moduleDelegates = new HashMap(5); #P org.eclipse.wst.web Index: static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.wst.web/static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java,v retrieving revision 1.22 diff -u -r1.22 ComponentDeployable.java --- static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java 9 Jun 2009 19:57:24 -0000 1.22 +++ static_web_project/org/eclipse/wst/web/internal/deployables/ComponentDeployable.java 20 Nov 2009 21:09:02 -0000 @@ -37,17 +37,17 @@ import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.ServerUtil; -import org.eclipse.wst.server.core.internal.ModuleFile; -import org.eclipse.wst.server.core.internal.ModuleFolder; import org.eclipse.wst.server.core.model.IModuleFile; import org.eclipse.wst.server.core.model.IModuleFolder; import org.eclipse.wst.server.core.model.IModuleResource; +import org.eclipse.wst.server.core.util.ModuleFile; +import org.eclipse.wst.server.core.util.ModuleFolder; import org.eclipse.wst.server.core.util.ProjectModule; public abstract class ComponentDeployable extends ProjectModule { protected IVirtualComponent component = null; - protected List members = new ArrayList(); + protected List members = new ArrayList(); public ComponentDeployable(IProject project) { this(project,ComponentCore.createComponent(project)); @@ -72,7 +72,7 @@ * @param ModuleFolder mf * @param IModuleResource[] mr */ - private void addMembersToModuleFolder(ModuleFolder mf, IModuleResource[] mr) { + protected void addMembersToModuleFolder(ModuleFolder mf, IModuleResource[] mr) { // If the folder is null or the resources to add are null or empty, bail and return if (mf == null || mr == null || mr.length==0) return; @@ -105,7 +105,7 @@ } public IModule[] getModules() { - List modules = new ArrayList(); + List modules = new ArrayList(); if (component != null) { IVirtualReference[] components = getReferences(component); for (int i = 0; i < components.length; i++) { @@ -118,7 +118,7 @@ } } } - return (IModule[]) modules.toArray(new IModule[modules.size()]); + return modules.toArray(new IModule[modules.size()]); } protected IVirtualReference[] getReferences(IVirtualComponent aComponent) { @@ -148,7 +148,7 @@ protected IModuleResource[] getMembers(IContainer cont, IPath path, IPath javaPath, IContainer[] javaCont) throws CoreException { IResource[] res = cont.members(); int size2 = res.length; - List list = new ArrayList(size2); + List list = new ArrayList(size2); for (int j = 0; j < size2; j++) { if (res[j] instanceof IContainer) { IContainer cc = (IContainer) res[j]; @@ -196,13 +196,13 @@ } protected IModuleFile createModuleFile(final IFile file, final IPath path) { - return new ModuleFile(file, file.getName(), path, file.getModificationStamp() + file.getLocalTimeStamp()); + return new ModuleFile(file, file.getName(), path); } protected IModuleResource[] getMembers(IVirtualContainer cont, IPath path) throws CoreException { IVirtualResource[] res = cont.members(); int size2 = res.length; - List list = new ArrayList(size2); + List list = new ArrayList(size2); for (int j = 0; j < size2; j++) { if (res[j] instanceof IVirtualContainer) { IVirtualContainer cc = (IVirtualContainer) res[j]; #P org.eclipse.jst.j2ee Index: j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java,v retrieving revision 1.55 diff -u -r1.55 J2EEDeployableFactory.java --- j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java 10 Jun 2009 19:19:02 -0000 1.55 +++ j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEDeployableFactory.java 20 Nov 2009 21:09:05 -0000 @@ -91,21 +91,17 @@ List projectModules = new ArrayList(); try { - if (J2EEProjectUtilities.isLegacyJ2EEProject(component.getProject())) { - IModule module = null; - String type = JavaEEProjectUtilities.getJ2EEProjectType(component.getProject()); - String version = J2EEProjectUtilities.getJ2EEProjectVersion(component.getProject()); - module = createModule(component.getDeployedName(), component.getDeployedName(), type, version, component.getProject()); - J2EEFlexProjDeployable moduleDelegate = new J2EEFlexProjDeployable(component.getProject(), component); - moduleDelegates.put(module, moduleDelegate); - projectModules.add(module); - - // Check to add any binary modules - if (J2EEProjectUtilities.ENTERPRISE_APPLICATION.equals(type)) - projectModules.addAll(createBinaryModules(component)); - } else { - return null; - } + IModule module = null; + String type = JavaEEProjectUtilities.getJ2EEProjectType(component.getProject()); + String version = J2EEProjectUtilities.getJ2EEProjectVersion(component.getProject()); + module = createModule(component.getDeployedName(), component.getDeployedName(), type, version, component.getProject()); + J2EEFlexProjDeployable moduleDelegate = new J2EEFlexProjDeployable(component.getProject(), component); + moduleDelegates.put(module, moduleDelegate); + projectModules.add(module); + + // Check to add any binary modules + if (J2EEProjectUtilities.ENTERPRISE_APPLICATION.equals(type)) + projectModules.addAll(createBinaryModules(component)); } catch (Exception e) { J2EEPlugin.logError(e); } @@ -166,7 +162,6 @@ } } } - return projectModules; } Index: j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java,v retrieving revision 1.99 diff -u -r1.99 J2EEFlexProjDeployable.java --- j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java 10 Nov 2009 19:35:08 -0000 1.99 +++ j2eeplugin/org/eclipse/jst/j2ee/internal/deployables/J2EEFlexProjDeployable.java 20 Nov 2009 21:09:06 -0000 @@ -11,19 +11,21 @@ package org.eclipse.jst.j2ee.internal.deployables; import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.net.URL; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Properties; -import java.util.Set; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; @@ -31,28 +33,31 @@ import org.eclipse.core.runtime.IPath; 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.common.jdt.internal.javalite.JavaLiteUtilities; -import org.eclipse.jst.j2ee.application.Application; -import org.eclipse.jst.j2ee.classpathdep.ClasspathDependencyUtil; -import org.eclipse.jst.j2ee.classpathdep.IClasspathDependencyConstants; +import org.eclipse.jst.j2ee.commonarchivecore.internal.util.ArchiveUtil; import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; -import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualComponent; import org.eclipse.jst.j2ee.componentcore.util.EARArtifactEdit; import org.eclipse.jst.j2ee.ejb.EJBJar; import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper; import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager; import org.eclipse.jst.j2ee.internal.J2EEConstants; -import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyManifestUtil; -import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyVirtualComponent; -import org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper; +import org.eclipse.jst.j2ee.internal.archive.ComponentArchiveLoadAdapter; +import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities; +import org.eclipse.jst.j2ee.internal.archive.JavaEEArchiveUtilities.JavaEEWrappingLoadAdapter; +import org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentLoadAdapter; import org.eclipse.jst.j2ee.internal.plugin.IJ2EEModuleConstants; import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; -import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; +import org.eclipse.jst.j2ee.model.IModelProvider; +import org.eclipse.jst.j2ee.model.ModelProviderManager; import org.eclipse.jst.j2ee.project.EarUtilities; import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; -import org.eclipse.jst.jee.util.internal.JavaEEQuickPeek; +import org.eclipse.jst.javaee.ejb.EnterpriseBeans; +import org.eclipse.jst.javaee.ejb.SessionBean; +import org.eclipse.jst.jee.archive.ArchiveOpenFailureException; +import org.eclipse.jst.jee.archive.IArchive; +import org.eclipse.jst.jee.archive.IArchiveLoadAdapter; +import org.eclipse.jst.jee.archive.IArchiveResource; import org.eclipse.jst.server.core.IApplicationClientModule; import org.eclipse.jst.server.core.IConnectorModule; import org.eclipse.jst.server.core.IEJBModule; @@ -60,20 +65,13 @@ import org.eclipse.jst.server.core.IWebModule; import org.eclipse.wst.common.componentcore.ArtifactEdit; import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.internal.ComponentResource; -import org.eclipse.wst.common.componentcore.internal.Property; -import org.eclipse.wst.common.componentcore.internal.StructureEdit; -import org.eclipse.wst.common.componentcore.internal.WorkbenchComponent; import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; import org.eclipse.wst.common.componentcore.internal.util.ComponentUtilities; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; import org.eclipse.wst.common.componentcore.resources.IVirtualReference; import org.eclipse.wst.server.core.IModule; import org.eclipse.wst.server.core.ServerUtil; import org.eclipse.wst.server.core.model.IModuleFile; -import org.eclipse.wst.server.core.model.IModuleFolder; import org.eclipse.wst.server.core.model.IModuleResource; import org.eclipse.wst.server.core.util.ModuleFile; import org.eclipse.wst.server.core.util.ModuleFolder; @@ -84,15 +82,13 @@ public class J2EEFlexProjDeployable extends ComponentDeployable implements IEnterpriseApplication, IApplicationClientModule, IConnectorModule, IEJBModule, IWebModule { - protected static final IPath WEB_CLASSES_PATH = new Path(J2EEConstants.WEB_INF_CLASSES); + protected static final IPath MANIFEST_PATH = new Path(J2EEConstants.MANIFEST_URI); - protected static IPath WEBLIB = new Path(J2EEConstants.WEB_INF_LIB).makeAbsolute(); - private static String USE_SINGLE_ROOT_PROPERTY = "useSingleRoot"; //$NON-NLS-1$ - protected IPackageFragmentRoot[] cachedSourceContainers; + protected static IPath WEBLIB = new Path(J2EEConstants.WEB_INF_LIB); + protected IContainer[] cachedOutputContainers; - protected HashMap cachedOutputMappings; - protected HashMap cachedSourceOutputPairs; - protected List classpathComponentDependencyURIs = new ArrayList(); + protected ComponentArchiveLoadAdapter cLoadAdapter; + protected Map moduleFolderCache = new HashMap(); /** * Constructor for J2EEFlexProjDeployable. @@ -115,17 +111,6 @@ } /** - * Returns the root folders for the resources in this module. - * The implementation was no different than the superclass implementation; - * - * @return a possibly-empty array of resource folders - */ - @Override - public IContainer[] getResourceFolders() { - return super.getResourceFolders(); - } - - /** * Returns the root folders containing Java output in this module. * * @return a possibly-empty array of Java output folders @@ -142,245 +127,167 @@ List l = JavaLiteUtilities.getJavaOutputContainers(component); return l.toArray(new IContainer[l.size()]); } - - @Override - 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 (JavaEEProjectUtilities.isEARProject(component.getProject())) { - return virtualComp != null && virtualComp.isBinary() && !isNestedJ2EEModule(virtualComp, references, (EARArtifactEdit)edit); - } - return super.shouldIncludeUtilityComponent(virtualComp, references, edit); - } - - @Override - protected void addUtilMember(IVirtualComponent parent, IVirtualReference reference, IPath runtimePath) { - // do not add classpath dependencies whose runtime path (../) maps to the parent component or that represent - // class folders - if (!runtimePath.equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH) - && !ClasspathDependencyUtil.isClassFolderReference(reference)) { - super.addUtilMember(parent, reference, runtimePath); - } - } - - protected IModuleResource[] getBinaryModuleMembers() { - IPath archivePath = ((J2EEModuleVirtualArchiveComponent)component).getWorkspaceRelativePath(); - ModuleFile mf = null; - if (archivePath != null) { //In Workspace - IFile utilFile = ResourcesPlugin.getWorkspace().getRoot().getFile(archivePath); - mf = new ModuleFile(utilFile, utilFile.getName(), ((J2EEModuleVirtualArchiveComponent)component).getRuntimePath().makeRelative()); - } else { - File extFile = ((J2EEModuleVirtualArchiveComponent)component).getUnderlyingDiskFile(); - if( extFile != null ) - mf = new ModuleFile(extFile, extFile.getName(), ((J2EEModuleVirtualArchiveComponent)component).getRuntimePath().makeRelative()); - } - return mf == null ? new IModuleResource[]{} : new IModuleResource[] {mf}; - } @Override public IModuleResource[] members() throws CoreException { members.clear(); - classpathComponentDependencyURIs.clear(); - cachedSourceContainers = null; - getSourceContainers(); // set the cache - - // Handle binary components - if (component instanceof J2EEModuleVirtualArchiveComponent) - return getBinaryModuleMembers(); - - if (JavaEEProjectUtilities.isEARProject(component.getProject())) { - // If an EAR, add classpath contributions for all referenced modules - addReferencedComponentClasspathDependencies(component, false); - } else { - if (JavaEEProjectUtilities.isDynamicWebProject(component.getProject())) { - // If a web, add classpath contributions for all WEB-INF/lib modules - addReferencedComponentClasspathDependencies(component, true); - } - if (canExportClasspathComponentDependencies(component)){ - saveClasspathDependencyURIs(component); - } - // Add all Java output folders that have publish/export attributes - addClassFolderDependencies(component); - } - - if( isForceSingleRoot()) - return getOptimizedMembers(); - + moduleFolderCache.clear(); + IArchive archive = null; try { - - /* - * This section will traverse the VCF and create all the - * ModuleFile and ModuleFolder objects needed. - * The impl. is a bit odd. Unseen-before folders - * are automatically added to "members", but unseen files - * are instead returned via the return value. - * The upstream impl could benefit from cleanup - */ - - if (component != null) { - IVirtualFolder vFolder = component.getRootFolder(); - IModuleResource[] mr = getMembers(vFolder, Path.EMPTY); - int size = mr.length; - for (int j = 0; j < size; j++) { - members.add(mr[j]); - } - - addRelevantOutputFolders(); - - if (component != null) { - addUtilMembers(component); - List consumableMembers = getConsumableReferencedMembers(component); - if (!consumableMembers.isEmpty()) - members.addAll(consumableMembers); + archive = JavaEEArchiveUtilities.INSTANCE.openArchive(component); + IArchiveLoadAdapter loadAdapter = archive.getLoadAdapter(); + if (loadAdapter instanceof ComponentArchiveLoadAdapter) { + cLoadAdapter = (ComponentArchiveLoadAdapter)loadAdapter; + cLoadAdapter.setExportSource(false); + //if a single-root structure is found the load adapter will optimize members + cLoadAdapter.setOptimizeMembers(true); + + List archiveResources = archive.getArchiveResources(); + for (Iterator iterator = archiveResources.iterator(); iterator.hasNext();) { + IArchiveResource archiveResource = iterator.next(); + IPath deployPath = archiveResource.getPath(); + if (archiveResource.getType() == IArchiveResource.FILE_TYPE) { + if (deployPath.removeLastSegments(1).equals(WEBLIB)) { + gatherWebLibMembers(deployPath); + } + else { + IResource resource = cLoadAdapter.getWorkbenchResources(deployPath); + if (resource != null && (resource instanceof IFile)) { + IFile file = (IFile) resource; + IModuleFile moduleFile = new ModuleFile(file, file.getName(), deployPath.removeLastSegments(1)); + if (deployPath.equals(MANIFEST_PATH) && cLoadAdapter.shouldUpdateManifest(archiveResource)) { + moduleFile = replaceManifestFile(archiveResource, moduleFile); + } + gatherFileMembers(deployPath, moduleFile); + } + } + } + else if (archiveResource.getType() == IArchiveResource.ARCHIVE_TYPE) { + IArchiveLoadAdapter nestedLoadAdapter = ((IArchive)archiveResource).getLoadAdapter(); + IArchiveLoadAdapter lAdapter = null; + + if (nestedLoadAdapter instanceof JavaEEWrappingLoadAdapter) { + lAdapter = ((JavaEEWrappingLoadAdapter) nestedLoadAdapter).getWrappedLoadAdatper(); + } + else { + lAdapter = nestedLoadAdapter; + } + + if (lAdapter instanceof JavaEEBinaryComponentLoadAdapter){ + VirtualArchiveComponent vComponent = ((JavaEEBinaryComponentLoadAdapter) lAdapter).getArchiveComponent(); + gatherBinaryMembers(vComponent, archiveResource.getPath()); + } + } + else if (archiveResource.getType() == IArchiveResource.DIRECTORY_TYPE) { + gatherFolderMembers(deployPath); + } } } - - IModuleResource[] mr = new IModuleResource[members.size()]; - members.toArray(mr); - return mr; + } catch (ArchiveOpenFailureException e) { + J2EEPlugin.logError(e); } finally { - cachedSourceContainers = null; - cachedOutputContainers = null; - cachedOutputMappings = null; - cachedSourceOutputPairs = null; + if (null != archive) { + JavaEEArchiveUtilities.INSTANCE.closeArchive(archive); + } + } + IModuleResource[] mr = new IModuleResource[members.size()]; + members.toArray(mr); + return mr; + } + + private void gatherWebLibMembers(IPath deployPath) { + IModuleFile moduleFile = null; + IResource webLibFile = cLoadAdapter.getWorkbenchResources(deployPath); + if (webLibFile != null && (webLibFile instanceof IFile)) { + moduleFile = new ModuleFile(((IFile)webLibFile), webLibFile.getName(), deployPath.removeLastSegments(1)); + } + else { + File extFile = cLoadAdapter.getExternalFiles(deployPath); + if (extFile == null) return; + moduleFile = new ModuleFile(extFile, extFile.getName(), deployPath.removeLastSegments(1)); } + gatherFileMembers(deployPath, moduleFile); } - /* - * This method was separated out because previously the paths that designated - * where to put these files was completely ignoring the component.xml - * and was instead making assumptions based on project type. - */ - protected void addRelevantOutputFolders() throws CoreException { - StructureEdit edit = null; - try { - edit = StructureEdit.getStructureEditForRead(getProject()); - if (edit == null || edit.getComponent() == null) - return; - List resourceMaps = edit.getComponent().getResources(); - ComponentResource source; - List addedOutputFolders = new ArrayList(); - for( int i = 0; i < resourceMaps.size(); i++ ) { - source = ((ComponentResource)resourceMaps.get(i)); - if( isSourceContainer(source)) { - IContainer out = getOutputContainerIfExists(source.getSourcePath()); - if (out == null || ComponentCore.createResources(out).length > 0 || addedOutputFolders.contains(out)) - continue; - addedOutputFolders.add(out); - IModuleResource[] mr = getMembers(out, - source.getRuntimePath().makeRelative(), - source.getRuntimePath().makeRelative(), - getJavaOutputFolders()); - int size2 = mr.length; - for (int j = 0; j < size2; j++) { - members.add(mr[j]); - } - } - } - } finally { - if( edit != null ) - edit.dispose(); + private void gatherBinaryMembers(VirtualArchiveComponent virtualComp, IPath deployPath) { + IModuleFile moduleFile = null; + final IPath archivePath = virtualComp.getWorkspaceRelativePath(); + if (archivePath != null) { //in Workspace + IFile utilFile = ResourcesPlugin.getWorkspace().getRoot().getFile(archivePath); + moduleFile = new ModuleFile(utilFile, utilFile.getName(), deployPath.removeLastSegments(1)); + } + else { //outside of workspace + File extFile = virtualComp.getUnderlyingDiskFile(); + moduleFile = new ModuleFile(extFile, extFile.getName(), deployPath.removeLastSegments(1)); } + gatherFileMembers(deployPath, moduleFile); } - protected boolean hasConsumableReferences(IVirtualComponent vc) { - IVirtualReference[] refComponents = vc.getReferences(); - for (int i = 0; i < refComponents.length; i++) { - IVirtualReference reference = refComponents[i]; - if (reference != null && reference.getDependencyType()==IVirtualReference.DEPENDENCY_TYPE_CONSUMES) - return true; - } - return false; - } + + private void gatherFileMembers(IPath deployPath, IModuleFile moduleFile) { + if (deployPath.segmentCount() > 1) { + ModuleFolder moduleFolder = gatherFolderMembers(deployPath.removeLastSegments(1)); + addMembersToModuleFolder(moduleFolder, new IModuleResource[] {moduleFile}); + } + else { + members.add(moduleFile); + } + } - @Override - protected IModuleFile createModuleFile(IFile file, IPath path) { - // if this is the MANIFEST.MF file and we have classpath component dependencies, - // update it - return replaceManifestFile(super.createModuleFile(file, path)); + private ModuleFolder gatherFolderMembers(IPath path) { + ModuleFolder existingEntry = moduleFolderCache.get(path); + if (existingEntry != null) { + return existingEntry; + } + IResource resource = cLoadAdapter.getWorkbenchResources(path); + if (resource == null || !(resource instanceof IContainer)) + return null; + + IContainer modContainer = (IContainer) resource; + ModuleFolder newEntry = new ModuleFolder(modContainer, path.lastSegment(), path.removeLastSegments(1)); + moduleFolderCache.put(path, newEntry); + + if (path.segmentCount() > 1) { + ModuleFolder parent = gatherFolderMembers(path.removeLastSegments(1)); + addMembersToModuleFolder(parent, new IModuleResource[] {newEntry}); + } + else { + members.add(newEntry); + } + return newEntry; } - protected IModuleFile replaceManifestFile(IModuleFile moduleFile) { + protected IModuleFile replaceManifestFile(IArchiveResource archiveResource, IModuleFile moduleFile) { final IFile file = (IFile) moduleFile.getAdapter(IFile.class); - final IPath path = moduleFile.getModuleRelativePath(); // if the MANIFEST.MF is being requested and we have classpath component dependencies, // dynamically generate a customized MANIFEST.MF and return that - if (path.append(file.getName()).equals(MANIFEST_PATH) && !classpathComponentDependencyURIs.isEmpty()) { - final IProject project = file.getProject(); - final IPath workingLocation = project.getWorkingLocation(J2EEPlugin.PLUGIN_ID); - // create path to temp MANIFEST.MF - final IPath tempManifestPath = workingLocation.append(MANIFEST_PATH); - final File fsFile = tempManifestPath.toFile(); - if (!fsFile.exists()) { - // create parent dirs for temp MANIFEST.MF - final File parent = fsFile.getParentFile(); - if (!parent.exists()) { - if (!parent.mkdirs()) { - return moduleFile; - } + final IProject project = file.getProject(); + final IPath workingLocation = project.getWorkingLocation(J2EEPlugin.PLUGIN_ID); + // create path to temp MANIFEST.MF + final IPath tempManifestPath = workingLocation.append(MANIFEST_PATH); + final File tempFile = tempManifestPath.toFile(); + if (!tempFile.exists()) { + // create parent dirs for temp MANIFEST.MF + final File parent = tempFile.getParentFile(); + if (!parent.exists()) { + if (!parent.mkdirs()) { + return moduleFile; } } - // create temp MANIFEST.MF using util method - try { - ClasspathDependencyManifestUtil.updateManifestClasspath(file, classpathComponentDependencyURIs, fsFile); - // create new ModuleFile that points to temp MANIFEST.MF - return new ModuleFile(fsFile, file.getName(), path); - } catch (IOException ioe) { - return moduleFile; - } + } + try { + InputStream in = cLoadAdapter.getInputStream(archiveResource); + OutputStream out = new FileOutputStream(tempFile); + ArchiveUtil.copy(in, out); + } catch (FileNotFoundException e) { + return moduleFile; + } catch (IOException e) { + return moduleFile; } return moduleFile; } - @Override - protected IModuleResource[] handleJavaPath(IPath path, IPath javaPath, IPath curPath, IContainer[] javaCont, IModuleResource[] moduleResource, IContainer cc) throws CoreException { - IModuleResource [] mr = moduleResource; - if (curPath.equals(javaPath)) { - int size = javaCont.length; - for (int i = 0; i < size; i++) { - IModuleResource[] mr2 = getMembers(javaCont[i], path.append(cc.getName()), null, null); - IModuleResource[] mr3 = new IModuleResource[mr.length + mr2.length]; - System.arraycopy(mr, 0, mr3, 0, mr.length); - System.arraycopy(mr2, 0, mr3, mr.length, mr2.length); - mr = mr3; - } - } else { - boolean containsFolder = false; - String name = javaPath.segment(curPath.segmentCount()); - int size = mr.length; - for (int i = 0; i < size && !containsFolder; i++) { - if (mr[i] instanceof IModuleFolder) { - IModuleFolder mf2 = (IModuleFolder) mr[i]; - if (name.equals(mf2.getName())) { - containsFolder = true; - } - } - } - - if (!containsFolder && javaCont.length > 0) { - ModuleFolder mf2 = new ModuleFolder(javaCont[0], name, curPath); - IModuleResource[] mrf = new IModuleResource[0]; - size = javaCont.length; - for (int i = 0; i < size; i++) { - IModuleResource[] mrf2 = getMembers(javaCont[i], javaPath, null, null); - IModuleResource[] mrf3 = new IModuleResource[mrf.length + mrf2.length]; - System.arraycopy(mrf, 0, mrf3, 0, mrf.length); - System.arraycopy(mrf2, 0, mrf3, mrf.length, mrf2.length); - mrf = mrf3; - } - - mf2.setMembers(mrf); - - IModuleResource[] mr3 = new IModuleResource[mr.length + 1]; - System.arraycopy(mr, 0, mr3, 0, mr.length); - mr3[mr.length] = mf2; - mr = mr3; - } - } - return mr; - } /** * Returns the classpath as a list of absolute IPaths. @@ -420,7 +327,26 @@ return null; } - /** + + public String getJNDIName(String ejbName, String interfaceName) { + if (!JavaEEProjectUtilities.isEJBProject(component.getProject())) + return null; + + EjbModuleExtensionHelper modHelper = null; + org.eclipse.jst.javaee.ejb.EJBJar jar = null; + + IModelProvider model = ModelProviderManager.getModelProvider(component.getProject()); + if (model != null) { + jar = (org.eclipse.jst.javaee.ejb.EJBJar) model.getModelObject(); + SessionBean bean = getSessionBeanNamed(jar, ejbName); + modHelper = IEJBModelExtenderManager.INSTANCE.getEJBModuleExtension(null); + return modHelper == null ? null : modHelper.getJavaEEJNDIName(jar, bean, interfaceName); + } + return null; + } + + + /** * This method will handle a number of J2EE related scenarios. If this is an ear and a child module is passed in, * the URI for that child module will be returned. If no child module was passed, the URI of the EAR is returned. * If this is a child component and the module passed in is the EAR, we grab the module uri for this compared to that @@ -545,6 +471,20 @@ } /** + * Return List of Session beans in this jar. + * @return java.util.List + */ + public SessionBean getSessionBeanNamed(org.eclipse.jst.javaee.ejb.EJBJar jar, String beanName) { + EnterpriseBeans allBeans = jar.getEnterpriseBeans(); + for (Iterator iterator = allBeans.getSessionBeans().iterator(); iterator.hasNext();) { + SessionBean bean = (SessionBean) iterator.next(); + if (bean.getEjbName().equals(beanName)) + return bean; + } + return null; + } + + /** * This method returns the context root property from the deployable project's .component file */ public String getContextRoot() { @@ -580,88 +520,6 @@ return contextRoot; } - /** - * Find the source container, if any, for the given file. - * - * @param file - * @return IPackageFragmentRoot sourceContainer for IFile - */ - protected IPackageFragmentRoot getSourceContainer(IResource file) { - if (file == null) - return null; - IPackageFragmentRoot[] srcContainers = getSourceContainers(); - for (int i=0; itrue if this module has a simple structure based on a - * single root folder, and false otherwise. - *

- * In a single root structure, all files that are contained within the root folder - * are part of the module, and are already in the correct module structure. No - * module resources exist outside of this single folder. - * - * For J2EE, this method will check if the project is already in J2EE spec standard output form. - * The project must follow certain rules, but in general, the project's content roots must be source folders - * and the output folder must also be the the content root folder. - *

- * - * @return true if this module has a single root structure, and - * false otherwise - */ - @Override - public boolean isSingleRootStructure() { - return isForceSingleRoot() || getSingleRoot() != null; - } - - /** - * Will attempt to return the IContainer that counts as the "single-root". - * If this module does not qualify as a "single-root" module, this - * method will return null. Otherwise it will return an IContainer - * that may be used as the single root container. - * - * @return - */ - - public IContainer getSingleRoot() { - StructureEdit edit = null; - try { - edit = StructureEdit.getStructureEditForRead(getProject()); - if (edit == null || edit.getComponent() == null) - return null; - - // 229650 - check to see if the property 'useSingleRoot' is defined. - // The force status will be checked until a suitable root folder is found - boolean forceSingleRoot = isForceSingleRoot(edit); - - // if there are any consumed references, this is not single root - if( hasConsumableReferences(component) && !forceSingleRoot) - return null; - - // if there are any linked resources in the workspace under this folder, - // then this is not a single root module - if (rootFoldersHaveLinkedContent() && !forceSingleRoot) - return null; - - // Always return false for EARs so that members for EAR - // are always calculated and j2ee modules are filtered out - if (JavaEEProjectUtilities.isEARProject(getProject()) && !forceSingleRoot) - return null; - - List resourceMaps = edit.getComponent().getResources(); - - // No mappings at all... undefined? false for now - if (resourceMaps.size()<1) - return null; - - // One mapping, and something maps to root. That's a good sign - if( resourceMaps.size() == 1 ) { - ComponentResource mapping = (ComponentResource)resourceMaps.get(0); - if( isRootMapping(mapping)) - return getOutputContainerIfExists(mapping.getSourcePath()); - // One mapping, but doesn't map to root... so there's no root to point to - if( !forceSingleRoot) - return null; - } - - // There are several mappings to root. - // If more than one map to root, not single root - if( countExistingRootMappings(resourceMaps) > 1 ) - return !forceSingleRoot ? null : - getOutputContainerIfExists(getFirstExistingRootPath(resourceMaps)); - - // if ALL are source folders, - if( countSourceMappings(resourceMaps) == resourceMaps.size()) { - // then we check that they all output to the same place - if (getJavaOutputFolders().length==1) { - // Currently, we claim single-rooted when all source folders - // have the same output folder. However, we know this is not - // true because it cannot contain non Java files unless it is - // the only source folder. But, fixing at this time would break - // all current users. - return getJavaOutputFolders()[0]; - } - if( !forceSingleRoot) - return null; - } - - // Not all of them are source mappings, but there's only one root mapping - // Lets find our root mapping container - IContainer rootContainer = component.getRootFolder().getUnderlyingFolder(); - IPath projectRelative = component.getRootFolder().getProjectRelativePath(); - if( forceSingleRoot) - return getOutputContainerIfExists(projectRelative); - - // Lets check the underlying folders of all OTHER mappings, which are all source folders, - // and check its output folder against this root mapping. If the output is to - // somewhere under the root mapping, then it's single root - IContainer[] outputFolders = getJavaOutputFolders(); - IPath rootContainerProjectRelative = rootContainer.getProjectRelativePath(); - for( int i = 0; i < outputFolders.length; i++ ) { - if( !rootContainerProjectRelative.isPrefixOf(outputFolders[i].getProjectRelativePath())) { - return null; - } - } - - // All outputs go somewhere under the root folder, or the root folder doesn't exist (EH?) - return getOutputContainerIfExists(projectRelative); - } finally { - if (edit !=null) - edit.dispose(); - } - } - - protected boolean isForceSingleRoot() { - StructureEdit edit = StructureEdit.getStructureEditForRead(getProject()); - return isForceSingleRoot(edit); - } - - protected boolean isForceSingleRoot(StructureEdit edit) { - WorkbenchComponent wbComp = edit.getComponent(); - final List componentProperties = wbComp.getProperties(); - if (componentProperties != null) { - final Iterator componentPropertiesIterator = componentProperties.iterator(); - while (componentPropertiesIterator.hasNext()) { - Property wbProperty = (Property) componentPropertiesIterator.next(); - if (J2EEFlexProjDeployable.USE_SINGLE_ROOT_PROPERTY.equals(wbProperty.getName())) { - boolean useSingleRoot = Boolean.valueOf(wbProperty.getValue()).booleanValue(); - if (useSingleRoot) { - return true; - } - } - } - } - return false; - } - - /** - * This method will return the container related to the given path. - * If the container is a source path, this method will return its output - * folder. - * If the container is not a source path, the container itself will be returned - * @param projectRelative - * @return - */ - protected IContainer getOutputContainerIfExists(IPath projectRelative) { - IContainer container = (IContainer)getProject().findMember(projectRelative); - if( !isSourceContainer(projectRelative)) - return container; - return getOutputContainer(getSourceContainer(container)); - } - - private int countExistingRootMappings(List resourceMaps) { - int count = 0; - ComponentResource cr = null; - for (int i=0; i 0) - result = Boolean.TRUE; - // Otherwise it is not mapped - else - result = Boolean.FALSE; - // Cache the result in the map for this output container - outputMaps.put(outputContainer, result); - } - return result.booleanValue(); - } - - /** - * Lazy initialize the cached output mappings - * @return HashMap - */ - private HashMap getCachedOutputMappings() { - if (cachedOutputMappings==null) - cachedOutputMappings = new HashMap(); - return cachedOutputMappings; - } - - /** - * Lazy initialize the cached source - output pairings - * @return HashMap - */ - private HashMap getCachedSourceOutputPairs() { - if (cachedSourceOutputPairs==null) - cachedSourceOutputPairs = new HashMap(); - return cachedSourceOutputPairs; - } - - /** - * This file should be added to the members list from the virtual component maps only if: - * a) it is not in a source folder - * b) it is in a source folder, and the corresponding output folder is a mapped component resource - * - * @return boolean should file be added to members - */ - @Override - protected boolean shouldAddComponentFile(IFile file) { - IPackageFragmentRoot sourceContainer = getSourceContainer(file); - // If the file is not in a source container, return true - if (sourceContainer==null) { - return true; - // Else if it is a source container and the output container is mapped in the component, return true - // Otherwise, return false. - } - IContainer outputContainer = getOutputContainer(sourceContainer); - return outputContainer!=null && isOutputContainerMapped(outputContainer); - } } Index: j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java,v retrieving revision 1.2 diff -u -r1.2 SingleRootUtil.java --- j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java 18 Nov 2009 22:38:28 -0000 1.2 +++ j2eecreation/org/eclipse/jst/j2ee/project/SingleRootUtil.java 20 Nov 2009 21:09:05 -0000 @@ -85,7 +85,14 @@ return validateSingleRoot(INCLUDE_FIRST_ERROR).getSeverity() != IStatus.ERROR; } - + /** + * Will attempt to return the IContainer that counts as the "single-root". + * If this module does not qualify as a "single-root" module, this + * method will return null. Otherwise it will return an IContainer + * that may be used as the single-root container. + * + * @return IContainer representing single-root container + */ public IContainer getSingleRoot() { IStatus status = validateSingleRoot(GET_SINGLE_ROOT_CONTAINER); if (status.getSeverity() == IStatus.INFO) { @@ -230,7 +237,7 @@ // Verify the java output folder is the same as one of the content roots IPath javaOutputPath = getJavaOutputFolders()[0].getProjectRelativePath(); IContainer[] rootFolders = aComponent.getRootFolder().getUnderlyingFolders(); - for (int i=0; i/WEB-INF/classes IPath javaOutputPath = getJavaOutputFolders()[0].getProjectRelativePath(); - IPath compRootPath = aComponent.getRootFolder().getUnderlyingFolder().getProjectRelativePath(); + IContainer rootContainer = aComponent.getRootFolder().getUnderlyingFolder(); + IPath compRootPath = rootContainer.getProjectRelativePath(); if (compRootPath.append(J2EEConstants.WEB_INF_CLASSES).equals(javaOutputPath)) { - reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, javaOutputFolders[0]); + reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, rootContainer); return; } reportStatus(ISingleRootStatus.JAVA_OUTPUT_NOT_WEBINF_CLASSES); Index: archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java,v retrieving revision 1.17 diff -u -r1.17 ComponentArchiveLoadAdapter.java --- archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java 9 Sep 2009 16:22:36 -0000 1.17 +++ archiveops/org/eclipse/jst/j2ee/internal/archive/ComponentArchiveLoadAdapter.java 20 Nov 2009 21:09:05 -0000 @@ -12,6 +12,7 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -46,6 +47,7 @@ import org.eclipse.jst.j2ee.internal.classpathdep.ClasspathDependencyVirtualComponent; import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities; +import org.eclipse.jst.j2ee.project.SingleRootUtil; import org.eclipse.jst.jee.archive.AbstractArchiveLoadAdapter; import org.eclipse.jst.jee.archive.ArchiveModelLoadException; import org.eclipse.jst.jee.archive.IArchive; @@ -82,27 +84,29 @@ protected IVirtualComponent vComponent; protected boolean exportSource = true; + + protected boolean optimizeMembers = false; - private List zipFiles = new ArrayList(); + private List zipFiles = new ArrayList(); - private List javaClasspathURIs = new ArrayList(); + private List javaClasspathURIs = new ArrayList(); protected boolean includeClasspathComponents = true; protected class FilesHolder { - private Map pathsToArchiveResources = new HashMap(); + private Map pathsToArchiveResources = new HashMap(); - private Map pathsToWorkbenchResources = new HashMap(); + private Map pathsToWorkbenchResources = new HashMap(); - private Map workbenchResourcesToPaths = new HashMap(); + private Map workbenchResourcesToPaths = new HashMap(); - private Map pathsToDiskFiles; + private Map pathsToDiskFiles; - private Map pathsToZipEntry = new HashMap(); + private Map pathsToZipEntry = new HashMap(); public void removeIFile(IFile file) { - IPath path = (IPath) workbenchResourcesToPaths.get(file); + IPath path = workbenchResourcesToPaths.get(file); remove(path); } @@ -126,7 +130,7 @@ IPath path = file.getPath(); pathsToArchiveResources.put(path, file); if (null == pathsToDiskFiles) { - pathsToDiskFiles = new HashMap(); + pathsToDiskFiles = new HashMap(); } pathsToDiskFiles.put(path, externalDiskFile); } @@ -141,9 +145,9 @@ java.io.File diskFile = null; if (pathsToDiskFiles != null && pathsToDiskFiles.containsKey(path)) { - diskFile = (java.io.File) pathsToDiskFiles.get(path); + diskFile = pathsToDiskFiles.get(path); } else if (pathsToWorkbenchResources != null && pathsToWorkbenchResources.containsKey(path)) { - IResource resource = (IResource) pathsToWorkbenchResources.get(path); + IResource resource = pathsToWorkbenchResources.get(path); diskFile = new java.io.File(resource.getLocation().toOSString()); } if (diskFile != null) { @@ -181,7 +185,7 @@ } public IArchiveResource getArchiveResource(IPath path) { - return (IArchiveResource) pathsToArchiveResources.get(path); + return pathsToArchiveResources.get(path); } public void addEntry(ZipEntry entry, ZipFile zipFile, IPath runtimePath) { @@ -197,7 +201,7 @@ IArchiveResource file = createFile(innerRuntimePath); - Map fileURIMap = new HashMap(); + Map fileURIMap = new HashMap(); fileURIMap.put(entry.getName(), zipFile); pathsToZipEntry.put(file.getPath(), fileURIMap); @@ -300,6 +304,19 @@ protected void initArchiveResources() { if (!archiveResourcesInitialized) { archiveResourcesInitialized = true; + if (isOptimizeMembers()) { + SingleRootUtil util = new SingleRootUtil(getComponent()); + IContainer rootContainer = util.getSingleRoot(); + if (rootContainer != null) { + try { + aggregateMembers(Path.EMPTY, rootContainer); + addUtilities(); + } catch (CoreException e) { + J2EEPlugin.logError(e); + } + return; + } + } aggregateSourceFiles(); aggregateClassFiles(); addUtilities(); @@ -308,10 +325,17 @@ @Override public List getArchiveResources() { - initArchiveResources(); return filesHolder.getFiles(); } + + public IResource getWorkbenchResources(IPath path) { + return filesHolder.pathsToWorkbenchResources.get(path); + } + + public File getExternalFiles(IPath path) { + return filesHolder.pathsToDiskFiles.get(path); + } /** * Adds library cp entries that point to class folders and have been tagged with the publish/export attribute. @@ -484,7 +508,7 @@ continue; cFile = createDirectory(runtimePath); cFile.setLastModified(getLastModified(resources[i])); - filesHolder.addFile(cFile); + filesHolder.addFile(cFile, resources[i]); fileAdded = true; } } @@ -498,6 +522,7 @@ */ private boolean inJavaSrc = false; + protected boolean aggregateFiles(IVirtualResource[] virtualResources) throws CoreException { boolean fileAdded = false; for (int i = 0; i < virtualResources.length; i++) { @@ -610,6 +635,36 @@ protected long getLastModified(IResource aResource) { return aResource.getLocation().toFile().lastModified(); } + + protected void aggregateMembers(IPath path, IContainer container) throws CoreException{ + IResource[] resources; + resources = container.members(); + if (resources != null) { + int size = resources.length; + for (int i = 0; i < size; i++) { + IResource resource = resources[i]; + IArchiveResource cFile = null; + if (resource != null && resource.exists()) { + IPath deployPath = path.append(resource.getName()); + if (filesHolder.contains(deployPath)) { + continue; + } + if (resource instanceof IContainer) { + IContainer container2 = (IContainer) resource; + cFile = createDirectory(deployPath); + aggregateMembers(deployPath, container2); + + } else if ((resource instanceof IFile) && shouldInclude(deployPath)) { + cFile = createFile(deployPath); + } + } + if (cFile != null) { + cFile.setLastModified(getLastModified(resource)); + filesHolder.addFile(cFile, resource); + } + } + } + } public void setExportSource(boolean newExportSource) { exportSource = newExportSource; @@ -619,6 +674,23 @@ return exportSource; } + public void setOptimizeMembers(boolean optimize) { + optimizeMembers = optimize; + } + + public boolean isOptimizeMembers() { + return optimizeMembers; + } + + public boolean shouldUpdateManifest(IArchiveResource archiveResource) { + IPath path = archiveResource.getPath(); + if (includeClasspathComponents && path.equals(J2EEConstants.MANIFEST_URI) && !javaClasspathURIs.isEmpty() && manifestFile != null + && manifestFile.getUnderlyingFile() != null && manifestFile.getUnderlyingFile().exists()) { + return true; + } + return false; + } + protected boolean shouldInclude(IContainer aContainer) { return true; } @@ -639,7 +711,7 @@ } return isExportSource() || !isSource(path); } - + // TODO add a mechanism for ignoring specific file types protected boolean isSource(IPath path) { if (path == null) @@ -665,20 +737,18 @@ @Override public InputStream getInputStream(IArchiveResource archiveResource) throws IOException, FileNotFoundException { - IPath path = archiveResource.getPath(); // If the MANIFEST.MF of a module component is being requested and that // module component references // Java build path-based components, need to dynamically update the // manifest classpath to reflect the resolved // contributions from the build path - if (includeClasspathComponents && path.equals(J2EEConstants.MANIFEST_URI) && !javaClasspathURIs.isEmpty() && manifestFile != null && manifestFile.getUnderlyingFile() != null - && manifestFile.getUnderlyingFile().exists()) { + if (shouldUpdateManifest(archiveResource)) { // update the manifest classpath for the component ByteArrayOutputStream baos = new ByteArrayOutputStream(); ClasspathDependencyManifestUtil.updateManifestClasspath(manifestFile.getUnderlyingFile(), javaClasspathURIs, baos); return new ByteArrayInputStream(baos.toByteArray()); } - + IPath path = archiveResource.getPath(); if (filesHolder.contains(path)) { return filesHolder.getInputStream(path); } Index: plugin.xml =================================================================== RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/plugin.xml,v retrieving revision 1.133 diff -u -r1.133 plugin.xml --- plugin.xml 18 Nov 2009 22:26:19 -0000 1.133 +++ plugin.xml 20 Nov 2009 21:09:04 -0000 @@ -349,19 +349,19 @@ id="org.eclipse.jst.j2ee.server"> + versions="5.0,1.2,1.3,1.4"> + versions="5.0,1.2,1.3,1.4"> + versions="2.5,2.2,2.3,2.4"> + versions="3.0,1.1,2.0,2.1">