Chris Beams
16 years ago
12 changed files with 32 additions and 143 deletions
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
#Fri Feb 27 19:22:36 PST 2009 |
||||
eclipse.preferences.version=1 |
||||
org.springframework.ide.eclipse.beans.core.ignoreMissingNamespaceHandler=false |
@ -1,74 +0,0 @@
@@ -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); |
||||
} |
||||
|
||||
} |
@ -1,50 +0,0 @@
@@ -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; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue