View Javadoc

1   package com.atlassian.plugin.classloader;
2   
3   import java.io.IOException;
4   import java.io.File;
5   import java.net.URL;
6   import java.util.Enumeration;
7   import java.util.Collections;
8   
9   /**
10   * An abstract class loader to show what you need to implement.
11   */
12  abstract class AbstractClassLoader extends ClassLoader
13  {
14      protected AbstractClassLoader(ClassLoader parent)
15      {
16          super(parent);
17      }
18  
19      protected AbstractClassLoader()
20      {
21          super();
22      }
23  
24      protected abstract URL findResource(String name);
25  
26      protected abstract Class findClass(String className) throws ClassNotFoundException;
27  
28      /**
29       * The default implementation returns a "singleton" enumeration over the result
30       * of {@link #findResource(String)}.
31       *
32       * @param name the name of the resource
33       * @return an enumeration over all matching resources
34       * @throws IOException This implementation will not throw this exception
35       */
36      protected Enumeration findResources(String name) throws IOException
37      {
38          final URL url = this.findResource(name);
39          return url != null ? Collections.enumeration(Collections.singleton(url)) : null;
40      }
41  }