Changeset 26255

Show
Ignore:
Timestamp:
26.09.2012 12:45:43 (7 years ago)
Author:
sjm84
Message:

Reformatting this file AND changing the way a URL is retrieved from a file so that it works on windows

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/CollectionClassLoader.java

    r26197 r26255  
    2020 
    2121import java.net.URL; 
     22import java.util.Enumeration; 
    2223import java.io.File; 
     24import java.io.IOException; 
    2325 
    24 /** Looks for classes/resources in the collection resources directory  
     26/** 
     27 * Looks for classes/resources in the collection resources directory 
    2528 */ 
    26 public class CollectionClassLoader 
    27     extends ClassLoader { 
     29public class CollectionClassLoader extends ClassLoader 
     30{ 
    2831 
    29     String base_dir = null; 
    30     public CollectionClassLoader(ClassLoader parent, String site_home, String collection_name) { 
    31     super(parent); 
    32     // 'resources directory' in the collection 
    33     this.base_dir = GSFile.collectionResourceDir(site_home, collection_name); 
    34     }  
     32    String base_dir = null; 
    3533 
    36     public URL findResource(String name) { 
    37     File resource_path = new File(this.base_dir, name); 
    38     try { 
    39         if (resource_path.exists()) { 
    40         return new URL("file://"+resource_path.getAbsolutePath()); 
    41         } 
    42     } catch (Exception e) {}; 
     34    public CollectionClassLoader(ClassLoader parent, String site_home, String collection_name) 
     35    { 
     36        super(parent); 
     37        // 'resources directory' in the collection 
     38        this.base_dir = GSFile.collectionResourceDir(site_home, collection_name); 
     39    } 
    4340 
    44     return super.findResource(name); 
    45     } 
     41    public URL findResource(String name) 
     42    { 
     43        File resource_path = new File(this.base_dir, name); 
     44        try 
     45        { 
     46            if (resource_path.exists()) 
     47            { 
     48                return resource_path.toURI().toURL(); 
     49            } 
     50        } 
     51        catch (Exception e) 
     52        { 
     53        } 
     54 
     55        return super.findResource(name); 
     56    } 
    4657}