Fixed INT-770
This commit is contained in:
@@ -37,6 +37,7 @@ import org.springframework.util.xml.DomUtils;
|
|||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
* @author Marius Bogoevici
|
* @author Marius Bogoevici
|
||||||
* @author Alex Peters
|
* @author Alex Peters
|
||||||
|
* @author Oleg Zhurakousky
|
||||||
*/
|
*/
|
||||||
public abstract class IntegrationNamespaceUtils {
|
public abstract class IntegrationNamespaceUtils {
|
||||||
|
|
||||||
@@ -189,7 +190,9 @@ public abstract class IntegrationNamespaceUtils {
|
|||||||
if (childElements != null && childElements.size() == 1){
|
if (childElements != null && childElements.size() == 1){
|
||||||
Element beanElement = childElements.get(0);
|
Element beanElement = childElements.get(0);
|
||||||
BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
|
BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
|
||||||
innerDefinition = delegate.parseBeanDefinitionElement(beanElement).getBeanDefinition();
|
BeanDefinitionHolder bdHolder = delegate.parseBeanDefinitionElement(beanElement);
|
||||||
|
bdHolder = delegate.decorateBeanDefinitionIfRequired(beanElement, bdHolder);
|
||||||
|
innerDefinition = bdHolder.getBeanDefinition();
|
||||||
}
|
}
|
||||||
|
|
||||||
String ref = element.getAttribute(REF_ATTRIBUTE);
|
String ref = element.getAttribute(REF_ATTRIBUTE);
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
|
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-1.0.xsd"
|
||||||
|
xmlns:p="http://www.springframework.org/schema/p"
|
||||||
|
xmlns:si="http://www.springframework.org/schema/integration">
|
||||||
|
|
||||||
|
<si:channel id="input"/>
|
||||||
|
|
||||||
|
<si:service-activator id="sa" input-channel="input" method="printWithPrefix">
|
||||||
|
<bean class="org.springframework.integration.config.xml.PNamespaceTest$TestBean"
|
||||||
|
p:fname="paris" p:lname="hilton"/>
|
||||||
|
</si:service-activator>
|
||||||
|
|
||||||
|
<si:splitter id="sp" input-channel="input" method="printWithPrefix">
|
||||||
|
<bean class="org.springframework.integration.config.xml.PNamespaceTest$TestBean"
|
||||||
|
p:fname="paris" p:lname="hilton"/>
|
||||||
|
</si:splitter>
|
||||||
|
|
||||||
|
<si:transformer id="tr" input-channel="input" method="printWithPrefix">
|
||||||
|
<bean class="org.springframework.integration.config.xml.PNamespaceTest$TestBean"
|
||||||
|
p:fname="paris" p:lname="hilton"/>
|
||||||
|
</si:transformer>
|
||||||
|
|
||||||
|
<si:router id="rt" input-channel="input" method="printWithPrefix">
|
||||||
|
<bean class="org.springframework.integration.config.xml.PNamespaceTest$TestBean"
|
||||||
|
p:fname="paris" p:lname="hilton"/>
|
||||||
|
</si:router>
|
||||||
|
</beans>
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* 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 junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.beans.DirectFieldAccessor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the "p:namespace" is working for inner "bean" definition within SI components.
|
||||||
|
*
|
||||||
|
* @author Oleg Zhurakousky
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@ContextConfiguration
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
public class PNamespaceTest {
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("sa")
|
||||||
|
EventDrivenConsumer serviceActivator;
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("sp")
|
||||||
|
EventDrivenConsumer splitter;
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("rt")
|
||||||
|
EventDrivenConsumer router;
|
||||||
|
@Autowired
|
||||||
|
@Qualifier("tr")
|
||||||
|
EventDrivenConsumer transformer;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPNamespaceServiceActivator(){
|
||||||
|
TestBean bean = prepare(serviceActivator);
|
||||||
|
|
||||||
|
Assert.assertEquals("paris", bean.getFname());
|
||||||
|
Assert.assertEquals("hilton", bean.getLname());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testPNamespaceSplitter(){
|
||||||
|
TestBean bean = prepare(splitter);
|
||||||
|
|
||||||
|
Assert.assertEquals("paris", bean.getFname());
|
||||||
|
Assert.assertEquals("hilton", bean.getLname());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testPNamespaceRouter(){
|
||||||
|
TestBean bean = prepare(router);
|
||||||
|
|
||||||
|
Assert.assertEquals("paris", bean.getFname());
|
||||||
|
Assert.assertEquals("hilton", bean.getLname());
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
public void testPNamespaceTransformer(){
|
||||||
|
TestBean bean = prepare(transformer);
|
||||||
|
|
||||||
|
Assert.assertEquals("paris", bean.getFname());
|
||||||
|
Assert.assertEquals("hilton", bean.getLname());
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestBean prepare(EventDrivenConsumer edc){
|
||||||
|
DirectFieldAccessor saAccessor = new DirectFieldAccessor(serviceActivator);
|
||||||
|
Object handler = saAccessor.getPropertyValue("handler");
|
||||||
|
DirectFieldAccessor hAccessor = new DirectFieldAccessor(handler);
|
||||||
|
Object invoker = hAccessor.getPropertyValue("invoker");
|
||||||
|
DirectFieldAccessor iAccessor = new DirectFieldAccessor(invoker);
|
||||||
|
return (TestBean) iAccessor.getPropertyValue("object");
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface InboundGateway{
|
||||||
|
public String echo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class TestBean{
|
||||||
|
private String fname;
|
||||||
|
private String lname;
|
||||||
|
public String getFname() {
|
||||||
|
return fname;
|
||||||
|
}
|
||||||
|
public void setFname(String fname) {
|
||||||
|
this.fname = fname;
|
||||||
|
}
|
||||||
|
public String getLname() {
|
||||||
|
return lname;
|
||||||
|
}
|
||||||
|
public void setLname(String lname) {
|
||||||
|
this.lname = lname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String printWithPrefix(String prefix){
|
||||||
|
return prefix + fname + " " + lname;
|
||||||
|
}
|
||||||
|
public String toString(){
|
||||||
|
return fname + lname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user