Browse Source

Polishing

pull/28694/head
Juergen Hoeller 4 years ago
parent
commit
a439a83f34
  1. 2
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
  2. 7
      spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java
  3. 4
      spring-context/src/main/java/org/springframework/context/annotation/ComponentScanAnnotationParser.java
  4. 14
      spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java
  5. 6
      spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java
  6. 3
      spring-tx/src/main/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.java

2
spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

@ -459,7 +459,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
return metadata; return metadata;
} }
private InjectionMetadata buildAutowiringMetadata(final Class<?> clazz) { private InjectionMetadata buildAutowiringMetadata(Class<?> clazz) {
if (!AnnotationUtils.isCandidateClass(clazz, this.autowiredAnnotationTypes)) { if (!AnnotationUtils.isCandidateClass(clazz, this.autowiredAnnotationTypes)) {
return InjectionMetadata.EMPTY; return InjectionMetadata.EMPTY;
} }

7
spring-context/src/main/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 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.
@ -332,7 +332,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
} }
private InjectionMetadata findResourceMetadata(String beanName, final Class<?> clazz, @Nullable PropertyValues pvs) { private InjectionMetadata findResourceMetadata(String beanName, Class<?> clazz, @Nullable PropertyValues pvs) {
// Fall back to class name as cache key, for backwards compatibility with custom callers. // Fall back to class name as cache key, for backwards compatibility with custom callers.
String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName());
// Quick check on the concurrent map first, with minimal locking. // Quick check on the concurrent map first, with minimal locking.
@ -352,7 +352,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
return metadata; return metadata;
} }
private InjectionMetadata buildResourceMetadata(final Class<?> clazz) { private InjectionMetadata buildResourceMetadata(Class<?> clazz) {
if (!AnnotationUtils.isCandidateClass(clazz, resourceAnnotationTypes)) { if (!AnnotationUtils.isCandidateClass(clazz, resourceAnnotationTypes)) {
return InjectionMetadata.EMPTY; return InjectionMetadata.EMPTY;
} }
@ -464,6 +464,7 @@ public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBean
public void releaseTarget(Object target) { public void releaseTarget(Object target) {
} }
}; };
ProxyFactory pf = new ProxyFactory(); ProxyFactory pf = new ProxyFactory();
pf.setTargetSource(ts); pf.setTargetSource(ts);
if (element.lookupType.isInterface()) { if (element.lookupType.isInterface()) {

4
spring-context/src/main/java/org/springframework/context/annotation/ComponentScanAnnotationParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 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.
@ -73,7 +73,7 @@ class ComponentScanAnnotationParser {
} }
public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, final String declaringClass) { public Set<BeanDefinitionHolder> parse(AnnotationAttributes componentScan, String declaringClass) {
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(this.registry, ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(this.registry,
componentScan.getBoolean("useDefaultFilters"), this.environment, this.resourceLoader); componentScan.getBoolean("useDefaultFilters"), this.environment, this.resourceLoader);

14
spring-context/src/main/java/org/springframework/context/annotation/ConfigurationClassEnhancer.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2018 the original author or authors. * Copyright 2002-2021 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.
@ -453,8 +453,8 @@ class ConfigurationClassEnhancer {
* instance directly. If a FactoryBean instance is fetched through the container via &-dereferencing, * instance directly. If a FactoryBean instance is fetched through the container via &-dereferencing,
* it will not be proxied. This too is aligned with the way XML configuration works. * it will not be proxied. This too is aligned with the way XML configuration works.
*/ */
private Object enhanceFactoryBean(final Object factoryBean, Class<?> exposedType, private Object enhanceFactoryBean(Object factoryBean, Class<?> exposedType,
final ConfigurableBeanFactory beanFactory, final String beanName) { ConfigurableBeanFactory beanFactory, String beanName) {
try { try {
Class<?> clazz = factoryBean.getClass(); Class<?> clazz = factoryBean.getClass();
@ -489,8 +489,8 @@ class ConfigurationClassEnhancer {
return createCglibProxyForFactoryBean(factoryBean, beanFactory, beanName); return createCglibProxyForFactoryBean(factoryBean, beanFactory, beanName);
} }
private Object createInterfaceProxyForFactoryBean(final Object factoryBean, Class<?> interfaceType, private Object createInterfaceProxyForFactoryBean(Object factoryBean, Class<?> interfaceType,
final ConfigurableBeanFactory beanFactory, final String beanName) { ConfigurableBeanFactory beanFactory, String beanName) {
return Proxy.newProxyInstance( return Proxy.newProxyInstance(
factoryBean.getClass().getClassLoader(), new Class<?>[] {interfaceType}, factoryBean.getClass().getClassLoader(), new Class<?>[] {interfaceType},
@ -502,8 +502,8 @@ class ConfigurationClassEnhancer {
}); });
} }
private Object createCglibProxyForFactoryBean(final Object factoryBean, private Object createCglibProxyForFactoryBean(Object factoryBean,
final ConfigurableBeanFactory beanFactory, final String beanName) { ConfigurableBeanFactory beanFactory, String beanName) {
Enhancer enhancer = new Enhancer(); Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(factoryBean.getClass()); enhancer.setSuperclass(factoryBean.getClass());

6
spring-orm/src/main/java/org/springframework/orm/jpa/support/PersistenceAnnotationBeanPostProcessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2020 the original author or authors. * Copyright 2002-2021 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.
@ -393,7 +393,7 @@ public class PersistenceAnnotationBeanPostProcessor
} }
private InjectionMetadata findPersistenceMetadata(String beanName, final Class<?> clazz, @Nullable PropertyValues pvs) { private InjectionMetadata findPersistenceMetadata(String beanName, Class<?> clazz, @Nullable PropertyValues pvs) {
// Fall back to class name as cache key, for backwards compatibility with custom callers. // Fall back to class name as cache key, for backwards compatibility with custom callers.
String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName());
// Quick check on the concurrent map first, with minimal locking. // Quick check on the concurrent map first, with minimal locking.
@ -413,7 +413,7 @@ public class PersistenceAnnotationBeanPostProcessor
return metadata; return metadata;
} }
private InjectionMetadata buildPersistenceMetadata(final Class<?> clazz) { private InjectionMetadata buildPersistenceMetadata(Class<?> clazz) {
if (!AnnotationUtils.isCandidateClass(clazz, Arrays.asList(PersistenceContext.class, PersistenceUnit.class))) { if (!AnnotationUtils.isCandidateClass(clazz, Arrays.asList(PersistenceContext.class, PersistenceUnit.class))) {
return InjectionMetadata.EMPTY; return InjectionMetadata.EMPTY;
} }

3
spring-tx/src/main/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2021 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.
@ -38,7 +38,6 @@ import org.springframework.util.Assert;
* PersistenceExceptionTranslator} interface, which are subsequently asked to translate * PersistenceExceptionTranslator} interface, which are subsequently asked to translate
* candidate exceptions. * candidate exceptions.
* *
* <p>All of Spring's applicable resource factories (e.g. * <p>All of Spring's applicable resource factories (e.g.
* {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean}) * {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean})
* implement the {@code PersistenceExceptionTranslator} interface out of the box. * implement the {@code PersistenceExceptionTranslator} interface out of the box.

Loading…
Cancel
Save