Added the 'request-callback' attribute for the <ws-handler/> element. The provided bean reference will be set as the 'requestCallback' property of the handler (INT-257).

This commit is contained in:
Mark Fisher
2008-06-24 16:22:41 +00:00
parent e24fe02cf0
commit 161e7d1933
6 changed files with 79 additions and 4 deletions

View File

@@ -70,6 +70,10 @@ public class WebServiceHandlerParser extends AbstractSingleBeanDefinitionParser
builder.addConstructorArgReference(sourceExtractorRef);
}
}
String requestCallbackRef = element.getAttribute("request-callback");
if (StringUtils.hasText(requestCallbackRef)) {
builder.addPropertyReference("requestCallback", requestCallbackRef);
}
}
}

View File

@@ -31,6 +31,7 @@
<xsd:attribute name="marshaller" type="xsd:string"/>
<xsd:attribute name="unmarshaller" type="xsd:string"/>
<xsd:attribute name="source-extractor" type="xsd:string"/>
<xsd:attribute name="request-callback" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

View File

@@ -0,0 +1,34 @@
/*
* 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.ws.config;
import java.io.IOException;
import javax.xml.transform.TransformerException;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.client.core.WebServiceMessageCallback;
/**
* @author Mark Fisher
*/
public class StubWebServiceMessageCallback implements WebServiceMessageCallback {
public void doWithMessage(WebServiceMessage message) throws IOException, TransformerException {
}
}

View File

@@ -29,6 +29,7 @@ import org.springframework.integration.ws.handler.SimpleWebServiceHandler;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.ws.client.core.SourceExtractor;
import org.springframework.ws.client.core.WebServiceMessageCallback;
/**
* @author Mark Fisher
@@ -56,6 +57,17 @@ public class WebServiceHandlerParserTests {
assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor"));
}
@Test
public void testSimpleWebServiceHandlerWithCustomRequestCallback() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"simpleWebServiceHandlerParserTests.xml", this.getClass());
MessageHandler handler = (MessageHandler) context.getBean("handlerWithCustomRequestCallback");
assertEquals(SimpleWebServiceHandler.class, handler.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
}
@Test
public void testWebServiceHandlerWithAllInOneMarshaller() {
ApplicationContext context = new ClassPathXmlApplicationContext(
@@ -71,7 +83,7 @@ public class WebServiceHandlerParserTests {
}
@Test
public void testWebServiceTargetAdapterWithSeparateMarshallerAndUnmarshaller() {
public void testWebServiceHandlerWithSeparateMarshallerAndUnmarshaller() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceHandlerParserTests.xml", this.getClass());
MessageHandler handler = (MessageHandler) context.getBean("handlerWithSeparateMarshallerAndUnmarshaller");
@@ -85,4 +97,15 @@ public class WebServiceHandlerParserTests {
assertEquals(unmarshaller, templateAccessor.getPropertyValue("unmarshaller"));
}
@Test
public void testMarshallingWebServiceHandlerWithCustomRequestCallback() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"marshallingWebServiceHandlerParserTests.xml", this.getClass());
MessageHandler handler = (MessageHandler) context.getBean("handlerWithCustomRequestCallback");
assertEquals(MarshallingWebServiceHandler.class, handler.getClass());
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
assertEquals(callback, accessor.getPropertyValue("requestCallback"));
}
}

View File

@@ -12,9 +12,14 @@
marshaller="marshallerAndUnmarshaller"/>
<si:ws-handler id="handlerWithSeparateMarshallerAndUnmarshaller"
uri="http://example.org"
marshaller="marshaller"
unmarshaller="unmarshaller"/>
uri="http://example.org"
marshaller="marshaller"
unmarshaller="unmarshaller"/>
<si:ws-handler id="handlerWithCustomRequestCallback"
uri="http://example.org"
marshaller="marshallerAndUnmarshaller"
request-callback="requestCallback"/>
<bean id="marshallerAndUnmarshaller" class="org.springframework.integration.ws.config.StubMarshallerAndUnmarshaller"/>
@@ -22,4 +27,6 @@
<bean id="unmarshaller" class="org.springframework.integration.ws.config.StubUnmarshaller"/>
<bean id="requestCallback" class="org.springframework.integration.ws.config.StubWebServiceMessageCallback"/>
</beans>

View File

@@ -14,6 +14,12 @@
uri="http://example.org"
source-extractor="sourceExtractor"/>
<si:ws-handler id="handlerWithCustomRequestCallback"
uri="http://example.org"
request-callback="requestCallback"/>
<bean id="sourceExtractor" class="org.springframework.integration.ws.config.StubSourceExtractor"/>
<bean id="requestCallback" class="org.springframework.integration.ws.config.StubWebServiceMessageCallback"/>
</beans>