Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.modules;
import java.io.File;
import java.io.IOException;
import java.security.AccessController;
import java.util.Enumeration;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
/**
* A utility class which maintains the set of JDK paths. Makes certain assumptions about the disposition of the
* class loader used to load JBoss Modules; thus this class should only be used when booted up via the "-jar" or "-cp"
* switches.
*
* @author David M. Lloyd
*/
final class JDKPaths {
static final Set JDK;
static {
final Set pathSet = new FastCopyHashSet(1024);
final Set jarSet = new FastCopyHashSet(1024);
final String sunBootClassPath = AccessController.doPrivileged(new PropertyReadAction("sun.boot.class.path"));
final String javaClassPath = AccessController.doPrivileged(new PropertyReadAction("java.class.path"));
processClassPathItem(sunBootClassPath, jarSet, pathSet);
processClassPathItem(javaClassPath, jarSet, pathSet);
pathSet.add("org/jboss/modules");
pathSet.add("org/jboss/modules/filter");
pathSet.add("org/jboss/modules/log");
pathSet.add("org/jboss/modules/management");
pathSet.add("org/jboss/modules/ref");
JDK = pathSet;
}
private JDKPaths() {
}
private static void processClassPathItem(final String classPath, final Set jarSet, final Set pathSet) {
if (classPath == null) return;
int s = 0, e;
do {
e = classPath.indexOf(File.pathSeparatorChar, s);
String item = e == -1 ? classPath.substring(s) : classPath.substring(s, e);
if (! jarSet.contains(item)) {
final File file = new File(item);
if (file.isDirectory()) {
processDirectory0(pathSet, file);
} else {
try {
final ZipFile zipFile = new ZipFile(file);
try {
final Enumeration extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
final ZipEntry entry = entries.nextElement();
final String name = entry.getName();
final int lastSlash = name.lastIndexOf('/');
if (lastSlash != -1) {
pathSet.add(name.substring(0, lastSlash));
}
}
} finally {
zipFile.close();
}
} catch (IOException ex) {
// ignore
}
}
}
s = e + 1;
} while (e != -1);
}
private static void processDirectory0(final Set pathSet, final File file) {
for (File entry : file.listFiles()) {
if (entry.isDirectory()) {
processDirectory1(pathSet, entry, file.getPath());
} else {
final String parent = entry.getParent();
if (parent != null) pathSet.add(parent);
}
}
}
private static void processDirectory1(final Set pathSet, final File file, final String pathBase) {
for (File entry : file.listFiles()) {
if (entry.isDirectory()) {
processDirectory1(pathSet, entry, pathBase);
} else {
String packagePath = entry.getParent();
if (packagePath != null) {
packagePath = packagePath.substring(pathBase.length()).replace('\\', '/');;
if(packagePath.startsWith("/")) {
packagePath = packagePath.substring(1);
}
pathSet.add(packagePath);
}
}
}
}
}