Skip to content

Commit

Permalink
WELD-1962 Make use of ZipFile.getEntry()
Browse files Browse the repository at this point in the history
- also revert Weld.createDeployment() method signature change
  • Loading branch information
mkouba authored and jharting committed Aug 20, 2015
1 parent 0c641a4 commit 10287ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.io.IOException;
import java.net.URL;
import java.security.AccessController;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -119,26 +118,17 @@ private void scanDirectory(File entryDirectory, ImmutableList.Builder<ScanResult

private void scanJarFile(File entryFile, ImmutableList.Builder<ScanResult> results) throws IOException {
try (ZipFile zip = new ZipFile(entryFile)) {
Enumeration<? extends ZipEntry> entries = zip.entries();
BeansXml beansXml = null;
boolean extensionFound = false;
while (entries.hasMoreElements()) {
ZipEntry zipEntry = entries.nextElement();
if (zipEntry.getName().equals(AbstractWeldDeployment.BEANS_XML)) {
logger.debugv(BEANS_XML_FOUND_MESSAGE, entryFile);
beansXml = parseBeansXml(new URL(PROCOTOL_JAR + ":" + entryFile.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR + zipEntry.getName()));
}
if (zipEntry.getName().equals(EXTENSION_FILE)) {
extensionFound = true;
}
}
if (beansXml != null) {
ZipEntry beansXmlEntry = zip.getEntry(AbstractWeldDeployment.BEANS_XML);
if (beansXmlEntry != null) {
logger.debugv(BEANS_XML_FOUND_MESSAGE, entryFile);
BeansXml beansXml = parseBeansXml(
new URL(PROCOTOL_JAR + ":" + entryFile.toURI().toURL().toExternalForm() + JAR_URL_SEPARATOR + beansXmlEntry.getName()));
if (accept(beansXml)) {
results.add(new ScanResult(beansXml, entryFile.getPath()));
}
} else {
// No beans.xml found - check whether the bean archive contains an extension
if (!extensionFound) {
if (zip.getEntry(EXTENSION_FILE) == null) {
logger.debugv(BEANS_XML_NOT_FOUND_MESSAGE, entryFile);
results.add(new ScanResult(null, entryFile.getPath()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ public WeldContainer initialize() {
}

final WeldBootstrap bootstrap = new WeldBootstrap();
final Deployment deployment = createDeployment(bootstrap);
final Deployment deployment = createDeployment(resourceLoader, bootstrap);

final ExternalConfigurationBuilder configurationBuilder = new ExternalConfigurationBuilder()
// weld-se uses CommonForkJoinPoolExecutorServices by default
Expand Down Expand Up @@ -629,7 +629,7 @@ public Weld setClassLoader(ClassLoader classLoader) {
* @param resourceLoader
* @param bootstrap
*/
protected Deployment createDeployment(CDI11Bootstrap bootstrap) {
protected Deployment createDeployment(ResourceLoader resourceLoader, CDI11Bootstrap bootstrap) {

final Iterable<Metadata<Extension>> extensions = getExtensions(WeldResourceLoader.getClassLoader(), bootstrap);
final TypeDiscoveryConfiguration typeDiscoveryConfiguration = bootstrap.startExtensions(extensions);
Expand Down

0 comments on commit 10287ce

Please sign in to comment.