diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java index fdfe35e7c9f..d58e9877776 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java @@ -132,6 +132,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean ClassLoader cl = AutowiredAnnotationBeanPostProcessor.class.getClassLoader(); try { this.autowiredAnnotationTypes.add((Class) cl.loadClass("javax.inject.Inject")); + logger.info("JSR-330 'javax.inject.Inject' annotation found and supported for autowiring"); } catch (ClassNotFoundException ex) { // JSR-330 API not available - simply skip. diff --git a/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 2ae21e45431..3966d79b795 100644 --- a/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/org.springframework.beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -93,6 +93,19 @@ import org.springframework.util.StringUtils; public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFactory implements ConfigurableListableBeanFactory, BeanDefinitionRegistry, Serializable { + private static Class javaxInjectProviderClass = null; + + static { + ClassLoader cl = DefaultListableBeanFactory.class.getClassLoader(); + try { + javaxInjectProviderClass = cl.loadClass("javax.inject.Provider"); + } + catch (ClassNotFoundException ex) { + // JSR-330 API not available - Provider interface simply not supported then. + } + } + + /** Map from serialized id to factory instance */ private static final Map> serializableFactories = new ConcurrentHashMap>(); @@ -646,7 +659,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (descriptor.getDependencyType().equals(ObjectFactory.class)) { return new DependencyObjectFactory(descriptor, beanName); } - else if (descriptor.getDependencyType().getName().equals("javax.inject.Provider")) { + else if (descriptor.getDependencyType().equals(javaxInjectProviderClass)) { return new DependencyProviderFactory().createDependencyProvider(descriptor, beanName); } else { diff --git a/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java b/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java index b66889df3a2..5f2bde0ab26 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java +++ b/org.springframework.context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java @@ -140,16 +140,15 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean private static Class 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; diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java b/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java index d1d38311ab2..b1578438aa5 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationAdvisor.java @@ -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> asyncAnnotationTypes = new LinkedHashSet>(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. diff --git a/org.springframework.core/src/main/java/org/springframework/core/CollectionFactory.java b/org.springframework.core/src/main/java/org/springframework/core/CollectionFactory.java index 98105e81b35..b598947818f 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/CollectionFactory.java +++ b/org.springframework.core/src/main/java/org/springframework/core/CollectionFactory.java @@ -34,7 +34,6 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArraySet; -import org.springframework.util.ClassUtils; import org.springframework.util.LinkedCaseInsensitiveMap; /** @@ -52,13 +51,9 @@ import org.springframework.util.LinkedCaseInsensitiveMap; */ public abstract class CollectionFactory { - private static final String NAVIGABLE_SET_CLASS_NAME = "java.util.NavigableSet"; + private static Class navigableSetClass = null; - private static final String NAVIGABLE_MAP_CLASS_NAME = "java.util.NavigableMap"; - - private static Class navigableSet = null; - - private static Class navigableMap = null; + private static Class navigableMapClass = null; private static final Set approximableCollectionTypes = new HashSet(10); @@ -75,11 +70,12 @@ public abstract class CollectionFactory { approximableMapTypes.add(SortedMap.class); // New Java 6 collection interfaces + ClassLoader cl = CollectionFactory.class.getClassLoader(); try { - navigableSet = ClassUtils.forName(NAVIGABLE_SET_CLASS_NAME, CollectionFactory.class.getClassLoader()); - navigableMap = ClassUtils.forName(NAVIGABLE_MAP_CLASS_NAME, CollectionFactory.class.getClassLoader()); - approximableCollectionTypes.add(navigableSet); - approximableMapTypes.add(navigableMap); + navigableSetClass = cl.loadClass("java.util.NavigableSet"); + navigableMapClass = cl.loadClass("java.util.NavigableMap"); + approximableCollectionTypes.add(navigableSetClass); + approximableMapTypes.add(navigableMapClass); } catch (ClassNotFoundException ex) { // not running on Java 6 or above... @@ -240,7 +236,7 @@ public abstract class CollectionFactory { if (List.class.equals(collectionType)) { return new ArrayList(initialCapacity); } - else if (SortedSet.class.equals(collectionType) || collectionType.equals(navigableSet)) { + else if (SortedSet.class.equals(collectionType) || collectionType.equals(navigableSetClass)) { return new TreeSet(); } else if (Set.class.equals(collectionType) || Collection.class.equals(collectionType)) { @@ -307,7 +303,7 @@ public abstract class CollectionFactory { if (Map.class.equals(mapType)) { return new LinkedHashMap(initialCapacity); } - else if (SortedMap.class.equals(mapType) || mapType.equals(navigableMap)) { + else if (SortedMap.class.equals(mapType) || mapType.equals(navigableMapClass)) { return new TreeMap(); } else {