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