Revision 1228 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/MutableURLClassLoader.java

View differences:

MutableURLClassLoader.java
16 16

  
17 17

  
18 18
public class MutableURLClassLoader extends URLClassLoader {
19
    protected static final Logger logger = LoggerFactory.getLogger(MutableURLClassLoader.class);
19
    protected static final Logger LOGGER = LoggerFactory.getLogger(MutableURLClassLoader.class);
20 20
    
21 21
    public MutableURLClassLoader(List<URL> urls, ClassLoader parent) {
22 22
        super(urls.toArray(new URL[urls.size()]),parent);
......
56 56

  
57 57
        URL x = super.getResource(name); 
58 58
        if( needRecompile(name, x) ) {
59
            logger.trace("getResoure("+name+") -> null (need recompile).");
59
            LOGGER.trace("getResoure("+name+") -> null (need recompile).");
60 60
            return null;
61 61
        }
62
        logger.trace("getResoure("+name+") -> "+x);
62
        LOGGER.trace("getResoure("+name+") -> "+x);
63 63
        return x;
64 64
    }
65 65

  
......
67 67
    public InputStream getResourceAsStream(String name) {
68 68
        URL url = super.getResource(name); 
69 69
        if( needRecompile(name, url) ) {
70
            logger.trace("getResourceAsStream("+name+") -> null (need recompile).");
70
            LOGGER.trace("getResourceAsStream("+name+") -> null (need recompile).");
71 71
            return null;
72 72
        }
73 73
        InputStream x = super.getResourceAsStream(name); 
74
        logger.trace("getResourceAsStream("+name+") -> "+(x==null? "null":"(stream)"));
74
        LOGGER.trace("getResourceAsStream("+name+") -> "+(x==null? "null":"(stream)"));
75 75
        return x;
76 76
    }
77 77

  
78 78
    @Override
79 79
    public Enumeration<URL> getResources(String name) throws IOException {
80 80
        Enumeration<URL> urls = super.getResources(name); 
81
        logger.info("getResources("+name+") -> "+(urls==null? "null":urls));
81
        LOGGER.info("getResources("+name+") -> "+(urls==null? "null":urls));
82 82
        return urls;
83 83
    }
84 84
    
......
93 93
        File f = org.apache.commons.io.FileUtils.toFile(url);
94 94
        return f.getAbsolutePath();
95 95
    }    
96
    
97
    public List<String> path(List<String>basepath) {
98
      List<String> path = new ArrayList<>();
99
      if( basepath!=null ) {
100
        for (String folder : basepath) {
101
          if( folder==null || folder.startsWith("__") || path.contains(folder) ) {
102
            continue;
103
          }
104
          path.add(folder);
105
        }
106
      }
107
      URL[] urls = this.getURLs();
108
      for (URL url : urls) {
109
        if( url==null || !StringUtils.equalsIgnoreCase(url.getProtocol(),"file") ) {
110
          continue;
111
        }
112
        String folder = url.getPath();
113
        if( folder==null || folder.isEmpty() || path.contains(folder) ) {
114
          continue;
115
        }
116
        path.add(folder);
117
      }
118
      return path;
119
    }
96 120
}

Also available in: Unified diff