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 156056 Details for
Bug 299549
Need IArchive option to descriminate manifest peek for jars
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch
patch.txt (text/plain), 12.14 KB, created by
Jason Peterson
on 2010-01-13 17:01:44 EST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Jason Peterson
Created:
2010-01-13 17:01:44 EST
Size:
12.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jst.j2ee >Index: archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java,v >retrieving revision 1.36 >diff -u -r1.36 JavaEEArchiveUtilities.java >--- archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java 3 Dec 2009 01:19:34 -0000 1.36 >+++ archiveops/org/eclipse/jst/j2ee/internal/archive/JavaEEArchiveUtilities.java 13 Jan 2010 22:00:43 -0000 >@@ -79,6 +79,19 @@ > * specified IArchive is an EJB 3.0 jar. > */ > public static final String DISCRIMINATE_EJB_ANNOTATIONS = "DISCRIMINATE_EJB_ANNOTATIONS"; //$NON-NLS-1$ >+ >+ /** >+ * Default value = Boolean.TRUE Valid values = Boolean.TRUE or Boolean.FALSE >+ * >+ * An ArchiveOption used to specify whether >+ * {@link #openArchive(ArchiveOptions)} should attempt to fully discriminate >+ * a JAR file from an Application Client JAR file. This option is only relevant >+ * if the {@link #DISCRIMINATE_JAVA_EE} option is also set to Boolean.TRUE. If >+ * both options are set to true then as a last resort the MANIFEST.MF >+ * will be analyzed for a Main-Class entry in order to discriminate whether the >+ * specified IArchive is an Application Client jar. >+ */ >+ public static final String DISCRIMINATE_MAIN_CLASS = "DISCRIMINATE_MAIN_CLASS"; //$NON-NLS-1$ > > /** > * Default value = null >@@ -117,36 +130,7 @@ > > public IArchive openArchive(IVirtualComponent virtualComponent) throws ArchiveOpenFailureException { > if (virtualComponent.isBinary()) { >- J2EEModuleVirtualArchiveComponent archiveComponent = (J2EEModuleVirtualArchiveComponent) virtualComponent; >- JavaEEBinaryComponentLoadAdapter loadAdapter = new JavaEEBinaryComponentLoadAdapter(archiveComponent); >- ArchiveOptions archiveOptions = new ArchiveOptions(); >- archiveOptions.setOption(ArchiveOptions.LOAD_ADAPTER, loadAdapter); >- archiveOptions.setOption(ArchiveOptions.ARCHIVE_PATH, loadAdapter.getArchivePath()); >- IArchive parentEARArchive = null; >- try { >- if(archiveComponent.isLinkedToEAR()){ >- try { >- IProject earProject = virtualComponent.getProject(); >- if(earProject != null && EarUtilities.isEARProject(earProject)){ >- IVirtualComponent earComponent = ComponentCore.createComponent(virtualComponent.getProject()); >- if(earComponent != null) { >- parentEARArchive = openArchive(earComponent); >- if(parentEARArchive != null) { >- archiveOptions.setOption(ArchiveOptions.PARENT_ARCHIVE, parentEARArchive); >- } >- } >- } >- } catch(ArchiveOpenFailureException e) { >- org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin.logError(e); >- } >- } >- return openArchive(archiveOptions); >- } finally { >- if(parentEARArchive != null){ >- archiveOptions.removeOption(ArchiveOptions.PARENT_ARCHIVE); >- closeArchive(parentEARArchive); >- } >- } >+ return openBinaryArchive(virtualComponent, true); > } > int type = J2EEVersionConstants.UNKNOWN; > IArchiveLoadAdapter archiveLoadAdapter = null; >@@ -239,6 +223,40 @@ > return null; > } > >+ public IArchive openBinaryArchive(IVirtualComponent virtualComponent, boolean descriminateMainClass) throws ArchiveOpenFailureException { >+ J2EEModuleVirtualArchiveComponent archiveComponent = (J2EEModuleVirtualArchiveComponent) virtualComponent; >+ JavaEEBinaryComponentLoadAdapter loadAdapter = new JavaEEBinaryComponentLoadAdapter(archiveComponent); >+ ArchiveOptions archiveOptions = new ArchiveOptions(); >+ archiveOptions.setOption(ArchiveOptions.LOAD_ADAPTER, loadAdapter); >+ archiveOptions.setOption(ArchiveOptions.ARCHIVE_PATH, loadAdapter.getArchivePath()); >+ archiveOptions.setOption(DISCRIMINATE_MAIN_CLASS, descriminateMainClass); >+ IArchive parentEARArchive = null; >+ try { >+ if(archiveComponent.isLinkedToEAR()){ >+ try { >+ IProject earProject = virtualComponent.getProject(); >+ if(earProject != null && EarUtilities.isEARProject(earProject)){ >+ IVirtualComponent earComponent = ComponentCore.createComponent(virtualComponent.getProject()); >+ if(earComponent != null) { >+ parentEARArchive = openArchive(earComponent); >+ if(parentEARArchive != null) { >+ archiveOptions.setOption(ArchiveOptions.PARENT_ARCHIVE, parentEARArchive); >+ } >+ } >+ } >+ } catch(ArchiveOpenFailureException e) { >+ org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin.logError(e); >+ } >+ } >+ return openArchive(archiveOptions); >+ } finally { >+ if (parentEARArchive != null){ >+ archiveOptions.removeOption(ArchiveOptions.PARENT_ARCHIVE); >+ closeArchive(parentEARArchive); >+ } >+ } >+ } >+ > private Map<IArchive, JavaEEQuickPeek> archiveToJavaEEQuickPeek = new WeakHashMap<IArchive, JavaEEQuickPeek>(); > > /** >@@ -482,32 +500,35 @@ > wrapArchive(simpleArchive, new Path(J2EEConstants.WEBAPP_DD_URI)); > return simpleArchive; > } else if (lastSegment.endsWith(IJ2EEModuleConstants.JAR_EXT)) { >- IPath manifestPath = new Path(J2EEConstants.MANIFEST_URI); >- if (simpleArchive.containsArchiveResource(manifestPath)) { >- InputStream in = null; >- try { >- IArchiveResource manifestResource = simpleArchive.getArchiveResource(manifestPath); >- in = manifestResource.getInputStream(); >- Manifest manifest = new Manifest(in); >- Attributes attributes = manifest.getMainAttributes(); >- String mainClassName = attributes.getValue("Main-Class"); //$NON-NLS-1$ >- if (mainClassName != null) { >- //EE6TODO >- JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(JavaEEQuickPeek.APPLICATION_CLIENT_TYPE, JavaEEQuickPeek.JEE_5_0_ID, JavaEEQuickPeek.JEE_5_0_ID); >- archiveToJavaEEQuickPeek.put(simpleArchive, quickPeek); >- wrapArchive(simpleArchive, new Path(J2EEConstants.APPLICATION_DD_URI)); >- return simpleArchive; >- } >- } catch (FileNotFoundException e) { >- ArchiveUtil.warn(e); >- } catch (IOException e) { >- ArchiveUtil.warn(e); >- } finally { >- if (in != null) { >- try { >- in.close(); >- } catch (IOException e) { >- ArchiveUtil.warn(e); >+ Object discriminateMainClass = simpleArchive.getArchiveOptions().getOption(DISCRIMINATE_MAIN_CLASS); >+ if (null == discriminateMainClass || ((Boolean) discriminateMainClass).booleanValue()) { >+ IPath manifestPath = new Path(J2EEConstants.MANIFEST_URI); >+ if (simpleArchive.containsArchiveResource(manifestPath)) { >+ InputStream in = null; >+ try { >+ IArchiveResource manifestResource = simpleArchive.getArchiveResource(manifestPath); >+ in = manifestResource.getInputStream(); >+ Manifest manifest = new Manifest(in); >+ Attributes attributes = manifest.getMainAttributes(); >+ String mainClassName = attributes.getValue("Main-Class"); //$NON-NLS-1$ >+ if (mainClassName != null) { >+ //EE6TODO >+ JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(JavaEEQuickPeek.APPLICATION_CLIENT_TYPE, JavaEEQuickPeek.JEE_5_0_ID, JavaEEQuickPeek.JEE_5_0_ID); >+ archiveToJavaEEQuickPeek.put(simpleArchive, quickPeek); >+ wrapArchive(simpleArchive, new Path(J2EEConstants.APPLICATION_DD_URI)); >+ return simpleArchive; >+ } >+ } catch (FileNotFoundException e) { >+ ArchiveUtil.warn(e); >+ } catch (IOException e) { >+ ArchiveUtil.warn(e); >+ } finally { >+ if (in != null) { >+ try { >+ in.close(); >+ } catch (IOException e) { >+ ArchiveUtil.warn(e); >+ } > } > } > } >Index: earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java,v >retrieving revision 1.50 >diff -u -r1.50 AddComponentToEnterpriseApplicationOp.java >--- earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java 2 Dec 2009 19:07:43 -0000 1.50 >+++ earproject/org/eclipse/jst/j2ee/application/internal/operations/AddComponentToEnterpriseApplicationOp.java 13 Jan 2010 22:00:43 -0000 >@@ -33,6 +33,7 @@ > import org.eclipse.jst.j2ee.internal.ICommonEMFModule; > import org.eclipse.jst.j2ee.internal.J2EEVersionConstants; > import org.eclipse.jst.j2ee.internal.common.classpath.J2EEComponentClasspathUpdater; >+import org.eclipse.jst.j2ee.internal.componentcore.JavaEEBinaryComponentHelper; > import org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin; > import org.eclipse.jst.j2ee.model.IEARModelProvider; > import org.eclipse.jst.j2ee.model.IModelProvider; >@@ -221,6 +222,12 @@ > > String earDDVersion = JavaEEProjectUtilities.getJ2EEDDProjectVersion(earpj); > boolean useNewModel = earDDVersion.equals(J2EEVersionConstants.VERSION_5_0_TEXT) || earDDVersion.equals(J2EEVersionConstants.VERSION_6_0_TEXT); >+ if (wc.isBinary()){ >+ //[Bug 299549] open and cache archive using the DISCRIMINATE_MAIN_CLASS >+ //option before attempting the JavaEEQuickPeek >+ JavaEEBinaryComponentHelper.openArchive(wc, useNewModel); >+ } >+ > //[Bug 238264] need to use component to determine type of project in-case component is binary > if (JavaEEProjectUtilities.isDynamicWebComponent(wc)) { > if (useNewModel) { >Index: j2eecreation/org/eclipse/jst/j2ee/internal/componentcore/JavaEEBinaryComponentHelper.java >=================================================================== >RCS file: /cvsroot/webtools/jeetools/plugins/org.eclipse.jst.j2ee/j2eecreation/org/eclipse/jst/j2ee/internal/componentcore/JavaEEBinaryComponentHelper.java,v >retrieving revision 1.11 >diff -u -r1.11 JavaEEBinaryComponentHelper.java >--- j2eecreation/org/eclipse/jst/j2ee/internal/componentcore/JavaEEBinaryComponentHelper.java 12 Dec 2009 04:34:09 -0000 1.11 >+++ j2eecreation/org/eclipse/jst/j2ee/internal/componentcore/JavaEEBinaryComponentHelper.java 13 Jan 2010 22:00:43 -0000 >@@ -45,7 +45,7 @@ > > private IArchive archive; > private EnterpriseBinaryComponentHelper legacyBinaryHelper; >- >+ private boolean descriminateMainClass = true; > private int localArchiveAccessCount = 0; > > public static JavaEEQuickPeek getJavaEEQuickPeek(IPath filesystemPath) { >@@ -82,6 +82,23 @@ > } > } > } >+ >+ public static void openArchive(IVirtualComponent aBinaryComponent, boolean descriminateMainClass) { >+ JavaEEBinaryComponentHelper helper = null; >+ try { >+ helper = new JavaEEBinaryComponentHelper(aBinaryComponent); >+ helper.setDescriminateMainClass(descriminateMainClass); >+ try { >+ helper.openArchive(); >+ } catch (ArchiveOpenFailureException e) { >+ J2EEPlugin.logError(e); >+ } >+ } finally { >+ if (helper != null) { >+ helper.dispose(); >+ } >+ } >+ } > > public JavaEEBinaryComponentHelper(IVirtualComponent aBinaryComponent) { > super(aBinaryComponent); >@@ -391,6 +408,14 @@ > ArchiveCache.getInstance().clearAllArchivesInProject(earProject); > } > >+ public void setDescriminateMainClass(boolean archiveOption) { >+ descriminateMainClass = archiveOption; >+ } >+ >+ public boolean shouldDescriminateMainClass() { >+ return descriminateMainClass; >+ } >+ > /** > * This cache manages IArchives across all > * {@link JavaEEBinaryComponentHelper} instances. If multiple >@@ -499,7 +524,13 @@ > } > > public synchronized IArchive openArchive(JavaEEBinaryComponentHelper helper) throws ArchiveOpenFailureException { >- IArchive archive = JavaEEArchiveUtilities.INSTANCE.openArchive(helper.getComponent()); >+ IArchive archive; >+ if (helper.getComponent().isBinary()) { >+ archive = JavaEEArchiveUtilities.INSTANCE.openBinaryArchive(helper.getComponent(), helper.shouldDescriminateMainClass()); >+ } >+ else { >+ archive = JavaEEArchiveUtilities.INSTANCE.openArchive(helper.getComponent()); >+ } > componentsToArchives.put(helper.getComponent(), archive); > archiveAccessCount.put(archive, new Integer(0)); > return archive;
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 299549
: 156056