00001
00027 package org.objectweb.jonas_lib.loader.factory;
00028
00029 import java.net.URL;
00030 import java.io.IOException;
00031
00037 public abstract class URLFactory {
00038
00048 public abstract URL getURL(String path) throws IOException;
00049
00061 public static URLFactory getFactory(URL url) throws IOException {
00062
00063 String path = url.getPath();
00064 if (path.matches(".*\\..ar")) {
00065
00066 return new JarURLFactory(url);
00067 } else if (path.endsWith("/")) {
00068
00069 return new DirURLFactory(url);
00070 } else {
00071 String err = "Unsupported URL '" + url + "' support "
00072 + "only jar archive and directory";
00073 throw new IOException(err);
00074 }
00075 }
00076
00077 }