INT-3284: Add 'spring.factories' Infrastructure

JIRA: https://jira.springsource.org/browse/INT-3284

* Introduce `IntegrationConfigurationBeanFactoryPostProcessor`, `IntegrationConfigurationInitializer`
* Apply `IntegrationConfigurationInitializer` and 'spring.factories' for HTTP and Security modules

INT-3284: Address PR's comments

JIRA: https://jira.springsource.org/browse/INT-3287

* Fix package tangle (INT-3287)
* Apply `IntegrationConfigurationInitializer` for `MBeanExporterHelper`
* Previously, there was a separate `ChannelSecurityInterceptorBeanPostProcessor`
for each `ChannelSecurityInterceptor` whereas now, there is one `ChannelSecurityInterceptorBeanPostProcessor`
that processes all interceptors

INT-3284 Refactoring around config package tangle
This commit is contained in:
Artem Bilan
2014-02-05 13:57:40 +02:00
committed by Gary Russell
parent b59fe444cf
commit ea080e8a9b
50 changed files with 513 additions and 225 deletions

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2014 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.integration.jmx.config;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.integration.config.IntegrationConfigurationInitializer;
import org.springframework.integration.monitor.IntegrationMBeanExporter;
/**
* The JMX Integration infrastructure {@code beanFactory} initializer.
*
* @author Artem Bilan
* @since 4.0
*/
public class JmxIntegrationConfigurationInitializer implements IntegrationConfigurationInitializer {
private static final String MBEAN_EXPORTER_HELPER_BEAN_NAME = MBeanExporterHelper.class.getName();
@Override
public void initialize(ConfigurableListableBeanFactory beanFactory) throws BeansException {
this.registerMBeanExporterHelperIfNecessary(beanFactory);
}
private void registerMBeanExporterHelperIfNecessary(ConfigurableListableBeanFactory beanFactory) {
if (!beanFactory.getBeansOfType(IntegrationMBeanExporter.class, false, false).isEmpty()) {
MBeanExporterHelper mBeanExporterHelper = new MBeanExporterHelper();
mBeanExporterHelper.postProcessBeanFactory(beanFactory);
beanFactory.registerSingleton(MBEAN_EXPORTER_HELPER_BEAN_NAME, mBeanExporterHelper);
beanFactory.initializeBean(mBeanExporterHelper, MBEAN_EXPORTER_HELPER_BEAN_NAME);
}
}
}

View File

@@ -23,8 +23,6 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
@@ -64,12 +62,6 @@ public class MBeanExporterParser extends AbstractSingleBeanDefinitionParser {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "object-naming-strategy", "namingStrategy");
builder.addPropertyValue("server", mbeanServer);
this.registerMBeanExporterHelper(parserContext.getRegistry());
}
private void registerMBeanExporterHelper(BeanDefinitionRegistry registry){
BeanDefinitionBuilder mBeanExporterHelperBuilder = BeanDefinitionBuilder.rootBeanDefinition(MBeanExporterHelper.class);
BeanDefinitionReaderUtils.registerWithGeneratedName(mBeanExporterHelperBuilder.getBeanDefinition(), registry);
}
private Object getMBeanServer(Element element, ParserContext parserContext) {