[jboss-cvs] javassist/src/main/javassist ...
Shigeru Chiba
chiba at is.titech.ac.jp
Fri Nov 2 13:15:01 EDT 2007
User: chiba
Date: 07/11/02 13:15:01
Modified: src/main/javassist ClassPoolTail.java ClassPool.java
Log:
supported the class path wildcards.
Revision Changes Path
1.16 +55 -5 javassist/src/main/javassist/ClassPoolTail.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ClassPoolTail.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/ClassPoolTail.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ClassPoolTail.java 4 Jun 2007 03:11:11 -0000 1.15
+++ ClassPoolTail.java 2 Nov 2007 17:15:01 -0000 1.16
@@ -72,6 +72,51 @@
}
}
+final class JarDirClassPath implements ClassPath {
+ JarClassPath[] jars;
+
+ JarDirClassPath(String dirName) throws NotFoundException {
+ File[] files = new File(dirName).listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ name = name.toLowerCase();
+ return name.endsWith(".jar") || name.endsWith(".zip");
+ }
+ });
+
+ jars = new JarClassPath[files.length];
+ for (int i = 0; i < files.length; i++)
+ jars[i] = new JarClassPath(files[i].getPath());
+ }
+
+ public InputStream openClassfile(String classname) throws NotFoundException {
+ if (jars != null)
+ for (int i = 0; i < jars.length; i++) {
+ InputStream is = jars[i].openClassfile(classname);
+ if (is != null)
+ return is;
+ }
+
+ return null; // not found
+ }
+
+ public URL find(String classname) {
+ if (jars != null)
+ for (int i = 0; i < jars.length; i++) {
+ URL url = jars[i].find(classname);
+ if (url != null)
+ return url;
+ }
+
+ return null; // not found
+ }
+
+ public void close() {
+ if (jars != null)
+ for (int i = 0; i < jars.length; i++)
+ jars[i].close();
+ }
+}
+
final class JarClassPath implements ClassPath {
JarFile jarfile;
String jarfileURL;
@@ -206,11 +251,16 @@
private static ClassPath makePathObject(String pathname)
throws NotFoundException
{
- int i = pathname.lastIndexOf('.');
- if (i >= 0) {
- String ext = pathname.substring(i).toLowerCase();
- if (ext.equals(".jar") || ext.equals(".zip"))
+ String lower = pathname.toLowerCase();
+ if (lower.endsWith(".jar") || lower.endsWith(".zip"))
return new JarClassPath(pathname);
+
+ int len = pathname.length();
+ if (len > 2 && pathname.charAt(len - 1) == '*'
+ && (pathname.charAt(len - 2) == '/'
+ || pathname.charAt(len - 2) == File.separatorChar)) {
+ String dir = pathname.substring(0, len - 2);
+ return new JarDirClassPath(dir);
}
return new DirClassPath(pathname);
1.65 +6 -0 javassist/src/main/javassist/ClassPool.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ClassPool.java
===================================================================
RCS file: /cvsroot/jboss/javassist/src/main/javassist/ClassPool.java,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- ClassPool.java 3 Jul 2007 15:31:19 -0000 1.64
+++ ClassPool.java 2 Nov 2007 17:15:01 -0000 1.65
@@ -757,6 +757,9 @@
*
* @param pathname the path name of the directory or jar file.
* It must not end with a path separator ("/").
+ * If the path name ends with "/*", then all the
+ * jar files matching the path name are inserted.
+ *
* @return the inserted class path.
* @throws NotFoundException if the jar file is not found.
*/
@@ -772,6 +775,9 @@
*
* @param pathname the path name of the directory or jar file.
* It must not end with a path separator ("/").
+ * If the path name ends with "/*", then all the
+ * jar files matching the path name are appended.
+ *
* @return the appended class path.
* @throws NotFoundException if the jar file is not found.
*/
More information about the jboss-cvs-commits
mailing list