<<Maven Example | Home Print Layout | Spring Framework>> |
IURLFactory
:
One-Jar-URL-Factory: com.simontuffs.onejar.JarClassLoader$OneJarURLFactoryOne-JAR supports custom generation of URL's based on a factory interface in the JarClassLoader:
// Injectable URL factory. public static interface IURLFactory { public URL getURL(String codebase, String resource) throws MalformedURLException; public URL getCodeBase(String jar) throws MalformedURLException; }A factory must support
getUrl(String codebase, String resource)
, returning a URL for a resource
at a given codebase. It must also support getCodeBase(String jar)
, returning a URL for a given codebase.
One-JAR comes pre-configured with two factories which return different kinds of URLs:
onejar:/<codebase>/<resource>
jar:file:<path-to-onejar>!/<codebase>/<resource
FileURL
URL's are injected with a java.net.URLStreamHandler
which
knows how to tear-apart the "jar:" protocol. FileURL is the best choice for SpringFramework
applications, which use "jar:" protocol URL's in their annotation scanners.
The OneJarUrlFactory URL's rely on the global com.simontuffs.onejar.Handler
which
One-JAR adds to the java.protocol.handler.pkgs
system property on startup, so that
the URL resolving mechanisms know where to delegate the "onejar:" protocol URL requests.
You can inject your own implementation of IURLFactory
into the One-JAR ClassLoader by setting
the One-Jar-URL-Factory
property to your own implementation of IURLFactory