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 215639 Details for
Bug 379112
Performance issue on large WAR deployment
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 proposal (new)
patch.txt (text/plain), 5.77 KB, created by
Radoslav Ivanov
on 2012-05-15 09:41:21 EDT
(
hide
)
Description:
Patch proposal (new)
Filename:
MIME Type:
Creator:
Radoslav Ivanov
Created:
2012-05-15 09:41:21 EDT
Size:
5.77 KB
patch
obsolete
>diff --git a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java >index bbdb962..186f795 100644 >--- a/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java >+++ b/org.eclipse.gemini.web.core/src/main/java/org/eclipse/gemini/web/internal/url/WebBundleScanner.java >@@ -19,15 +19,21 @@ package org.eclipse.gemini.web.internal.url; > import java.io.File; > import java.io.FileInputStream; > import java.io.IOException; >+import java.io.InputStream; > import java.net.URI; > import java.net.URISyntaxException; > import java.net.URL; >+import java.net.URLDecoder; >+import java.util.Collection; >+import java.util.Enumeration; > import java.util.HashSet; > import java.util.Set; > import java.util.jar.Attributes; > import java.util.jar.JarEntry; >+import java.util.jar.JarFile; > import java.util.jar.JarInputStream; > import java.util.jar.Manifest; >+import java.util.zip.ZipEntry; > > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; >@@ -59,6 +65,8 @@ final class WebBundleScanner { > private final Object monitor = new Object(); > > private final URL source; >+ private final String localSourcePath; >+ private final Collection<ZipEntry> sourceZipEntries = new HashSet<ZipEntry>(); > > private final WebBundleScannerCallback callBack; > >@@ -81,6 +89,7 @@ final class WebBundleScanner { > this.source = source; > this.callBack = callBack; > this.findClassesInNestedJars = findClassesInNestedJars; >+ this.localSourcePath = getLocalSourcePath(source); > } > > /** >@@ -92,6 +101,7 @@ final class WebBundleScanner { > void scanWar() throws IOException { > synchronized (this.monitor) { > this.scannedJars.clear(); >+ this.sourceZipEntries.clear(); > if (isDirectory()) { > scanWarDirectory(); > } else { >@@ -208,14 +218,16 @@ final class WebBundleScanner { > } > } > } >- >- JarEntry entry; >- while ((entry = jis.getNextJarEntry()) != null) { >- String entryName = entry.getName(); >- if (entryName.endsWith(CLASS_SUFFIX)) { >- notifyClassFound(entryName); >- } >- } >+ >+ if (this.findClassesInNestedJars) { >+ JarEntry entry; >+ while ((entry = jis.getNextJarEntry()) != null) { >+ String entryName = entry.getName(); >+ if (entryName.endsWith(CLASS_SUFFIX)) { >+ notifyClassFound(entryName); >+ } >+ } >+ } > } > > private static Path getNormalisedDirectoryPath(String jarEntryName) { >@@ -246,8 +258,24 @@ final class WebBundleScanner { > throw new IllegalStateException("Unexpected URISyntaxException.", e); > } > } >+ >+ private void scanNestedJarInWarFile(final String jarPath) throws IOException { >+ if (this.localSourcePath == null) { >+ scanNestedJarInWarFileWithStream(jarPath); >+ return; >+ } >+ >+ scanNestedJarInWarFileWithZipFile(jarPath, this.localSourcePath); >+ } >+ >+ private String getLocalSourcePath(final URL url) { >+ if (!FILE_SCHEME.equals(this.source.getProtocol())) { >+ return null; >+ } >+ return URLDecoder.decode(url.getPath()); >+ } > >- private void scanNestedJarInWarFile(String jarPath) throws IOException { >+ private void scanNestedJarInWarFileWithStream(String jarPath) throws IOException { > JarInputStream jis = new JarInputStream(this.source.openStream()); > try { > JarEntry entry; >@@ -263,13 +291,53 @@ final class WebBundleScanner { > } finally { > IOUtils.closeQuietly(jis); > } >- >+ } >+ >+ private void scanNestedJarInWarFileWithZipFile(String jarPath, String localSourcePath) throws IOException { >+ JarFile jarFile = null; >+ try { >+ InputStream foundInputStream = null; >+ String foundZipEntryName = null; >+ if (sourceZipEntries.isEmpty()) {//then search and cache all entries >+ jarFile = new JarFile(localSourcePath); >+ Enumeration<JarEntry> jarFileEntries = jarFile.entries(); >+ while (jarFileEntries.hasMoreElements()) { >+ final ZipEntry zipEntry = jarFileEntries.nextElement(); >+ // 1. cache >+ sourceZipEntries.add(zipEntry); >+ // 2. search if it is not found still >+ if ((foundZipEntryName == null) && jarPath.endsWith(zipEntry.getName())) { >+ foundZipEntryName = zipEntry.getName(); >+ foundInputStream = jarFile.getInputStream(zipEntry); >+ } >+ } >+ } else {//search entry in cache >+ for (ZipEntry zipEntry: sourceZipEntries) { >+ if (jarPath.endsWith(zipEntry.getName())) { >+ jarFile = new JarFile(localSourcePath); >+ foundZipEntryName = zipEntry.getName(); >+ foundInputStream = jarFile.getInputStream(zipEntry); >+ break; >+ } >+ >+ } >+ } >+ >+ if ((foundZipEntryName != null) && driveCallBackIfNewJarFound(foundZipEntryName)) { >+ JarInputStream nestedJis = new JarInputStream(foundInputStream); >+ doScanNestedJar(foundZipEntryName, nestedJis); >+ } >+ } finally {//quiet close >+ if (jarFile != null) { >+ try { >+ jarFile.close(); >+ } catch (IOException _) {} >+ } >+ } > } > >- private void notifyClassFound(String entryName) { >- if (this.findClassesInNestedJars) { >- this.callBack.classFound(entryName); >- } >+ private void notifyClassFound(String entryName) { >+ this.callBack.classFound(entryName); > } > > private boolean isDirectory() {
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 379112
:
215391
|
215639
|
216458
|
216459