Fix generics and serialization warnings
This commit is contained in:
parent
6d84f06d8c
commit
f30b7e3125
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2010 the original author or authors.
|
* Copyright 2002-2011 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.
|
||||||
|
|
@ -115,8 +115,8 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
|
|
||||||
private ConfigurableListableBeanFactory beanFactory;
|
private ConfigurableListableBeanFactory beanFactory;
|
||||||
|
|
||||||
private final Map<Class<?>, Constructor[]> candidateConstructorsCache =
|
private final Map<Class<?>, Constructor<?>[]> candidateConstructorsCache =
|
||||||
new ConcurrentHashMap<Class<?>, Constructor[]>();
|
new ConcurrentHashMap<Class<?>, Constructor<?>[]>();
|
||||||
|
|
||||||
private final Map<Class<?>, InjectionMetadata> injectionMetadataCache =
|
private final Map<Class<?>, InjectionMetadata> injectionMetadataCache =
|
||||||
new ConcurrentHashMap<Class<?>, InjectionMetadata>();
|
new ConcurrentHashMap<Class<?>, InjectionMetadata>();
|
||||||
|
|
@ -209,7 +209,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||||
if (beanType != null) {
|
if (beanType != null) {
|
||||||
InjectionMetadata metadata = findAutowiringMetadata(beanType);
|
InjectionMetadata metadata = findAutowiringMetadata(beanType);
|
||||||
metadata.checkConfigMembers(beanDefinition);
|
metadata.checkConfigMembers(beanDefinition);
|
||||||
|
|
@ -217,17 +217,17 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
|
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
|
||||||
// Quick check on the concurrent map first, with minimal locking.
|
// Quick check on the concurrent map first, with minimal locking.
|
||||||
Constructor[] candidateConstructors = this.candidateConstructorsCache.get(beanClass);
|
Constructor<?>[] candidateConstructors = this.candidateConstructorsCache.get(beanClass);
|
||||||
if (candidateConstructors == null) {
|
if (candidateConstructors == null) {
|
||||||
synchronized (this.candidateConstructorsCache) {
|
synchronized (this.candidateConstructorsCache) {
|
||||||
candidateConstructors = this.candidateConstructorsCache.get(beanClass);
|
candidateConstructors = this.candidateConstructorsCache.get(beanClass);
|
||||||
if (candidateConstructors == null) {
|
if (candidateConstructors == null) {
|
||||||
Constructor[] rawCandidates = beanClass.getDeclaredConstructors();
|
Constructor<?>[] rawCandidates = beanClass.getDeclaredConstructors();
|
||||||
List<Constructor> candidates = new ArrayList<Constructor>(rawCandidates.length);
|
List<Constructor<?>> candidates = new ArrayList<Constructor<?>>(rawCandidates.length);
|
||||||
Constructor requiredConstructor = null;
|
Constructor<?> requiredConstructor = null;
|
||||||
Constructor defaultConstructor = null;
|
Constructor<?> defaultConstructor = null;
|
||||||
for (Constructor<?> candidate : rawCandidates) {
|
for (Constructor<?> candidate : rawCandidates) {
|
||||||
Annotation annotation = findAutowiredAnnotation(candidate);
|
Annotation annotation = findAutowiredAnnotation(candidate);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
|
|
@ -305,7 +305,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private InjectionMetadata findAutowiringMetadata(Class clazz) {
|
private InjectionMetadata findAutowiringMetadata(Class<?> clazz) {
|
||||||
// Quick check on the concurrent map first, with minimal locking.
|
// Quick check on the concurrent map first, with minimal locking.
|
||||||
InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
|
InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
|
|
@ -320,7 +320,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private InjectionMetadata buildAutowiringMetadata(Class clazz) {
|
private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
|
||||||
LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
|
LinkedList<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();
|
||||||
Class<?> targetClass = clazz;
|
Class<?> targetClass = clazz;
|
||||||
|
|
||||||
|
|
@ -534,7 +534,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
||||||
arguments = resolveCachedArguments(beanName);
|
arguments = resolveCachedArguments(beanName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Class[] paramTypes = method.getParameterTypes();
|
Class<?>[] paramTypes = method.getParameterTypes();
|
||||||
arguments = new Object[paramTypes.length];
|
arguments = new Object[paramTypes.length];
|
||||||
DependencyDescriptor[] descriptors = new DependencyDescriptor[paramTypes.length];
|
DependencyDescriptor[] descriptors = new DependencyDescriptor[paramTypes.length];
|
||||||
Set<String> autowiredBeanNames = new LinkedHashSet<String>(paramTypes.length);
|
Set<String> autowiredBeanNames = new LinkedHashSet<String>(paramTypes.length);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 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.
|
||||||
|
|
@ -71,6 +71,7 @@ import org.springframework.util.ReflectionUtils;
|
||||||
* @see #setInitAnnotationType
|
* @see #setInitAnnotationType
|
||||||
* @see #setDestroyAnnotationType
|
* @see #setDestroyAnnotationType
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class InitDestroyAnnotationBeanPostProcessor
|
public class InitDestroyAnnotationBeanPostProcessor
|
||||||
implements DestructionAwareBeanPostProcessor, MergedBeanDefinitionPostProcessor, PriorityOrdered, Serializable {
|
implements DestructionAwareBeanPostProcessor, MergedBeanDefinitionPostProcessor, PriorityOrdered, Serializable {
|
||||||
|
|
||||||
|
|
@ -117,7 +118,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||||
if (beanType != null) {
|
if (beanType != null) {
|
||||||
LifecycleMetadata metadata = findLifecycleMetadata(beanType);
|
LifecycleMetadata metadata = findLifecycleMetadata(beanType);
|
||||||
metadata.checkConfigMembers(beanDefinition);
|
metadata.checkConfigMembers(beanDefinition);
|
||||||
|
|
@ -162,7 +163,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private LifecycleMetadata findLifecycleMetadata(Class clazz) {
|
private LifecycleMetadata findLifecycleMetadata(Class<?> clazz) {
|
||||||
if (this.lifecycleMetadataCache == null) {
|
if (this.lifecycleMetadataCache == null) {
|
||||||
// Happens after deserialization, during destruction...
|
// Happens after deserialization, during destruction...
|
||||||
return buildLifecycleMetadata(clazz);
|
return buildLifecycleMetadata(clazz);
|
||||||
|
|
@ -182,7 +183,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LifecycleMetadata buildLifecycleMetadata(Class clazz) {
|
private LifecycleMetadata buildLifecycleMetadata(Class<?> clazz) {
|
||||||
final boolean debug = logger.isDebugEnabled();
|
final boolean debug = logger.isDebugEnabled();
|
||||||
LinkedList<LifecycleElement> initMethods = new LinkedList<LifecycleElement>();
|
LinkedList<LifecycleElement> initMethods = new LinkedList<LifecycleElement>();
|
||||||
LinkedList<LifecycleElement> destroyMethods = new LinkedList<LifecycleElement>();
|
LinkedList<LifecycleElement> destroyMethods = new LinkedList<LifecycleElement>();
|
||||||
|
|
@ -242,7 +243,7 @@ public class InitDestroyAnnotationBeanPostProcessor
|
||||||
|
|
||||||
private final Set<LifecycleElement> destroyMethods;
|
private final Set<LifecycleElement> destroyMethods;
|
||||||
|
|
||||||
public LifecycleMetadata(Class targetClass, Collection<LifecycleElement> initMethods,
|
public LifecycleMetadata(Class<?> targetClass, Collection<LifecycleElement> initMethods,
|
||||||
Collection<LifecycleElement> destroyMethods) {
|
Collection<LifecycleElement> destroyMethods) {
|
||||||
|
|
||||||
this.initMethods = new LinkedHashSet<LifecycleElement>();
|
this.initMethods = new LinkedHashSet<LifecycleElement>();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 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.
|
||||||
|
|
@ -129,7 +129,7 @@ public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2008 the original author or authors.
|
* Copyright 2002-2011 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.
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Constructor<?>[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
|
public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ public abstract class InstantiationAwareBeanPostProcessorAdapter implements Smar
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException {
|
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2009 the original author or authors.
|
* Copyright 2002-2011 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.
|
||||||
|
|
@ -135,6 +135,7 @@ import org.springframework.util.StringUtils;
|
||||||
* @see org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor
|
* @see org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor
|
||||||
* @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
|
* @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBeanPostProcessor
|
public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBeanPostProcessor
|
||||||
implements InstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable {
|
implements InstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable {
|
||||||
|
|
||||||
|
|
@ -145,13 +146,17 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
static {
|
static {
|
||||||
ClassLoader cl = CommonAnnotationBeanPostProcessor.class.getClassLoader();
|
ClassLoader cl = CommonAnnotationBeanPostProcessor.class.getClassLoader();
|
||||||
try {
|
try {
|
||||||
webServiceRefClass = (Class) cl.loadClass("javax.xml.ws.WebServiceRef");
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.xml.ws.WebServiceRef");
|
||||||
|
webServiceRefClass = clazz;
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
webServiceRefClass = null;
|
webServiceRefClass = null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ejbRefClass = (Class) cl.loadClass("javax.ejb.EJB");
|
@SuppressWarnings("unchecked")
|
||||||
|
Class<? extends Annotation> clazz = (Class<? extends Annotation>) cl.loadClass("javax.ejb.EJB");
|
||||||
|
ejbRefClass = clazz;
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException ex) {
|
catch (ClassNotFoundException ex) {
|
||||||
ejbRefClass = null;
|
ejbRefClass = null;
|
||||||
|
|
@ -273,7 +278,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||||
super.postProcessMergedBeanDefinition(beanDefinition, beanType, beanName);
|
super.postProcessMergedBeanDefinition(beanDefinition, beanType, beanName);
|
||||||
if (beanType != null) {
|
if (beanType != null) {
|
||||||
InjectionMetadata metadata = findResourceMetadata(beanType);
|
InjectionMetadata metadata = findResourceMetadata(beanType);
|
||||||
|
|
@ -281,7 +286,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException {
|
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -303,7 +308,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private InjectionMetadata findResourceMetadata(final Class clazz) {
|
private InjectionMetadata findResourceMetadata(final Class<?> clazz) {
|
||||||
// Quick check on the concurrent map first, with minimal locking.
|
// Quick check on the concurrent map first, with minimal locking.
|
||||||
InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
|
InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
|
|
@ -365,7 +370,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
if (Modifier.isStatic(method.getModifiers())) {
|
if (Modifier.isStatic(method.getModifiers())) {
|
||||||
throw new IllegalStateException("@Resource annotation is not supported on static methods");
|
throw new IllegalStateException("@Resource annotation is not supported on static methods");
|
||||||
}
|
}
|
||||||
Class[] paramTypes = method.getParameterTypes();
|
Class<?>[] paramTypes = method.getParameterTypes();
|
||||||
if (paramTypes.length != 1) {
|
if (paramTypes.length != 1) {
|
||||||
throw new IllegalStateException("@Resource annotation requires a single-arg method: " + method);
|
throw new IllegalStateException("@Resource annotation requires a single-arg method: " + method);
|
||||||
}
|
}
|
||||||
|
|
@ -502,6 +507,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
*/
|
*/
|
||||||
private class ResourceElement extends LookupElement {
|
private class ResourceElement extends LookupElement {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
protected boolean shareable = true;
|
protected boolean shareable = true;
|
||||||
|
|
||||||
public ResourceElement(Member member, PropertyDescriptor pd) {
|
public ResourceElement(Member member, PropertyDescriptor pd) {
|
||||||
|
|
@ -512,7 +518,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
protected void initAnnotation(AnnotatedElement ae) {
|
protected void initAnnotation(AnnotatedElement ae) {
|
||||||
Resource resource = ae.getAnnotation(Resource.class);
|
Resource resource = ae.getAnnotation(Resource.class);
|
||||||
String resourceName = resource.name();
|
String resourceName = resource.name();
|
||||||
Class resourceType = resource.type();
|
Class<?> resourceType = resource.type();
|
||||||
this.isDefaultName = !StringUtils.hasLength(resourceName);
|
this.isDefaultName = !StringUtils.hasLength(resourceName);
|
||||||
if (this.isDefaultName) {
|
if (this.isDefaultName) {
|
||||||
resourceName = this.member.getName();
|
resourceName = this.member.getName();
|
||||||
|
|
@ -549,7 +555,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
*/
|
*/
|
||||||
private class WebServiceRefElement extends LookupElement {
|
private class WebServiceRefElement extends LookupElement {
|
||||||
|
|
||||||
private Class elementType;
|
private Class<?> elementType;
|
||||||
|
|
||||||
private String wsdlLocation;
|
private String wsdlLocation;
|
||||||
|
|
||||||
|
|
@ -561,7 +567,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
protected void initAnnotation(AnnotatedElement ae) {
|
protected void initAnnotation(AnnotatedElement ae) {
|
||||||
WebServiceRef resource = ae.getAnnotation(WebServiceRef.class);
|
WebServiceRef resource = ae.getAnnotation(WebServiceRef.class);
|
||||||
String resourceName = resource.name();
|
String resourceName = resource.name();
|
||||||
Class resourceType = resource.type();
|
Class<?> resourceType = resource.type();
|
||||||
this.isDefaultName = !StringUtils.hasLength(resourceName);
|
this.isDefaultName = !StringUtils.hasLength(resourceName);
|
||||||
if (this.isDefaultName) {
|
if (this.isDefaultName) {
|
||||||
resourceName = this.member.getName();
|
resourceName = this.member.getName();
|
||||||
|
|
@ -604,7 +610,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
}
|
}
|
||||||
if (StringUtils.hasLength(this.wsdlLocation)) {
|
if (StringUtils.hasLength(this.wsdlLocation)) {
|
||||||
try {
|
try {
|
||||||
Constructor ctor = this.lookupType.getConstructor(new Class[] {URL.class, QName.class});
|
Constructor<?> ctor = this.lookupType.getConstructor(new Class[] {URL.class, QName.class});
|
||||||
WebServiceClient clientAnn = this.lookupType.getAnnotation(WebServiceClient.class);
|
WebServiceClient clientAnn = this.lookupType.getAnnotation(WebServiceClient.class);
|
||||||
if (clientAnn == null) {
|
if (clientAnn == null) {
|
||||||
throw new IllegalStateException("JAX-WS Service class [" + this.lookupType.getName() +
|
throw new IllegalStateException("JAX-WS Service class [" + this.lookupType.getName() +
|
||||||
|
|
@ -656,7 +662,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
resourceName = Introspector.decapitalize(resourceName.substring(3));
|
resourceName = Introspector.decapitalize(resourceName.substring(3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Class resourceType = resource.beanInterface();
|
Class<?> resourceType = resource.beanInterface();
|
||||||
if (resourceType != null && !Object.class.equals(resourceType)) {
|
if (resourceType != null && !Object.class.equals(resourceType)) {
|
||||||
checkResourceType(resourceType);
|
checkResourceType(resourceType);
|
||||||
}
|
}
|
||||||
|
|
@ -698,20 +704,20 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
|
||||||
*/
|
*/
|
||||||
private static class LookupDependencyDescriptor extends DependencyDescriptor {
|
private static class LookupDependencyDescriptor extends DependencyDescriptor {
|
||||||
|
|
||||||
private final Class lookupType;
|
private final Class<?> lookupType;
|
||||||
|
|
||||||
public LookupDependencyDescriptor(Field field, Class lookupType) {
|
public LookupDependencyDescriptor(Field field, Class<?> lookupType) {
|
||||||
super(field, true);
|
super(field, true);
|
||||||
this.lookupType = lookupType;
|
this.lookupType = lookupType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LookupDependencyDescriptor(Method method, Class lookupType) {
|
public LookupDependencyDescriptor(Method method, Class<?> lookupType) {
|
||||||
super(new MethodParameter(method, 0), true);
|
super(new MethodParameter(method, 0), true);
|
||||||
this.lookupType = lookupType;
|
this.lookupType = lookupType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class getDependencyType() {
|
public Class<?> getDependencyType() {
|
||||||
return this.lookupType;
|
return this.lookupType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2010 the original author or authors.
|
* Copyright 2002-2011 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.
|
||||||
|
|
@ -51,6 +51,7 @@ import org.springframework.util.ClassUtils;
|
||||||
* @see Async
|
* @see Async
|
||||||
* @see AsyncAnnotationAdvisor
|
* @see AsyncAnnotationAdvisor
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class AsyncAnnotationBeanPostProcessor extends ProxyConfig
|
public class AsyncAnnotationBeanPostProcessor extends ProxyConfig
|
||||||
implements BeanPostProcessor, BeanClassLoaderAware, InitializingBean, Ordered {
|
implements BeanPostProcessor, BeanClassLoaderAware, InitializingBean, Ordered {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ public abstract class AnnotationUtils {
|
||||||
/** The attribute name for annotations with a single element */
|
/** The attribute name for annotations with a single element */
|
||||||
static final String VALUE = "value";
|
static final String VALUE = "value";
|
||||||
|
|
||||||
private static final Map<Class, Boolean> annotatedInterfaceCache = new WeakHashMap<Class, Boolean>();
|
private static final Map<Class<?>, Boolean> annotatedInterfaceCache = new WeakHashMap<Class<?>, Boolean>();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -120,7 +120,7 @@ public abstract class AnnotationUtils {
|
||||||
return annotation;
|
return annotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <A extends Annotation> A searchOnInterfaces(Method method, Class<A> annotationType, Class[] ifcs) {
|
private static <A extends Annotation> A searchOnInterfaces(Method method, Class<A> annotationType, Class<?>[] ifcs) {
|
||||||
A annotation = null;
|
A annotation = null;
|
||||||
for (Class<?> iface : ifcs) {
|
for (Class<?> iface : ifcs) {
|
||||||
if (isInterfaceWithAnnotatedMethods(iface)) {
|
if (isInterfaceWithAnnotatedMethods(iface)) {
|
||||||
|
|
@ -302,10 +302,10 @@ public abstract class AnnotationUtils {
|
||||||
Object value = method.invoke(annotation);
|
Object value = method.invoke(annotation);
|
||||||
if (classValuesAsString) {
|
if (classValuesAsString) {
|
||||||
if (value instanceof Class) {
|
if (value instanceof Class) {
|
||||||
value = ((Class) value).getName();
|
value = ((Class<?>) value).getName();
|
||||||
}
|
}
|
||||||
else if (value instanceof Class[]) {
|
else if (value instanceof Class[]) {
|
||||||
Class[] clazzArray = (Class[]) value;
|
Class<?>[] clazzArray = (Class[]) value;
|
||||||
String[] newValue = new String[clazzArray.length];
|
String[] newValue = new String[clazzArray.length];
|
||||||
for (int i = 0; i < clazzArray.length; i++) {
|
for (int i = 0; i < clazzArray.length; i++) {
|
||||||
newValue[i] = clazzArray[i].getName();
|
newValue[i] = clazzArray[i].getName();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2010 the original author or authors.
|
* Copyright 2002-2011 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.
|
||||||
|
|
@ -27,6 +27,7 @@ import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.PersistenceContext;
|
import javax.persistence.PersistenceContext;
|
||||||
|
|
@ -159,6 +160,7 @@ import org.springframework.util.ObjectUtils;
|
||||||
* @see javax.persistence.PersistenceUnit
|
* @see javax.persistence.PersistenceUnit
|
||||||
* @see javax.persistence.PersistenceContext
|
* @see javax.persistence.PersistenceContext
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
public class PersistenceAnnotationBeanPostProcessor
|
public class PersistenceAnnotationBeanPostProcessor
|
||||||
implements InstantiationAwareBeanPostProcessor, DestructionAwareBeanPostProcessor,
|
implements InstantiationAwareBeanPostProcessor, DestructionAwareBeanPostProcessor,
|
||||||
MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware, Serializable {
|
MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware, Serializable {
|
||||||
|
|
@ -315,14 +317,14 @@ public class PersistenceAnnotationBeanPostProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class beanType, String beanName) {
|
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) {
|
||||||
if (beanType != null) {
|
if (beanType != null) {
|
||||||
InjectionMetadata metadata = findPersistenceMetadata(beanType);
|
InjectionMetadata metadata = findPersistenceMetadata(beanType);
|
||||||
metadata.checkConfigMembers(beanDefinition);
|
metadata.checkConfigMembers(beanDefinition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object postProcessBeforeInstantiation(Class beanClass, String beanName) throws BeansException {
|
public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -357,7 +359,7 @@ public class PersistenceAnnotationBeanPostProcessor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private InjectionMetadata findPersistenceMetadata(final Class clazz) {
|
private InjectionMetadata findPersistenceMetadata(final Class<?> clazz) {
|
||||||
// Quick check on the concurrent map first, with minimal locking.
|
// Quick check on the concurrent map first, with minimal locking.
|
||||||
InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
|
InjectionMetadata metadata = this.injectionMetadataCache.get(clazz);
|
||||||
if (metadata == null) {
|
if (metadata == null) {
|
||||||
|
|
@ -592,7 +594,7 @@ public class PersistenceAnnotationBeanPostProcessor
|
||||||
AnnotatedElement ae = (AnnotatedElement) member;
|
AnnotatedElement ae = (AnnotatedElement) member;
|
||||||
PersistenceContext pc = ae.getAnnotation(PersistenceContext.class);
|
PersistenceContext pc = ae.getAnnotation(PersistenceContext.class);
|
||||||
PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class);
|
PersistenceUnit pu = ae.getAnnotation(PersistenceUnit.class);
|
||||||
Class resourceType = EntityManager.class;
|
Class<?> resourceType = EntityManager.class;
|
||||||
if (pc != null) {
|
if (pc != null) {
|
||||||
if (pu != null) {
|
if (pu != null) {
|
||||||
throw new IllegalStateException("Member may only be annotated with either " +
|
throw new IllegalStateException("Member may only be annotated with either " +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue