Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 152761 Details for
Bug 265798
Make export operation pull from wst.server APIs to reduce redundancy and inconsistancy
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
J2EEFlexDeployable utilizing IArchive APIs patch
deploy_patch.txt (text/plain), 75.41 KB, created by
Jason Peterson
on 2009-11-20 16:24:24 EST
(
hide
)
Description:
J2EEFlexDeployable utilizing IArchive APIs patch
Filename:
MIME Type:
Creator:
Jason Peterson
Created:
2009-11-20 16:24:24 EST
Size:
75.41 KB
patch
obsolete
>### 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 @@ > </package> > </extension> > >- <extension >- point="org.eclipse.wst.server.core.moduleFactories"> >- <moduleFactory >- projects="true" >- class="org.eclipse.jst.jee.internal.deployables.JEEDeployableFactory" >- id="org.eclipse.jst.jee.server"> >- <moduleType >- types="jst.ear" >- versions="5.0"> >- </moduleType> >- <moduleType >- types="jst.appclient" >- versions="5.0,1.2,1.3,1.4"> >- </moduleType> >- <moduleType >- types="jst.web" >- versions="2.5,2.2,2.3,2.4"> >- </moduleType> >- <moduleType >- types="jst.ejb" >- versions="3.0,1.1,2.0,2.1"> >- </moduleType> >- <moduleType >- types="jst.connector" >- versions="1.0,1.5"> >- </moduleType> >- <moduleType >- types="jst.utility" >- versions="1.0"> >- </moduleType> >- </moduleFactory> >- </extension> > <extension > point="org.eclipse.core.runtime.contentTypes"> > <content-type >Index: earproject/org/eclipse/jst/jee/internal/deployables/JEEFlexProjDeployable.java >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/internal/deployables/JEEFlexProjDeployable.java,v >retrieving revision 1.12 >diff -u -r1.12 JEEFlexProjDeployable.java >--- earproject/org/eclipse/jst/jee/internal/deployables/JEEFlexProjDeployable.java 13 Oct 2009 17:25:20 -0000 1.12 >+++ earproject/org/eclipse/jst/jee/internal/deployables/JEEFlexProjDeployable.java 20 Nov 2009 21:09:00 -0000 >@@ -10,21 +10,12 @@ > *******************************************************************************/ > package org.eclipse.jst.jee.internal.deployables; > >-import java.util.Iterator; >- > import org.eclipse.core.resources.IProject; > import org.eclipse.jst.j2ee.componentcore.J2EEModuleVirtualArchiveComponent; >-import org.eclipse.jst.j2ee.internal.EjbModuleExtensionHelper; >-import org.eclipse.jst.j2ee.internal.IEJBModelExtenderManager; > import org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable; > import org.eclipse.jst.j2ee.model.IEARModelProvider; >-import org.eclipse.jst.j2ee.model.IModelProvider; >-import org.eclipse.jst.j2ee.model.ModelProviderManager; > import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities; > import org.eclipse.jst.javaee.application.Application; >-import org.eclipse.jst.javaee.ejb.EJBJar; >-import org.eclipse.jst.javaee.ejb.EnterpriseBeans; >-import org.eclipse.jst.javaee.ejb.SessionBean; > import org.eclipse.wst.common.componentcore.ArtifactEdit; > import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; > import org.eclipse.wst.common.componentcore.resources.IVirtualReference; >@@ -33,6 +24,8 @@ > > /** > * JEE module superclass. >+ * >+ * @deprecated use org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable instead > */ > public class JEEFlexProjDeployable extends J2EEFlexProjDeployable { > >@@ -64,37 +57,6 @@ > return super.shouldIncludeUtilityComponent(virtualComp, references, ArtifactEdit.class.isInstance(model) ? (ArtifactEdit)model : null); > } > >- public String getJNDIName(String ejbName, String interfaceName) { >- if (!JavaEEProjectUtilities.isEJBProject(component.getProject())) >- return null; >- >- EjbModuleExtensionHelper modHelper = null; >- EJBJar jar = null; >- >- IModelProvider model = ModelProviderManager.getModelProvider(component.getProject()); >- if (model != null) { >- jar = (EJBJar) model.getModelObject(); >- SessionBean bean = getSessionBeanNamed(jar, ejbName); >- modHelper = IEJBModelExtenderManager.INSTANCE.getEJBModuleExtension(null); >- return modHelper == null ? null : modHelper.getJavaEEJNDIName(jar, bean, interfaceName); >- } >- >- return null; >- } >- /** >- * Return List of Session beans in this jar. >- * @return java.util.List >- */ >- public SessionBean getSessionBeanNamed(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; >- } > > @Override > protected IModule gatherModuleReference(IVirtualComponent component, IVirtualComponent targetComponent ) { >Index: earproject/org/eclipse/jst/jee/internal/deployables/JEEDeployableFactory.java >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.jee/earproject/org/eclipse/jst/jee/internal/deployables/JEEDeployableFactory.java,v >retrieving revision 1.10 >diff -u -r1.10 JEEDeployableFactory.java >--- earproject/org/eclipse/jst/jee/internal/deployables/JEEDeployableFactory.java 1 Jul 2009 21:32:47 -0000 1.10 >+++ earproject/org/eclipse/jst/jee/internal/deployables/JEEDeployableFactory.java 20 Nov 2009 21:08:59 -0000 >@@ -39,6 +39,7 @@ > > /** > * J2EE module factory. >+ * @deprecated use org.eclipse.jst.j2ee.internal.deployables.J2EEDeployableFactory instead > */ > public class JEEDeployableFactory extends ProjectModuleFactoryDelegate { > protected Map <IModule, ModuleDelegate> moduleDelegates = new HashMap<IModule, ModuleDelegate>(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<IModuleResource> members = new ArrayList<IModuleResource>(); > > 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<IModule> modules = new ArrayList<IModule>(); > 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<IModuleFile> list = new ArrayList<IModuleFile>(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<IModuleFile> list = new ArrayList<IModuleFile>(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<IModule> projectModules = new ArrayList<IModule>(); > 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<IPath, ModuleFolder> moduleFolderCache = new HashMap<IPath, ModuleFolder>(); > > /** > * 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<IContainer> 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<IArchiveResource> archiveResources = archive.getArchiveResources(); >+ for (Iterator<IArchiveResource> 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; i<srcContainers.length; i++) { >- IPath srcPath = srcContainers[i].getPath(); >- if (srcPath.isPrefixOf(file.getFullPath())) >- return srcContainers[i]; >- } >- return null; >- } >- >- /** >- * Either returns value from cache or stores result as value in cache for the corresponding >- * output container for the given source container. >- * >- * @param sourceContainer >- * @return IContainer output container for given source container >- */ >- protected IContainer getOutputContainer(IPackageFragmentRoot sourceContainer) { >- if (sourceContainer == null) >- return null; >- >- HashMap pairs = getCachedSourceOutputPairs(); >- IContainer output = (IContainer) pairs.get(sourceContainer); >- if (output == null) { >- output = J2EEProjectUtilities.getOutputContainer(getProject(), sourceContainer); >- pairs.put(sourceContainer,output); >- } >- return output; >- } >- >- private IPackageFragmentRoot[] getSourceContainers() { >- if (cachedSourceContainers != null) >- return cachedSourceContainers; >- return J2EEProjectUtilities.getSourceContainers(getProject()); >- } >- >- protected List getConsumableReferencedMembers(IVirtualComponent vc) throws CoreException { >- List consumableMembers = new ArrayList(); >- 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) { >- IVirtualComponent consumedComponent = reference.getReferencedComponent(); >- if (consumedComponent!=null && isProjectOfType(consumedComponent.getProject(),IModuleConstants.JST_UTILITY_MODULE)) { >- if (consumedComponent.getRootFolder()!=null) { >- IVirtualFolder vFolder = consumedComponent.getRootFolder(); >- IModuleResource[] mr = getMembers(vFolder, reference.getRuntimePath().makeRelative()); >- int size = mr.length; >- for (int j = 0; j < size; j++) { >- if (!members.contains(mr[j])) >- members.add(mr[j]); >- } >- addUtilMembers(consumedComponent); >- List childConsumableMembers = getConsumableReferencedMembers(consumedComponent); >- if (!childConsumableMembers.isEmpty()) >- members.addAll(childConsumableMembers); >- } >- >- IContainer[] javaCont = getJavaOutputFolders(consumedComponent); >- int size = javaCont.length; >- for (int j = 0; j < size; j++) { >- IModuleResource[] mr = getMembers(javaCont[j], reference.getRuntimePath(), reference.getRuntimePath(), javaCont); >- int size2 = mr.length; >- for (int k = 0; k < size2; k++) { >- if (!members.contains(mr[k])) >- members.add(mr[k]); >- } >- } >- } >- } >- } >- return consumableMembers; >- } >- > @Override > protected IModule gatherModuleReference(IVirtualComponent component, IVirtualComponent targetComponent ) { > IModule module = super.gatherModuleReference(component, targetComponent); >@@ -672,25 +530,7 @@ > } > 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(); >- if (app == null) { // if no application.xml, return false >- return false; >- } >- IVirtualReference reference = getReferenceNamed(references,aComponent.getName()); >- // Ensure module URI exists on EAR DD for binary archive >- boolean inDD = app.getFirstModule(reference.getArchiveName()) != null; >- return inDD && JavaEEBinaryComponentHelper.getJavaEEQuickPeek(aComponent).getType() != JavaEEQuickPeek.UNKNOWN; >- } >- >+ > protected IVirtualReference getReferenceNamed(IVirtualReference[] references, String name) { > for (int i=0; i<references.length; i++) { > if (references[i].getReferencedComponent().getName().equals(name)) >@@ -699,512 +539,5 @@ > return null; > } > >- @Override >- protected ArtifactEdit getComponentArtifactEditForRead() { >- return EARArtifactEdit.getEARArtifactEditForRead(component.getProject()); >- } >- >- /** >- * The references for J2EE module deployment are only those child modules of EARs or web modules >- */ >- @Override >- protected IVirtualReference[] getReferences(IVirtualComponent aComponent) { >- if (aComponent == null || aComponent.isBinary()) { >- return new IVirtualReference[] {}; >- } else if (JavaEEProjectUtilities.isDynamicWebProject(aComponent.getProject())) { >- return getWebLibModules((J2EEModuleVirtualComponent)aComponent); >- } else if (JavaEEProjectUtilities.isEARProject(aComponent.getProject())) { >- return super.getReferences(aComponent); >- } else { >- return new IVirtualReference[] {}; >- } >- } >- >- /** >- * This method will return the list of dependent modules which are utility jars in the web lib >- * folder of the deployed path of the module. It will not return null. >- * >- * @return array of the web library dependent modules >- */ >- private IVirtualReference[] getWebLibModules(J2EEModuleVirtualComponent comp) { >- List result = new ArrayList(); >- IVirtualReference[] refComponents = comp.getNonManifestReferences(); >- // Check the deployed path to make sure it has a lib parent folder and matchs the web.xml >- // base path >- for (int i = 0; i < refComponents.length; i++) { >- if (refComponents[i].getRuntimePath().equals(WEBLIB)) >- result.add(refComponents[i]); >- } >- return (IVirtualReference[]) result.toArray(new IVirtualReference[result.size()]); >- } >- >- /* >- * Add any classpath component dependencies from this component >- */ >- private void addReferencedComponentClasspathDependencies(final IVirtualComponent component, final boolean web) { >- final IVirtualReference[] refs = component.getReferences(); >- final Set absolutePaths = new HashSet(); >- for (int i = 0; i < refs.length; i++) { >- final IVirtualReference reference = refs[i]; >- final IPath runtimePath = reference.getRuntimePath(); >- final IVirtualComponent referencedComponent = reference.getReferencedComponent(); >- >- // if we are adding to a web project, only process references with the /WEB-INF/lib runtime path >- if (web && !runtimePath.equals(WEBLIB)) { >- continue; >- } >- >- // if the reference cannot export dependencies, skip >- if (!canExportClasspathComponentDependencies(referencedComponent)) { >- continue; >- } >- >- if (!referencedComponent.isBinary() && referencedComponent instanceof J2EEModuleVirtualComponent) { >- final IVirtualReference[] cpRefs = ((J2EEModuleVirtualComponent) referencedComponent).getJavaClasspathReferences(); >- for (int j = 0; j < cpRefs.length; j++) { >- final IVirtualReference cpRef = cpRefs[j]; >- IPath cpRefRuntimePath = cpRef.getRuntimePath(); >- >- if (cpRef.getReferencedComponent() instanceof ClasspathDependencyVirtualComponent) { >- // want to avoid adding dups >- ClasspathDependencyVirtualComponent cpComp = (ClasspathDependencyVirtualComponent) cpRef.getReferencedComponent(); >- // don't want to process class folder refs here >- if (cpComp.isClassFolder()) { >- continue; >- } >- if (cpRefRuntimePath.equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH)) { >- // runtime path within deployed app will be runtime path of parent component >- cpRefRuntimePath = runtimePath; >- } else { >- //https://bugs.eclipse.org/bugs/show_bug.cgi?id=247090 >- //if path isn't ../, it shouldn't be added here >- continue; >- } >- final IPath absolutePath = ClasspathDependencyUtil.getClasspathVirtualReferenceLocation(cpRef); >- if (absolutePaths.contains(absolutePath)) { >- // have already added a member for this archive >- continue; >- } >- addUtilMember(component, cpRef, cpRefRuntimePath); >- absolutePaths.add(absolutePath); >- } >- } >- } >- } >- } >- >- private boolean canExportClasspathComponentDependencies(IVirtualComponent component) { >- final IProject project = component.getProject(); >- // check for valid project type >- if (JavaEEProjectUtilities.isEJBProject(project) >- || JavaEEProjectUtilities.isDynamicWebProject(project) >- || JavaEEProjectUtilities.isJCAProject(project) >- || JavaEEProjectUtilities.isUtilityProject(project)) { >- return true; >- } >- return false; >- } >- >- private void saveClasspathDependencyURIs(IVirtualComponent component) { >- if (!component.isBinary() && component instanceof J2EEModuleVirtualComponent) { >- final IVirtualReference[] cpRefs = ((J2EEModuleVirtualComponent) component).getJavaClasspathReferences(); >- for (int j = 0; j < cpRefs.length; j++) { >- final IVirtualReference cpRef = cpRefs[j]; >- // if we are adding to an EAR project, only process references with the root mapping >- if (!cpRef.getRuntimePath().equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_CONTAINER_PATH)) { >- // fails the runtime path test >- continue; >- } >- if (cpRef.getReferencedComponent() instanceof VirtualArchiveComponent) { >- classpathComponentDependencyURIs.add(cpRef.getArchiveName()); >- } >- } >- } >- } >- >- private void addClassFolderDependencies(final IVirtualComponent component) throws CoreException { >- if (!component.isBinary() && component instanceof J2EEModuleVirtualComponent) { >- final IVirtualReference[] cpRefs = ((J2EEModuleVirtualComponent) component).getJavaClasspathReferences(); >- for (int i = 0; i < cpRefs.length; i++) { >- final IVirtualReference cpRef = cpRefs[i]; >- final IPath runtimePath = cpRef.getRuntimePath(); >- final IVirtualComponent comp = cpRef.getReferencedComponent(); >- if (comp instanceof ClasspathDependencyVirtualComponent) { >- final ClasspathDependencyVirtualComponent cpComp = (ClasspathDependencyVirtualComponent) comp; >- if (cpComp.isClassFolder()) { >- IPath targetPath = null; >- if (runtimePath.equals(IClasspathDependencyConstants.RUNTIME_MAPPING_INTO_COMPONENT_PATH)) { >- targetPath = Path.EMPTY; >- } else if (runtimePath.equals(IClasspathDependencyConstants.WEB_INF_CLASSES_PATH)) { >- targetPath = WEB_CLASSES_PATH; >- } else { >- continue; >- } >- final IContainer container = cpComp.getClassFolder(); >- final IModuleResource[] mr = getMembers(container, targetPath, targetPath, new IContainer[]{container}); >- for (int j = 0; j < mr.length; j++) { >- members.add(mr[j]); >- } >- } >- } >- } >- } >- } >- >- /* >- * If the resource to check is a file then this method will return true if the file is linked. If the resource to >- * check is a folder then this method will return true if it, any of its sub directories, or any file contained >- * with-in this directory of any of it's sub directories are linked. Otherwise false is returned. >- */ >- private boolean hasLinkedContent(final IResource resourceToCheck) throws CoreException { >- >- if ((resourceToCheck != null) && resourceToCheck.isAccessible()) { >- // skip non-accessible files >- if (resourceToCheck.isLinked()) { >- return true; >- } >- switch (resourceToCheck.getType()) { >- case IResource.FOLDER: >- // recursively check sub directory contents >- final IResource[] subDirContents = ((IFolder) resourceToCheck).members(); >- for (int i = 0; i < subDirContents.length; i++) { >- if (hasLinkedContent(subDirContents[i])) { >- return true; >- } >- } >- break; >- case IResource.FILE: >- return resourceToCheck.isLinked(); >- default: >- // skip as we only care about files and folders >- break; >- } >- } >- return false; >- } >- >- /* >- * This method returns true if the root folders of this component have any linked resources (folder or file); >- * Otherwise false is returned. >- */ >- private boolean rootFoldersHaveLinkedContent() { >- >- if (this.component != null) { >- final IContainer[] rootFolders = this.component.getRootFolder().getUnderlyingFolders(); >- for (int i = 0; i < rootFolders.length; i++) { >- try { >- boolean hasLinkedContent = this.hasLinkedContent(rootFolders[i]); >- if (hasLinkedContent) { >- return true; >- } >- } >- catch (CoreException coreEx) { >- J2EEPlugin.logError(coreEx); >- } >- } >- } >- return false; >- } > >- /** >- * Returns <code>true</code> if this module has a simple structure based on a >- * single root folder, and <code>false</code> otherwise. >- * <p> >- * 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. >- * </p> >- * >- * @return <code>true</code> if this module has a single root structure, and >- * <code>false</code> 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<resourceMaps.size(); i++) { >- cr = (ComponentResource)resourceMaps.get(i); >- if(isRootMapping(cr) && exists(cr)) >- count++; >- } >- return count; >- } >- >- private IPath getFirstExistingRootPath(List resourceMaps) { >- ComponentResource cr = null; >- for (int i=0; i<resourceMaps.size(); i++) { >- cr = (ComponentResource)resourceMaps.get(i); >- if(isRootMapping(cr) && exists(cr)) >- return cr.getSourcePath(); >- } >- return null; >- } >- >- private boolean exists(ComponentResource cr) { >- IContainer container = (IContainer)getProject().findMember(cr.getSourcePath()); >- return container != null && container.exists(); >- } >- >- private boolean isRootMapping(ComponentResource mapping) { >- // Verify it maps to "/" for the content root >- if (mapping != null && !mapping.getRuntimePath().equals(Path.ROOT)) >- return false; >- return true; >- } >- >- private int countSourceMappings(List resourceMaps) { >- int count = 0; >- for (int i=0; i<resourceMaps.size(); i++) { >- if(isSourceContainer((ComponentResource)resourceMaps.get(i))) >- count++; >- } >- return count; >- } >- >- private boolean isSourceContainer(ComponentResource mapping) { >- return isSourceContainer(mapping.getSourcePath()); >- } >- >- private boolean isSourceContainer(IPath projectRelative) { >- IResource sourceResource = getProject().findMember(projectRelative); >- if(sourceResource != null && sourceResource.exists()){ >- IPath sourcePath = getProject().getFullPath().append(projectRelative); >- if (!isSourceContainer2(sourcePath)) >- return false; >- } >- return true; >- } >- >- private boolean isSourceContainer2(IPath fullPath) { >- IPackageFragmentRoot[] srcContainers = getSourceContainers(); >- for (int i=0; i<srcContainers.length; i++) { >- if (srcContainers[i].getPath().equals(fullPath)) >- return true; >- } >- return false; >- } >- >- >- /** >- * This method is added so that force-singleroot use case can behave properly. >- * >- * @return array of ModuleResources >- * @throws CoreException >- */ >- private IModuleResource[] getOptimizedMembers() throws CoreException { >- IContainer root = getSingleRoot(); >- IModuleResource[] resources = getModuleResources(Path.EMPTY, root); >- for( int i = 0; i < resources.length; i++ ) >- members.add(resources[i]); >- return (IModuleResource[]) members.toArray(new IModuleResource[members.size()]); >- } >- >- /** >- * This method will return from cache or add to cache whether or not an output container >- * is mapped in the virtual component. >- * >- * @param outputContainer >- * @return if output container is mapped >- */ >- private boolean isOutputContainerMapped(IContainer outputContainer) { >- if (outputContainer == null) >- return false; >- >- HashMap outputMaps = getCachedOutputMappings(); >- Boolean result = (Boolean) outputMaps.get(outputContainer); >- if (result == null) { >- // If there are any component resources for the container, we know it is mapped >- if (ComponentCore.createResources(outputContainer).length > 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<rootFolders.length; i++) { >+ for (int i=0; i < rootFolders.length; i++) { > IPath compRootPath = rootFolders[i].getProjectRelativePath(); > if (javaOutputPath.equals(compRootPath)) { > reportStatus(ISingleRootStatus.SINGLE_ROOT_CONTAINER_FOUND, aComponent.getRootFolder().getUnderlyingFolder()); >@@ -254,9 +261,10 @@ > if (javaOutputFolders.length == 1) { > // Verify the java output folder is to <content root>/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<ZipFile> zipFiles = new ArrayList<ZipFile>(); > >- private List javaClasspathURIs = new ArrayList(); >+ private List<String> javaClasspathURIs = new ArrayList<String>(); > > protected boolean includeClasspathComponents = true; > > protected class FilesHolder { > >- private Map pathsToArchiveResources = new HashMap(); >+ private Map<IPath, IArchiveResource> pathsToArchiveResources = new HashMap<IPath, IArchiveResource>(); > >- private Map pathsToWorkbenchResources = new HashMap(); >+ private Map<IPath, IResource> pathsToWorkbenchResources = new HashMap<IPath, IResource>(); > >- private Map workbenchResourcesToPaths = new HashMap(); >+ private Map<IResource, IPath> workbenchResourcesToPaths = new HashMap<IResource, IPath>(); > >- private Map pathsToDiskFiles; >+ private Map<IPath, java.io.File> pathsToDiskFiles; > >- private Map pathsToZipEntry = new HashMap(); >+ private Map pathsToZipEntry = new HashMap<IPath, ZipFile>(); > > 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<IPath, java.io.File>(); > } > 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<String, ZipFile> fileURIMap = new HashMap<String, ZipFile>(); > 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<IArchiveResource> 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"> > <moduleType > types="jst.ear" >- versions="1.2,1.3,1.4"> >+ versions="5.0,1.2,1.3,1.4"> > </moduleType> > <moduleType > types="jst.appclient" >- versions="1.2,1.3,1.4"> >+ versions="5.0,1.2,1.3,1.4"> > </moduleType> > <moduleType > types="jst.web" >- versions="2.2,2.3,2.4"> >+ versions="2.5,2.2,2.3,2.4"> > </moduleType> > <moduleType > types="jst.ejb" >- versions="1.1,2.0,2.1"> >+ versions="3.0,1.1,2.0,2.1"> > </moduleType> > <moduleType > types="jst.connector"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 265798
:
126431
|
126438
|
152761
|
152982
|
153408
|
153416
|
153552
|
153762
|
153820