| | import java.io.InputStream; |
| | import java.io.IOException; |
| | +import java.io.File; |
| | + |
| | +import java.net.MalformedURLException; |
| | +import java.net.URI; |
| | +import java.net.URL; |
| | +import java.net.URLClassLoader; |
| | |
| | import java.util.Map; |
 |
| | configureServletMap(); |
| | configureServletDefault(); |
| | + } |
| | + |
| | + /** |
| | + * Adds the directories returned from getResourcePaths to the classpath. |
| | + * This avoids having to make an explicit dependency on the logger. |
| | + */ |
| | + protected void configureClasspath() throws MalformedURLException { |
| | + Thread.currentThread().setContextClassLoader( createClassLoader() ); |
| | } |
| | |
 |
| | "source/xsl" |
| | }; |
| | + } |
| | + |
| | + protected URL[] getResourceURLs() throws MalformedURLException { |
| | + String[] resources = getResourcePaths(); |
| | + URL[] result = new URL[ resources.length ]; |
| | + int index = 0; |
| | + |
| | + for( String resource : resources ) { |
| | + result[ index ] = toURI( resource ).toURL(); |
| | + } |
| | + |
| | + return result; |
| | + } |
| | + |
| | + protected URI toURI( String resource ) throws MalformedURLException { |
| | + return (new File( resource )).toURI(); |
| | + } |
| | + |
| | + protected ClassLoader createClassLoader() throws MalformedURLException { |
| | + return new URLClassLoader( getResourceURLs(), getClassLoader() ); |
| | + } |
| | + |
| | + protected ClassLoader getClassLoader() { |
| | + return Thread.currentThread().getContextClassLoader(); |
| | } |
| | |