|
|
|
@ -30,8 +30,6 @@ import org.springframework.beans.factory.support.RootBeanDefinition; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
import org.springframework.core.type.AnnotationMetadata; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.context.annotation.MetadataUtils.*; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Utility class that allows for convenient registration of common |
|
|
|
* Utility class that allows for convenient registration of common |
|
|
|
* {@link org.springframework.beans.factory.config.BeanPostProcessor} and |
|
|
|
* {@link org.springframework.beans.factory.config.BeanPostProcessor} and |
|
|
|
@ -85,70 +83,89 @@ public class AnnotationConfigUtils { |
|
|
|
public static final String COMMON_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
public static final String COMMON_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
"org.springframework.context.annotation.internalCommonAnnotationProcessor"; |
|
|
|
"org.springframework.context.annotation.internalCommonAnnotationProcessor"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The bean name of the internally managed JPA annotation processor. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final String PERSISTENCE_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
|
|
|
|
"org.springframework.context.annotation.internalPersistenceAnnotationProcessor"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME = |
|
|
|
|
|
|
|
"org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The bean name of the internally managed Scheduled annotation processor. |
|
|
|
* The bean name of the internally managed Scheduled annotation processor. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
public static final String SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
"org.springframework.context.annotation.internalScheduledAnnotationProcessor"; |
|
|
|
"org.springframework.context.annotation.internalScheduledAnnotationProcessor"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The bean name of the internally managed Async annotation processor. |
|
|
|
* The bean name of the internally managed Async annotation processor. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
public static final String ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
"org.springframework.context.annotation.internalAsyncAnnotationProcessor"; |
|
|
|
"org.springframework.context.annotation.internalAsyncAnnotationProcessor"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The bean name of the internally managed AspectJ async execution aspect. |
|
|
|
* The bean name of the internally managed AspectJ async execution aspect. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String ASYNC_EXECUTION_ASPECT_BEAN_NAME = |
|
|
|
public static final String ASYNC_EXECUTION_ASPECT_BEAN_NAME = |
|
|
|
"org.springframework.scheduling.config.internalAsyncExecutionAspect"; |
|
|
|
"org.springframework.scheduling.config.internalAsyncExecutionAspect"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The class name of the AspectJ async execution aspect. |
|
|
|
* The class name of the AspectJ async execution aspect. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String ASYNC_EXECUTION_ASPECT_CLASS_NAME = |
|
|
|
public static final String ASYNC_EXECUTION_ASPECT_CLASS_NAME = |
|
|
|
"org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect"; |
|
|
|
"org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The name of the AspectJ async execution aspect @{@code Configuration} class. |
|
|
|
* The name of the AspectJ async execution aspect @{@code Configuration} class. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME = |
|
|
|
public static final String ASYNC_EXECUTION_ASPECT_CONFIGURATION_CLASS_NAME = |
|
|
|
"org.springframework.scheduling.aspectj.AspectJAsyncConfiguration"; |
|
|
|
"org.springframework.scheduling.aspectj.AspectJAsyncConfiguration"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The bean name of the internally managed cache advisor. |
|
|
|
* The bean name of the internally managed cache advisor. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String CACHE_ADVISOR_BEAN_NAME = |
|
|
|
public static final String CACHE_ADVISOR_BEAN_NAME = |
|
|
|
"org.springframework.cache.config.internalCacheAdvisor"; |
|
|
|
"org.springframework.cache.config.internalCacheAdvisor"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The bean name of the internally managed cache aspect. |
|
|
|
* The bean name of the internally managed cache aspect. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String CACHE_ASPECT_BEAN_NAME = |
|
|
|
public static final String CACHE_ASPECT_BEAN_NAME = |
|
|
|
"org.springframework.cache.config.internalCacheAspect"; |
|
|
|
"org.springframework.cache.config.internalCacheAspect"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The class name of the AspectJ caching aspect. |
|
|
|
* The class name of the AspectJ caching aspect. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String CACHE_ASPECT_CLASS_NAME = |
|
|
|
public static final String CACHE_ASPECT_CLASS_NAME = |
|
|
|
"org.springframework.cache.aspectj.AnnotationCacheAspect"; |
|
|
|
"org.springframework.cache.aspectj.AnnotationCacheAspect"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The name of the AspectJ caching aspect @{@code Configuration} class. |
|
|
|
* The name of the AspectJ caching aspect @{@code Configuration} class. |
|
|
|
|
|
|
|
* <p>ATTENTION:</p> This constant is meant for internal use only. The value is stable |
|
|
|
|
|
|
|
* but don't rely on the presence of this constant declaration; rather copy the value. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static final String CACHE_ASPECT_CONFIGURATION_CLASS_NAME = |
|
|
|
public static final String CACHE_ASPECT_CONFIGURATION_CLASS_NAME = |
|
|
|
"org.springframework.cache.aspectj.AspectJCachingConfiguration"; |
|
|
|
"org.springframework.cache.aspectj.AspectJCachingConfiguration"; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The bean name of the internally managed JPA annotation processor. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static final String PERSISTENCE_ANNOTATION_PROCESSOR_BEAN_NAME = |
|
|
|
|
|
|
|
"org.springframework.context.annotation.internalPersistenceAnnotationProcessor"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME = |
|
|
|
|
|
|
|
"org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final boolean jsr250Present = |
|
|
|
private static final boolean jsr250Present = |
|
|
|
ClassUtils.isPresent("javax.annotation.Resource", AnnotationConfigUtils.class.getClassLoader()); |
|
|
|
ClassUtils.isPresent("javax.annotation.Resource", AnnotationConfigUtils.class.getClassLoader()); |
|
|
|
@ -236,14 +253,14 @@ public class AnnotationConfigUtils { |
|
|
|
abd.setPrimary(true); |
|
|
|
abd.setPrimary(true); |
|
|
|
} |
|
|
|
} |
|
|
|
if (metadata.isAnnotated(Lazy.class.getName())) { |
|
|
|
if (metadata.isAnnotated(Lazy.class.getName())) { |
|
|
|
abd.setLazyInit(attributesFor(metadata, Lazy.class).getBoolean("value")); |
|
|
|
abd.setLazyInit(MetadataUtils.attributesFor(metadata, Lazy.class).getBoolean("value")); |
|
|
|
} |
|
|
|
} |
|
|
|
if (metadata.isAnnotated(DependsOn.class.getName())) { |
|
|
|
if (metadata.isAnnotated(DependsOn.class.getName())) { |
|
|
|
abd.setDependsOn(attributesFor(metadata, DependsOn.class).getStringArray("value")); |
|
|
|
abd.setDependsOn(MetadataUtils.attributesFor(metadata, DependsOn.class).getStringArray("value")); |
|
|
|
} |
|
|
|
} |
|
|
|
if (abd instanceof AbstractBeanDefinition) { |
|
|
|
if (abd instanceof AbstractBeanDefinition) { |
|
|
|
if (metadata.isAnnotated(Role.class.getName())) { |
|
|
|
if (metadata.isAnnotated(Role.class.getName())) { |
|
|
|
Integer role = attributesFor(metadata, Role.class).getNumber("value"); |
|
|
|
Integer role = MetadataUtils.attributesFor(metadata, Role.class).getNumber("value"); |
|
|
|
((AbstractBeanDefinition)abd).setRole(role); |
|
|
|
((AbstractBeanDefinition)abd).setRole(role); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|