introduce ClassSource configuration

master
patrickroemer 18 years ago
parent 07f2be8db4
commit ffa5912729
  1. 21
      src/EDU/purdue/cs/bloat/file/ClassFileLoader.java
  2. 5
      src/EDU/purdue/cs/bloat/file/ClassSource.java
  3. 9
      src/EDU/purdue/cs/bloat/file/DefaultClassSource.java

@ -56,12 +56,9 @@ public class ClassFileLoader implements ClassInfoLoader {
private static final int CACHE_LIMIT = 10;
/**
* Constructor. The classpath initially consists of the contents of the
* <tt>java.class.path</tt> and <tt>sun.boot.class.path</tt> system
* properties.
*/
public ClassFileLoader() {
private ClassSource _classSource;
public ClassFileLoader(ClassSource classSource) {
outputDir = new File(".");
classpath = System.getProperty("java.class.path");
classpath += File.pathSeparator
@ -73,6 +70,16 @@ public class ClassFileLoader implements ClassInfoLoader {
openZipFiles = new HashMap();
cache = new LinkedList();
verbose = false;
_classSource = classSource;
}
/**
* Constructor. The classpath initially consists of the contents of the
* <tt>java.class.path</tt> and <tt>sun.boot.class.path</tt> system
* properties.
*/
public ClassFileLoader() {
this(new DefaultClassSource());
}
public void setVerbose(final boolean verbose) {
@ -205,7 +212,7 @@ public class ClassFileLoader implements ClassInfoLoader {
private ClassInfo loadClassFromRessource(String name){
name = name.replaceAll("/",".");
try {
Class clazz = Class.forName(name);
Class clazz = _classSource.loadClass(name);
int i = name.lastIndexOf('.');
if (i >= 0 && i < name.length()){
name = name.substring(i+1);

@ -0,0 +1,5 @@
package EDU.purdue.cs.bloat.file;
public interface ClassSource {
Class loadClass(String name) throws ClassNotFoundException ;
}

@ -0,0 +1,9 @@
package EDU.purdue.cs.bloat.file;
public class DefaultClassSource implements ClassSource {
public Class loadClass(String name) throws ClassNotFoundException {
return Class.forName(name);
}
}
Loading…
Cancel
Save