Commit b775e465083508d5beb0f1ac35bc0d32e4e50933
1 parent
5a14f56b
Exists in
master
Ajuste no classloader para forName
Showing
2 changed files
with
13 additions
and
10 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractStrategyBootstrap.java
... | ... | @@ -99,7 +99,7 @@ public abstract class AbstractStrategyBootstrap<T, D extends T> extends Abstract |
99 | 99 | Configuration config = new PropertiesConfiguration(url); |
100 | 100 | canonicalName = config.getString(getConfigKey(), getDefaultClass().getCanonicalName()); |
101 | 101 | |
102 | - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
102 | + ClassLoader classLoader = ConfigurationLoader.getClassLoaderForResource(canonicalName); | |
103 | 103 | result = (Class<T>) Class.forName(canonicalName, false, classLoader); |
104 | 104 | result.asSubclass(getType()); |
105 | 105 | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
... | ... | @@ -307,20 +307,18 @@ public class ConfigurationLoader implements Serializable { |
307 | 307 | return value; |
308 | 308 | } |
309 | 309 | |
310 | - public static URL getResourceAsURL(final String resource) throws FileNotFoundException { | |
310 | + public static ClassLoader getClassLoaderForResource(final String resource) throws FileNotFoundException { | |
311 | 311 | final String stripped = resource.startsWith("/") ? resource.substring(1) : resource; |
312 | 312 | |
313 | 313 | URL url = null; |
314 | - final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | |
315 | - | |
316 | - if (classLoader != null) { | |
317 | - url = classLoader.getResource(stripped); | |
318 | - } | |
314 | + ClassLoader result = Thread.currentThread().getContextClassLoader(); | |
319 | 315 | |
320 | - if (url == null) { | |
321 | - url = ConfigurationLoader.class.getResource(stripped); | |
316 | + if (result != null) { | |
317 | + url = result.getResource(stripped); | |
322 | 318 | } |
319 | + | |
323 | 320 | if (url == null) { |
321 | + result = ConfigurationLoader.class.getClassLoader(); | |
324 | 322 | url = ConfigurationLoader.class.getClassLoader().getResource(stripped); |
325 | 323 | } |
326 | 324 | |
... | ... | @@ -328,6 +326,11 @@ public class ConfigurationLoader implements Serializable { |
328 | 326 | throw new FileNotFoundException(resource + " not found."); |
329 | 327 | } |
330 | 328 | |
331 | - return url; | |
329 | + return result; | |
330 | + } | |
331 | + | |
332 | + public static URL getResourceAsURL(final String resource) throws FileNotFoundException { | |
333 | + ClassLoader classLoader = getClassLoaderForResource(resource); | |
334 | + return classLoader.getResource(resource); | |
332 | 335 | } |
333 | 336 | } | ... | ... |