|
Lines 79-84
Link Here
|
| 79 |
* specified IArchive is an EJB 3.0 jar. |
79 |
* specified IArchive is an EJB 3.0 jar. |
| 80 |
*/ |
80 |
*/ |
| 81 |
public static final String DISCRIMINATE_EJB_ANNOTATIONS = "DISCRIMINATE_EJB_ANNOTATIONS"; //$NON-NLS-1$ |
81 |
public static final String DISCRIMINATE_EJB_ANNOTATIONS = "DISCRIMINATE_EJB_ANNOTATIONS"; //$NON-NLS-1$ |
|
|
82 |
|
| 83 |
/** |
| 84 |
* Default value = Boolean.TRUE Valid values = Boolean.TRUE or Boolean.FALSE |
| 85 |
* |
| 86 |
* An ArchiveOption used to specify whether |
| 87 |
* {@link #openArchive(ArchiveOptions)} should attempt to fully discriminate |
| 88 |
* a JAR file from an Application Client JAR file. This option is only relevant |
| 89 |
* if the {@link #DISCRIMINATE_JAVA_EE} option is also set to Boolean.TRUE. If |
| 90 |
* both options are set to true then as a last resort the MANIFEST.MF |
| 91 |
* will be analyzed for a Main-Class entry in order to discriminate whether the |
| 92 |
* specified IArchive is an Application Client jar. |
| 93 |
*/ |
| 94 |
public static final String DISCRIMINATE_MAIN_CLASS = "DISCRIMINATE_MAIN_CLASS"; //$NON-NLS-1$ |
| 82 |
|
95 |
|
| 83 |
/** |
96 |
/** |
| 84 |
* Default value = null |
97 |
* Default value = null |
|
Lines 117-152
Link Here
|
| 117 |
|
130 |
|
| 118 |
public IArchive openArchive(IVirtualComponent virtualComponent) throws ArchiveOpenFailureException { |
131 |
public IArchive openArchive(IVirtualComponent virtualComponent) throws ArchiveOpenFailureException { |
| 119 |
if (virtualComponent.isBinary()) { |
132 |
if (virtualComponent.isBinary()) { |
| 120 |
J2EEModuleVirtualArchiveComponent archiveComponent = (J2EEModuleVirtualArchiveComponent) virtualComponent; |
133 |
return openBinaryArchive(virtualComponent, true); |
| 121 |
JavaEEBinaryComponentLoadAdapter loadAdapter = new JavaEEBinaryComponentLoadAdapter(archiveComponent); |
|
|
| 122 |
ArchiveOptions archiveOptions = new ArchiveOptions(); |
| 123 |
archiveOptions.setOption(ArchiveOptions.LOAD_ADAPTER, loadAdapter); |
| 124 |
archiveOptions.setOption(ArchiveOptions.ARCHIVE_PATH, loadAdapter.getArchivePath()); |
| 125 |
IArchive parentEARArchive = null; |
| 126 |
try { |
| 127 |
if(archiveComponent.isLinkedToEAR()){ |
| 128 |
try { |
| 129 |
IProject earProject = virtualComponent.getProject(); |
| 130 |
if(earProject != null && EarUtilities.isEARProject(earProject)){ |
| 131 |
IVirtualComponent earComponent = ComponentCore.createComponent(virtualComponent.getProject()); |
| 132 |
if(earComponent != null) { |
| 133 |
parentEARArchive = openArchive(earComponent); |
| 134 |
if(parentEARArchive != null) { |
| 135 |
archiveOptions.setOption(ArchiveOptions.PARENT_ARCHIVE, parentEARArchive); |
| 136 |
} |
| 137 |
} |
| 138 |
} |
| 139 |
} catch(ArchiveOpenFailureException e) { |
| 140 |
org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin.logError(e); |
| 141 |
} |
| 142 |
} |
| 143 |
return openArchive(archiveOptions); |
| 144 |
} finally { |
| 145 |
if(parentEARArchive != null){ |
| 146 |
archiveOptions.removeOption(ArchiveOptions.PARENT_ARCHIVE); |
| 147 |
closeArchive(parentEARArchive); |
| 148 |
} |
| 149 |
} |
| 150 |
} |
134 |
} |
| 151 |
int type = J2EEVersionConstants.UNKNOWN; |
135 |
int type = J2EEVersionConstants.UNKNOWN; |
| 152 |
IArchiveLoadAdapter archiveLoadAdapter = null; |
136 |
IArchiveLoadAdapter archiveLoadAdapter = null; |
|
Lines 239-244
Link Here
|
| 239 |
return null; |
223 |
return null; |
| 240 |
} |
224 |
} |
| 241 |
|
225 |
|
|
|
226 |
public IArchive openBinaryArchive(IVirtualComponent virtualComponent, boolean descriminateMainClass) throws ArchiveOpenFailureException { |
| 227 |
J2EEModuleVirtualArchiveComponent archiveComponent = (J2EEModuleVirtualArchiveComponent) virtualComponent; |
| 228 |
JavaEEBinaryComponentLoadAdapter loadAdapter = new JavaEEBinaryComponentLoadAdapter(archiveComponent); |
| 229 |
ArchiveOptions archiveOptions = new ArchiveOptions(); |
| 230 |
archiveOptions.setOption(ArchiveOptions.LOAD_ADAPTER, loadAdapter); |
| 231 |
archiveOptions.setOption(ArchiveOptions.ARCHIVE_PATH, loadAdapter.getArchivePath()); |
| 232 |
archiveOptions.setOption(DISCRIMINATE_MAIN_CLASS, descriminateMainClass); |
| 233 |
IArchive parentEARArchive = null; |
| 234 |
try { |
| 235 |
if(archiveComponent.isLinkedToEAR()){ |
| 236 |
try { |
| 237 |
IProject earProject = virtualComponent.getProject(); |
| 238 |
if(earProject != null && EarUtilities.isEARProject(earProject)){ |
| 239 |
IVirtualComponent earComponent = ComponentCore.createComponent(virtualComponent.getProject()); |
| 240 |
if(earComponent != null) { |
| 241 |
parentEARArchive = openArchive(earComponent); |
| 242 |
if(parentEARArchive != null) { |
| 243 |
archiveOptions.setOption(ArchiveOptions.PARENT_ARCHIVE, parentEARArchive); |
| 244 |
} |
| 245 |
} |
| 246 |
} |
| 247 |
} catch(ArchiveOpenFailureException e) { |
| 248 |
org.eclipse.jst.j2ee.internal.plugin.J2EEPlugin.logError(e); |
| 249 |
} |
| 250 |
} |
| 251 |
return openArchive(archiveOptions); |
| 252 |
} finally { |
| 253 |
if (parentEARArchive != null){ |
| 254 |
archiveOptions.removeOption(ArchiveOptions.PARENT_ARCHIVE); |
| 255 |
closeArchive(parentEARArchive); |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
|
| 242 |
private Map<IArchive, JavaEEQuickPeek> archiveToJavaEEQuickPeek = new WeakHashMap<IArchive, JavaEEQuickPeek>(); |
260 |
private Map<IArchive, JavaEEQuickPeek> archiveToJavaEEQuickPeek = new WeakHashMap<IArchive, JavaEEQuickPeek>(); |
| 243 |
|
261 |
|
| 244 |
/** |
262 |
/** |
|
Lines 482-513
Link Here
|
| 482 |
wrapArchive(simpleArchive, new Path(J2EEConstants.WEBAPP_DD_URI)); |
500 |
wrapArchive(simpleArchive, new Path(J2EEConstants.WEBAPP_DD_URI)); |
| 483 |
return simpleArchive; |
501 |
return simpleArchive; |
| 484 |
} else if (lastSegment.endsWith(IJ2EEModuleConstants.JAR_EXT)) { |
502 |
} else if (lastSegment.endsWith(IJ2EEModuleConstants.JAR_EXT)) { |
| 485 |
IPath manifestPath = new Path(J2EEConstants.MANIFEST_URI); |
503 |
Object discriminateMainClass = simpleArchive.getArchiveOptions().getOption(DISCRIMINATE_MAIN_CLASS); |
| 486 |
if (simpleArchive.containsArchiveResource(manifestPath)) { |
504 |
if (null == discriminateMainClass || ((Boolean) discriminateMainClass).booleanValue()) { |
| 487 |
InputStream in = null; |
505 |
IPath manifestPath = new Path(J2EEConstants.MANIFEST_URI); |
| 488 |
try { |
506 |
if (simpleArchive.containsArchiveResource(manifestPath)) { |
| 489 |
IArchiveResource manifestResource = simpleArchive.getArchiveResource(manifestPath); |
507 |
InputStream in = null; |
| 490 |
in = manifestResource.getInputStream(); |
508 |
try { |
| 491 |
Manifest manifest = new Manifest(in); |
509 |
IArchiveResource manifestResource = simpleArchive.getArchiveResource(manifestPath); |
| 492 |
Attributes attributes = manifest.getMainAttributes(); |
510 |
in = manifestResource.getInputStream(); |
| 493 |
String mainClassName = attributes.getValue("Main-Class"); //$NON-NLS-1$ |
511 |
Manifest manifest = new Manifest(in); |
| 494 |
if (mainClassName != null) { |
512 |
Attributes attributes = manifest.getMainAttributes(); |
| 495 |
//EE6TODO |
513 |
String mainClassName = attributes.getValue("Main-Class"); //$NON-NLS-1$ |
| 496 |
JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(JavaEEQuickPeek.APPLICATION_CLIENT_TYPE, JavaEEQuickPeek.JEE_5_0_ID, JavaEEQuickPeek.JEE_5_0_ID); |
514 |
if (mainClassName != null) { |
| 497 |
archiveToJavaEEQuickPeek.put(simpleArchive, quickPeek); |
515 |
//EE6TODO |
| 498 |
wrapArchive(simpleArchive, new Path(J2EEConstants.APPLICATION_DD_URI)); |
516 |
JavaEEQuickPeek quickPeek = new JavaEEQuickPeek(JavaEEQuickPeek.APPLICATION_CLIENT_TYPE, JavaEEQuickPeek.JEE_5_0_ID, JavaEEQuickPeek.JEE_5_0_ID); |
| 499 |
return simpleArchive; |
517 |
archiveToJavaEEQuickPeek.put(simpleArchive, quickPeek); |
| 500 |
} |
518 |
wrapArchive(simpleArchive, new Path(J2EEConstants.APPLICATION_DD_URI)); |
| 501 |
} catch (FileNotFoundException e) { |
519 |
return simpleArchive; |
| 502 |
ArchiveUtil.warn(e); |
520 |
} |
| 503 |
} catch (IOException e) { |
521 |
} catch (FileNotFoundException e) { |
| 504 |
ArchiveUtil.warn(e); |
522 |
ArchiveUtil.warn(e); |
| 505 |
} finally { |
523 |
} catch (IOException e) { |
| 506 |
if (in != null) { |
524 |
ArchiveUtil.warn(e); |
| 507 |
try { |
525 |
} finally { |
| 508 |
in.close(); |
526 |
if (in != null) { |
| 509 |
} catch (IOException e) { |
527 |
try { |
| 510 |
ArchiveUtil.warn(e); |
528 |
in.close(); |
|
|
529 |
} catch (IOException e) { |
| 530 |
ArchiveUtil.warn(e); |
| 531 |
} |
| 511 |
} |
532 |
} |
| 512 |
} |
533 |
} |
| 513 |
} |
534 |
} |