Locator.java

00001 
00027 package org.objectweb.jonas_lib.loader.locator;
00028 
00029 import java.util.List;
00030 import java.net.URL;
00031 import java.io.IOException;
00032 
00039 public abstract class Locator {
00040 
00048     public abstract boolean hasFile(String path);
00049 
00057     public abstract boolean hasDirectory(String path);
00058 
00066     public abstract List listContent(String path);
00067 
00079     public static Locator getLocator(URL url) throws IOException {
00080 
00081         String path = url.getPath();
00082         if (path.matches(".*\\..ar")) {
00083             // jar detected if path ends with .?ar (*.jar, *.war, *.ear)
00084             return new JarFileLocator(url);
00085         } else if (path.endsWith("/")) {
00086             // directory detected if url ends with a separator /
00087             return new DirLocator(url);
00088         } else {
00089             String err = "Unsupported URL '" + url + "' support "
00090                 + "only jar archive and directory";
00091             throw new IOException(err);
00092         }
00093     }
00094 }

Generated on Tue Feb 15 15:05:55 2005 for JOnAS by  doxygen 1.3.9.1