Polishing (along with SPR-10992)
This commit is contained in:
parent
044d68b336
commit
494cc22bcd
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2013 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.
|
||||||
|
@ -54,7 +54,7 @@ public abstract class ScopedProxyUtils {
|
||||||
// Create a scoped proxy definition for the original bean name,
|
// Create a scoped proxy definition for the original bean name,
|
||||||
// "hiding" the target bean in an internal target definition.
|
// "hiding" the target bean in an internal target definition.
|
||||||
RootBeanDefinition proxyDefinition = new RootBeanDefinition(ScopedProxyFactoryBean.class);
|
RootBeanDefinition proxyDefinition = new RootBeanDefinition(ScopedProxyFactoryBean.class);
|
||||||
proxyDefinition.setOriginatingBeanDefinition(definition.getBeanDefinition());
|
proxyDefinition.setOriginatingBeanDefinition(targetDefinition);
|
||||||
proxyDefinition.setSource(definition.getSource());
|
proxyDefinition.setSource(definition.getSource());
|
||||||
proxyDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
proxyDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,6 @@ final class ConfigurationClass {
|
||||||
return this.importedResources;
|
return this.importedResources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void validate(ProblemReporter problemReporter) {
|
public void validate(ProblemReporter problemReporter) {
|
||||||
// A configuration class may not be final (CGLIB limitation)
|
// A configuration class may not be final (CGLIB limitation)
|
||||||
if (getMetadata().isAnnotated(Configuration.class.getName())) {
|
if (getMetadata().isAnnotated(Configuration.class.getName())) {
|
||||||
|
@ -196,7 +195,6 @@ final class ConfigurationClass {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return (this == other || (other instanceof ConfigurationClass &&
|
return (this == other || (other instanceof ConfigurationClass &&
|
||||||
|
@ -210,7 +208,7 @@ final class ConfigurationClass {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("[ConfigurationClass:beanName=%s,resource=%s]", this.beanName, this.resource);
|
return "ConfigurationClass:beanName=" + this.beanName + ",resource=" + this.resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2012 the original author or authors.
|
* Copyright 2002-2013 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,7 +27,6 @@ import java.util.Stack;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
|
||||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||||
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||||
import org.springframework.beans.factory.BeanFactory;
|
import org.springframework.beans.factory.BeanFactory;
|
||||||
|
@ -85,7 +84,7 @@ import static org.springframework.context.annotation.AnnotationConfigUtils.*;
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor,
|
public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor,
|
||||||
ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware, Ordered {
|
Ordered, ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware {
|
||||||
|
|
||||||
private static final String IMPORT_AWARE_PROCESSOR_BEAN_NAME =
|
private static final String IMPORT_AWARE_PROCESSOR_BEAN_NAME =
|
||||||
ConfigurationClassPostProcessor.class.getName() + ".importAwareProcessor";
|
ConfigurationClassPostProcessor.class.getName() + ".importAwareProcessor";
|
||||||
|
@ -130,6 +129,10 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public int getOrder() {
|
||||||
|
return Ordered.HIGHEST_PRECEDENCE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the {@link SourceExtractor} to use for generated bean definitions
|
* Set the {@link SourceExtractor} to use for generated bean definitions
|
||||||
* that correspond to {@link Bean} factory methods.
|
* that correspond to {@link Bean} factory methods.
|
||||||
|
@ -368,21 +371,21 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
|
private static class ImportAwareBeanPostProcessor implements BeanPostProcessor, PriorityOrdered, BeanFactoryAware {
|
||||||
|
|
||||||
|
private BeanFactory beanFactory;
|
||||||
|
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
return Ordered.HIGHEST_PRECEDENCE;
|
return Ordered.HIGHEST_PRECEDENCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
private static class ImportAwareBeanPostProcessor implements PriorityOrdered, BeanFactoryAware, BeanPostProcessor {
|
public void setBeanFactory(BeanFactory beanFactory) {
|
||||||
|
|
||||||
private BeanFactory beanFactory;
|
|
||||||
|
|
||||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
public Object postProcessBeforeInitialization(Object bean, String beanName) {
|
||||||
if (bean instanceof ImportAware) {
|
if (bean instanceof ImportAware) {
|
||||||
ImportRegistry importRegistry = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
|
ImportRegistry importRegistry = this.beanFactory.getBean(IMPORT_REGISTRY_BEAN_NAME, ImportRegistry.class);
|
||||||
String importingClass = importRegistry.getImportingClassFor(bean.getClass().getSuperclass().getName());
|
String importingClass = importRegistry.getImportingClassFor(bean.getClass().getSuperclass().getName());
|
||||||
|
@ -404,13 +407,9 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
public Object postProcessAfterInitialization(Object bean, String beanName) {
|
||||||
return bean;
|
return bean;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOrder() {
|
|
||||||
return Ordered.HIGHEST_PRECEDENCE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue