Quartz ResourceLoaderClassLoadHelper explicitly falls back to classpath lookup
Issue: SPR-13706
This commit is contained in:
parent
6573e9142c
commit
6db6f23a04
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
package org.springframework.scheduling.quartz;
|
package org.springframework.scheduling.quartz;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -73,43 +72,50 @@ public class ResourceLoaderClassLoadHelper implements ClassLoadHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("rawtypes")
|
public Class<?> loadClass(String name) throws ClassNotFoundException {
|
||||||
public Class loadClass(String name) throws ClassNotFoundException {
|
|
||||||
return this.resourceLoader.getClassLoader().loadClass(name);
|
return this.resourceLoader.getClassLoader().loadClass(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> Class<? extends T> loadClass(String name, Class<T> clazz) throws ClassNotFoundException {
|
public <T> Class<? extends T> loadClass(String name, Class<T> clazz) throws ClassNotFoundException {
|
||||||
return loadClass(name);
|
return (Class<? extends T>) loadClass(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getResource(String name) {
|
public URL getResource(String name) {
|
||||||
Resource resource = this.resourceLoader.getResource(name);
|
Resource resource = this.resourceLoader.getResource(name);
|
||||||
|
if (resource.exists()) {
|
||||||
try {
|
try {
|
||||||
return resource.getURL();
|
return resource.getURL();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException ex) {
|
catch (IOException ex) {
|
||||||
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Could not load " + resource);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
}
|
||||||
logger.warn("Could not load " + resource);
|
else {
|
||||||
return null;
|
return getClassLoader().getResource(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getResourceAsStream(String name) {
|
public InputStream getResourceAsStream(String name) {
|
||||||
Resource resource = this.resourceLoader.getResource(name);
|
Resource resource = this.resourceLoader.getResource(name);
|
||||||
|
if (resource.exists()) {
|
||||||
try {
|
try {
|
||||||
return resource.getInputStream();
|
return resource.getInputStream();
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException ex) {
|
catch (IOException ex) {
|
||||||
|
if (logger.isWarnEnabled()) {
|
||||||
|
logger.warn("Could not load " + resource);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
}
|
||||||
logger.warn("Could not load " + resource);
|
else {
|
||||||
return null;
|
return getClassLoader().getResourceAsStream(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue