consistent loading of optional classes

This commit is contained in:
Juergen Hoeller
2009-09-18 14:01:39 +00:00
parent 8d66c90760
commit 7b42a12161
5 changed files with 29 additions and 21 deletions

View File

@@ -140,16 +140,15 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
private static Class<? extends Annotation> ejbRefClass = null;
static {
ClassLoader cl = CommonAnnotationBeanPostProcessor.class.getClassLoader();
try {
webServiceRefClass = ClassUtils.forName("javax.xml.ws.WebServiceRef",
CommonAnnotationBeanPostProcessor.class.getClassLoader());
webServiceRefClass = (Class) cl.loadClass("javax.xml.ws.WebServiceRef");
}
catch (ClassNotFoundException ex) {
webServiceRefClass = null;
}
try {
ejbRefClass = ClassUtils.forName("javax.ejb.EJB",
CommonAnnotationBeanPostProcessor.class.getClassLoader());
ejbRefClass = (Class) cl.loadClass("javax.ejb.EJB");
}
catch (ClassNotFoundException ex) {
ejbRefClass = null;

View File

@@ -32,7 +32,6 @@ import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* Advisor that activates asynchronous method execution through the {@link Async}
@@ -73,9 +72,9 @@ public class AsyncAnnotationAdvisor extends AbstractPointcutAdvisor {
public AsyncAnnotationAdvisor(Executor executor) {
Set<Class<? extends Annotation>> asyncAnnotationTypes = new LinkedHashSet<Class<? extends Annotation>>(2);
asyncAnnotationTypes.add(Async.class);
ClassLoader cl = AsyncAnnotationAdvisor.class.getClassLoader();
try {
asyncAnnotationTypes.add(ClassUtils.forName(
"javax.ejb.Asynchronous", AsyncAnnotationAdvisor.class.getClassLoader()));
asyncAnnotationTypes.add((Class) cl.loadClass("javax.ejb.Asynchronous"));
}
catch (ClassNotFoundException ex) {
// If EJB 3.1 API not present, simply ignore.