Ejemplo n.º 1
0
 /**
  * Set the classpath to a given list of libdirs.
  *
  * @param libdirList is an arraylist of File objects, each representing a directory.
  */
 public synchronized void setClassPath(ArrayList libdirList) throws ManifoldCFException {
   if (currentClasspath.size() > 0) {
     currentClasspath.clear();
     classLoader = null;
   }
   int i = 0;
   while (i < libdirList.size()) {
     File dir = (File) libdirList.get(i++);
     addToClassPath(dir, null);
   }
 }
Ejemplo n.º 2
0
  /** Get the class loader representing this resource loader. */
  public synchronized ClassLoader getClassLoader() throws ManifoldCFException {
    if (classLoader == null) {
      // Mint a class loader on demand
      if (currentClasspath.size() == 0) classLoader = parent;
      else {
        URL[] elements = new URL[currentClasspath.size()];

        for (int j = 0; j < currentClasspath.size(); j++) {
          try {
            URL element = ((File) currentClasspath.get(j)).toURI().normalize().toURL();
            elements[j] = element;
          } catch (MalformedURLException e) {
            // Should never happen, but...
            throw new ManifoldCFException(e.getMessage(), e);
          }
        }
        classLoader = URLClassLoader.newInstance(elements, parent);
      }
    }
    return classLoader;
  }
Ejemplo n.º 3
0
 /** Clear the class-search path. */
 public synchronized void clearClassPath() {
   if (currentClasspath.size() == 0) return;
   currentClasspath.clear();
   classLoader = null;
 }