Show
Ignore:
Timestamp:
09/01/10 10:24:14 (21 months ago)
Author:
seelmann
Message:

Add support for live modules when using file URLs

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-0.15.x/pustefix-core/src/main/java/de/schlund/pfixxml/resources/ModuleResourceProvider.java

    r5014 r5330  
    6060        ModuleDescriptor desc = ModuleInfo.getInstance().getModuleDescriptor(module); 
    6161        if (desc != null) { 
    62             URL url = getJarURL(desc.getURL()); 
     62            URL url = desc.getURL().getProtocol().equals("jar") ? getJarURL(desc.getURL()) : getFileUrl(desc.getURL()); 
    6363            // Ensure module resources are read from classpath in production environment 
    6464            boolean checkLive = !BuildTimeProperties.getProperties().getProperty("mode").equals("prod"); 
     
    8989    } 
    9090     
     91    private static URL getFileUrl(URL url) { 
     92        if (!url.getProtocol().equals("file")) 
     93            throw new PustefixRuntimeException("Invalid protocol: " + url); 
     94        String urlStr = url.toString(); 
     95        int ind = urlStr.indexOf("META-INF"); 
     96        if (ind > -1) { 
     97            urlStr = urlStr.substring(0, ind); 
     98        } else 
     99            throw new PustefixRuntimeException("Unexpected module descriptor URL: " + url); 
     100        try { 
     101            return new URL(urlStr); 
     102        } catch (MalformedURLException x) { 
     103            throw new PustefixRuntimeException("Invalid module URL: " + urlStr); 
     104        } 
     105    } 
     106 
    91107    private static URL getJarURL(URL url) { 
    92108        if(!url.getProtocol().equals("jar")) throw new PustefixRuntimeException("Invalid protocol: "+url);