Added support for 'advice-chain' sub-element for the 'poller' element (INT-503).
This commit is contained in:
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -62,4 +63,19 @@ public class PollerParserTests {
|
||||
"topLevelPollerWithoutId.xml", PollerParserTests.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pollerWithAdviceChain() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"pollerWithAdviceChain.xml", PollerParserTests.class);
|
||||
Object poller = context.getBean("poller");
|
||||
assertNotNull(poller);
|
||||
PollerMetadata metadata = (PollerMetadata) poller;
|
||||
assertNotNull(metadata.getAdviceChain());
|
||||
assertEquals(3, metadata.getAdviceChain().size());
|
||||
assertEquals(context.getBean("adviceBean1"), metadata.getAdviceChain().get(0));
|
||||
assertEquals(TestAdviceBean.class, metadata.getAdviceChain().get(1).getClass());
|
||||
assertEquals(2, ((TestAdviceBean) metadata.getAdviceChain().get(1)).getId());
|
||||
assertEquals(context.getBean("adviceBean3"), metadata.getAdviceChain().get(2));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* 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.integration.config.xml;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.aop.MethodBeforeAdvice;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class TestAdviceBean implements MethodBeforeAdvice {
|
||||
|
||||
private final int id;
|
||||
|
||||
|
||||
public TestAdviceBean(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void before(Method method, Object[] args, Object target) throws Throwable {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
|
||||
|
||||
<poller id="poller">
|
||||
<interval-trigger interval="5000"/>
|
||||
<advice-chain>
|
||||
<ref bean="adviceBean1"/>
|
||||
<beans:bean class="org.springframework.integration.config.xml.TestAdviceBean">
|
||||
<beans:constructor-arg value="2"/>
|
||||
</beans:bean>
|
||||
<ref bean="adviceBean3"/>
|
||||
</advice-chain>
|
||||
</poller>
|
||||
|
||||
<beans:bean id="adviceBean1" class="org.springframework.integration.config.xml.TestAdviceBean">
|
||||
<beans:constructor-arg value="1"/>
|
||||
</beans:bean>
|
||||
|
||||
<beans:bean id="adviceBean3" class="org.springframework.integration.config.xml.TestAdviceBean">
|
||||
<beans:constructor-arg value="3"/>
|
||||
</beans:bean>
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user