Consolidating types and reducing visibility wherever possible. Non-internal public API is now at 18 types (21 including internal packages).

This commit is contained in:
Chris Beams 2009-02-28 03:43:35 +00:00
parent 6deb1acab4
commit c593f06397
12 changed files with 32 additions and 143 deletions

View File

@ -0,0 +1,3 @@
#Fri Feb 27 19:22:36 PST 2009
eclipse.preferences.version=1
org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false

View File

@ -8,6 +8,7 @@
<enableImports><![CDATA[false]]></enableImports> <enableImports><![CDATA[false]]></enableImports>
<configs> <configs>
<config>src/test/java/test/basic/AutowiredConfigurationTests.xml</config> <config>src/test/java/test/basic/AutowiredConfigurationTests.xml</config>
<config>src/test/java/test/basic/ValueInjectionTests.xml</config>
</configs> </configs>
<configSets> <configSets>
</configSets> </configSets>

View File

@ -1,74 +0,0 @@
/*
* 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);
}
}

View File

@ -28,7 +28,7 @@ import org.springframework.config.java.Util;
/** /**
* Various utility methods commonly used when interacting with ASM. * Various utility methods commonly used when interacting with ASM.
*/ */
public class AsmUtils { class AsmUtils {
public static final EmptyVisitor EMPTY_VISITOR = new EmptyVisitor(); public static final EmptyVisitor EMPTY_VISITOR = new EmptyVisitor();

View File

@ -36,7 +36,7 @@ import org.springframework.core.io.ClassPathResource;
* that model. * that model.
* *
* @see org.springframework.config.java.ConfigurationModel * @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 * @author Chris Beams
*/ */

View File

@ -20,8 +20,7 @@ import java.lang.reflect.Proxy;
/** TODO: JAVADOC */ /** TODO: JAVADOC */
// TODO: SJC-242 made this public, revisit class MutableAnnotationUtils {
public class MutableAnnotationUtils {
/** /**
* Creates a {@link MutableAnnotation} for {@code annoType}. * Creates a {@link MutableAnnotation} for {@code annoType}.

View File

@ -1,50 +0,0 @@
/*
* 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;
}
}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.config.java.internal.factory.support; package org.springframework.config.java.support;
import static java.lang.String.*; import static java.lang.String.*;
@ -55,8 +55,7 @@ import org.springframework.util.Assert;
* *
* @author Chris Beams * @author Chris Beams
*/ */
// TODO: Unit test class ConfigurationModelBeanDefinitionReader {
public class ConfigurationModelBeanDefinitionReader {
private static final Log log = LogFactory.getLog(ConfigurationModelBeanDefinitionReader.class); private static final Log log = LogFactory.getLog(ConfigurationModelBeanDefinitionReader.class);

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.springframework.config.java.internal.process; package org.springframework.config.java.support;
import static org.springframework.config.java.Util.*; 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.MalformedJavaConfigurationException;
import org.springframework.config.java.UsageError; import org.springframework.config.java.UsageError;
import org.springframework.config.java.internal.enhancement.ConfigurationEnhancer; 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.internal.parsing.ConfigurationParser;
import org.springframework.config.java.process.ConfigurationPostProcessor; import org.springframework.core.Ordered;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.util.ClassUtils; 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 * 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 * Note: the classloading used within should not be problematic or interfere with tooling in any
* way. BeanFactoryPostProcessing happens only during actual runtime processing via * way. BeanFactoryPostProcessing happens only during actual runtime processing via
* {@link JavaConfigApplicationContext} or via XML using {@link ConfigurationPostProcessor}. In * {@link JavaConfigApplicationContext} or via XML using {@link ConfigurationPostProcessor}. In
* any case, tooling (Spring IDE) will use {@link ConfigurationClassBeanDefinitionReader}directly, * any case, tooling (Spring IDE) will hook in at a lower level than this class and
* thus never encountering this classloading. Should this become problematic, it would not be * 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 * 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 * order to find whether the class is directly or indirectly annotated with
* {@link Configuration}. * {@link Configuration}.

View File

@ -7,7 +7,7 @@
<context:annotation-config/> <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$AutowiredConfig"/>
<bean class="test.basic.AutowiredConfigurationTests$ColorConfig"/> <bean class="test.basic.AutowiredConfigurationTests$ColorConfig"/>

View File

@ -11,7 +11,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.config.java.Configuration; import org.springframework.config.java.Configuration;
import org.springframework.config.java.ext.Bean; 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 org.springframework.config.java.util.DefaultScopes;
import test.beans.ITestBean; import test.beans.ITestBean;

View File

@ -7,7 +7,7 @@
<context:annotation-config/> <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"/> <bean class="test.basic.AutowiredConfigurationTests$ValueConfig"/>
</beans> </beans>