Skip to content

Commit

Permalink
Fixes #176 - multi resources in extraClassPath
Browse files Browse the repository at this point in the history
  • Loading branch information
skybber committed Feb 23, 2017
1 parent 5de9c4f commit 2e836de
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package org.hotswap.agent.util.classloader;

import org.hotswap.agent.logging.AgentLogger;
import sun.misc.URLClassPath;

import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.Enumeration;

import org.hotswap.agent.logging.AgentLogger;

import sun.misc.URLClassPath;

/**
* Helper methods to enhance URL ClassLoader.
Expand Down Expand Up @@ -108,6 +111,21 @@ public URL findResource(String name, boolean check) {
return super.findResource(name, check);
}

public Enumeration<URL> findResources(final String name, boolean check) {
if (watchResourceLoader != null) {
try {
Enumeration<URL> resource = watchResourceLoader.getResources(name);
if (resource != null) {
return resource;
}
} catch (IOException e) {
LOGGER.debug("Unable to load resource {}", e, name);
}
}

return super.findResources(name, check);
}

/**
* Return orig classpath as was set by hotswap agent.
* Note: cannot use classLoader.getURLs(), because Tomcat WebappClassLoader does not return modified classPath.
Expand Down

0 comments on commit 2e836de

Please sign in to comment.