1 package javax.jdo;
2
3 import java.io.File;
4 import java.io.IOException;
5 import java.net.URL;
6 import java.net.URLClassLoader;
7
8 /**
9 * A class loader that allows the user to add classpath entries.
10 */
11 public class JDOConfigTestClassLoader extends URLClassLoader {
12
13 /**
14 * Uses the CTCCL as the parent and adds the given path to this loader's classpath.
15 */
16 public JDOConfigTestClassLoader(String... additionalPath) throws IOException {
17 this(Thread.currentThread().getContextClassLoader(), additionalPath);
18 }
19
20 /**
21 * Uses the given ClassLoader as the parent & adds the given paths to this loader's classpath.
22 */
23 public JDOConfigTestClassLoader(ClassLoader parent, String... additionalPaths) throws IOException {
24 super(new URL[] {}, parent);
25
26 for (String path : additionalPaths) {
27 addFile(path);
28 }
29 }
30
31 public void addFile(String s) throws IOException {
32 addFile(new File(s));
33 }
34
35 public void addFile(File f) throws IOException {
36 addURL(f.toURI().toURL());
37 }
38
39 @Override
40 public void addURL(URL url) {
41 super.addURL(url);
42 }
43 }