提交 c593f063 编写于 作者: C Chris Beams

Consolidating types and reducing visibility wherever possible. Non-internal...

Consolidating types and reducing visibility wherever possible. Non-internal public API is now at 18 types (21 including internal packages).
上级 6deb1aca
#Fri Feb 27 19:22:36 PST 2009
eclipse.preferences.version=1
org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false
......@@ -8,6 +8,7 @@
<enableImports><![CDATA[false]]></enableImports>
<configs>
<config>src/test/java/test/basic/AutowiredConfigurationTests.xml</config>
<config>src/test/java/test/basic/ValueInjectionTests.xml</config>
</configs>
<configSets>
</configSets>
......
/*
* Copyright 2002-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.factory.support;
import java.util.ArrayList;
import java.util.Map;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ConfigurationModel;
import org.springframework.config.java.MalformedJavaConfigurationException;
import org.springframework.config.java.UsageError;
import org.springframework.config.java.internal.parsing.ConfigurationParser;
import org.springframework.core.io.ClassPathResource;
/**
* Uses ASM to parse {@link Configuration @Configuration} classes. Fashioned after the
* {@link BeanDefinitionReader} hierarchy, but does not extend or implement any of its
* types because differences were significant enough to merit the departure.
*
* @see AsmConfigurationParser
*
* @author Chris Beams
*/
public class ConfigurationClassBeanDefinitionReader {
private final ConfigurationModelBeanDefinitionReader modelBeanDefinitionReader;
/**
* Creates a new {@link ConfigurationClassBeanDefinitionReader}.
*
* @param beanFactory {@link DefaultListableBeanFactory} into which new bean definitions will be
* registered as they are read from Configuration classes.
*/
public ConfigurationClassBeanDefinitionReader(DefaultListableBeanFactory beanFactory) {
this.modelBeanDefinitionReader = new ConfigurationModelBeanDefinitionReader(beanFactory);
}
/**
* Parses each {@link Configuration} class specified by <var>configClassResources</var> and registers
* individual bean definitions from those Configuration classes into the BeanDefinitionRegistry
* supplied during construction.
*/
public int loadBeanDefinitions(ConfigurationModel model, Map<String, ClassPathResource> configClassResources) throws BeanDefinitionStoreException {
ConfigurationParser parser = new ConfigurationParser(model);
for (String id : configClassResources.keySet())
parser.parse(configClassResources.get(id), id);
ArrayList<UsageError> errors = new ArrayList<UsageError>();
model.validate(errors);
if (errors.size() > 0)
throw new MalformedJavaConfigurationException(errors.toArray(new UsageError[] { }));
return modelBeanDefinitionReader.loadBeanDefinitions(model);
}
}
......@@ -28,7 +28,7 @@ import org.springframework.config.java.Util;
/**
* Various utility methods commonly used when interacting with ASM.
*/
public class AsmUtils {
class AsmUtils {
public static final EmptyVisitor EMPTY_VISITOR = new EmptyVisitor();
......
......@@ -36,7 +36,7 @@ import org.springframework.core.io.ClassPathResource;
* that model.
*
* @see org.springframework.config.java.ConfigurationModel
* @see org.springframework.config.java.internal.factory.support.ConfigurationModelBeanDefinitionReader
* @see org.springframework.config.java.support.ConfigurationModelBeanDefinitionReader
*
* @author Chris Beams
*/
......
......@@ -20,8 +20,7 @@ import java.lang.reflect.Proxy;
/** TODO: JAVADOC */
// TODO: SJC-242 made this public, revisit
public class MutableAnnotationUtils {
class MutableAnnotationUtils {
/**
* Creates a {@link MutableAnnotation} for {@code annoType}.
......
/*
* Copyright 2002-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.process;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.internal.process.InternalConfigurationPostProcessor;
import org.springframework.core.Ordered;
/**
* {@link BeanFactoryPostProcessor} used for bootstrapping {@link Configuration @Configuration}
* beans from Spring XML files.
*/
// TODO: This class now just delegates to InternalConfigurationPostProcessor. Eliminate?
public class ConfigurationPostProcessor implements Ordered, BeanFactoryPostProcessor {
/**
* Iterates through <var>beanFactory</var>, detecting and processing any {@link Configuration}
* bean definitions.
*/
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
new InternalConfigurationPostProcessor().postProcessBeanFactory(beanFactory);
}
/**
* Returns the order in which this {@link BeanPostProcessor} will be executed.
* Returns {@link Ordered#HIGHEST_PRECEDENCE}.
*/
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.factory.support;
package org.springframework.config.java.support;
import static java.lang.String.*;
......@@ -55,8 +55,7 @@ import org.springframework.util.Assert;
*
* @author Chris Beams
*/
// TODO: Unit test
public class ConfigurationModelBeanDefinitionReader {
class ConfigurationModelBeanDefinitionReader {
private static final Log log = LogFactory.getLog(ConfigurationModelBeanDefinitionReader.class);
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.config.java.internal.process;
package org.springframework.config.java.support;
import static org.springframework.config.java.Util.*;
......@@ -33,18 +33,29 @@ import org.springframework.config.java.ConfigurationModel;
import org.springframework.config.java.MalformedJavaConfigurationException;
import org.springframework.config.java.UsageError;
import org.springframework.config.java.internal.enhancement.ConfigurationEnhancer;
import org.springframework.config.java.internal.factory.support.ConfigurationClassBeanDefinitionReader;
import org.springframework.config.java.internal.factory.support.ConfigurationModelBeanDefinitionReader;
import org.springframework.config.java.internal.parsing.ConfigurationParser;
import org.springframework.config.java.process.ConfigurationPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ClassUtils;
/** TODO: JAVADOC */
public class InternalConfigurationPostProcessor implements BeanFactoryPostProcessor {
/**
* {@link BeanFactoryPostProcessor} used for bootstrapping {@link Configuration @Configuration}
* beans from Spring XML files.
*/
public class ConfigurationPostProcessor implements Ordered, BeanFactoryPostProcessor {
private static final Log logger = LogFactory.getLog(ConfigurationPostProcessor.class);
/**
* Returns the order in which this {@link BeanPostProcessor} will be executed.
* Returns {@link Ordered#HIGHEST_PRECEDENCE}.
*/
public int getOrder() {
return Ordered.HIGHEST_PRECEDENCE;
}
private static final Log logger = LogFactory.getLog(InternalConfigurationPostProcessor.class);
/**
* Searches <var>beanFactory</var> for any {@link Configuration} classes in order
......@@ -141,8 +152,8 @@ public class InternalConfigurationPostProcessor implements BeanFactoryPostProces
* Note: the classloading used within should not be problematic or interfere with tooling in any
* way. BeanFactoryPostProcessing happens only during actual runtime processing via
* {@link JavaConfigApplicationContext} or via XML using {@link ConfigurationPostProcessor}. In
* any case, tooling (Spring IDE) will use {@link ConfigurationClassBeanDefinitionReader}directly,
* thus never encountering this classloading. Should this become problematic, it would not be
* any case, tooling (Spring IDE) will hook in at a lower level than this class and
* thus never encounter this classloading. Should this become problematic, it would not be
* too difficult to replace the following with ASM logic that traverses the class hierarchy in
* order to find whether the class is directly or indirectly annotated with
* {@link Configuration}.
......
......@@ -7,7 +7,7 @@
<context:annotation-config/>
<bean class="org.springframework.config.java.process.ConfigurationPostProcessor"/>
<bean class="org.springframework.config.java.support.ConfigurationPostProcessor"/>
<bean class="test.basic.AutowiredConfigurationTests$AutowiredConfig"/>
<bean class="test.basic.AutowiredConfigurationTests$ColorConfig"/>
......
......@@ -11,7 +11,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.config.java.Configuration;
import org.springframework.config.java.ext.Bean;
import org.springframework.config.java.process.ConfigurationPostProcessor;
import org.springframework.config.java.support.ConfigurationPostProcessor;
import org.springframework.config.java.util.DefaultScopes;
import test.beans.ITestBean;
......
......@@ -7,7 +7,7 @@
<context:annotation-config/>
<bean class="org.springframework.config.java.process.ConfigurationPostProcessor"/>
<bean class="org.springframework.config.java.support.ConfigurationPostProcessor"/>
<bean class="test.basic.AutowiredConfigurationTests$ValueConfig"/>
</beans>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册