SimpleWebServiceTargetAdapter is now SimpleWebServiceHandler, and MarshallingWebServiceTargetAdapter is now MarshallingWebServiceHandler. The "ws-target" element is now "ws-handler", and the WebServiceHandlerParser (formerly WebServiceTargetAdapterParser) now creates a MessageHandler instance only - rather than creating the HandlerEndpoint itself. Therefore, the "ws-handler" should be referenced from the "handler" attribute of a <handler-endpoint/> element. See the modified WebServiceDemo (and its configuration file: "temperatureConversion.xml") in the "org.springframework.integration.samples" module for an example.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* 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 org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.ws.handler.MarshallingWebServiceHandler;
|
||||
import org.springframework.integration.ws.handler.SimpleWebServiceHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <ws-handler/> element.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class WebServiceHandlerParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return (StringUtils.hasText(element.getAttribute("marshaller"))) ?
|
||||
MarshallingWebServiceHandler.class : SimpleWebServiceHandler.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateId() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
String uri = element.getAttribute("uri");
|
||||
if (!StringUtils.hasText(uri)) {
|
||||
throw new ConfigurationException("The 'uri' attribute is required.");
|
||||
}
|
||||
builder.addConstructorArgValue(uri);
|
||||
String marshallerRef = element.getAttribute("marshaller");
|
||||
if (StringUtils.hasText(marshallerRef)) {
|
||||
builder.addConstructorArgReference(marshallerRef);
|
||||
String unmarshallerRef = element.getAttribute("unmarshaller");
|
||||
if (StringUtils.hasText(unmarshallerRef)) {
|
||||
builder.addConstructorArgReference(unmarshallerRef);
|
||||
}
|
||||
}
|
||||
else {
|
||||
String sourceExtractorRef = element.getAttribute("source-extractor");
|
||||
if (StringUtils.hasText(sourceExtractorRef)) {
|
||||
builder.addConstructorArgReference(sourceExtractorRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,94 +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.integration.ws.config;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.endpoint.HandlerEndpoint;
|
||||
import org.springframework.integration.scheduling.Subscription;
|
||||
import org.springframework.integration.ws.adapter.MarshallingWebServiceTargetAdapter;
|
||||
import org.springframework.integration.ws.adapter.SimpleWebServiceTargetAdapter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <ws-target/> element.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class WebServiceTargetAdapterParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return HandlerEndpoint.class;
|
||||
}
|
||||
|
||||
protected boolean shouldGenerateId() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean shouldGenerateIdAsFallback() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
String channel = element.getAttribute("channel");
|
||||
String uri = element.getAttribute("uri");
|
||||
if (!StringUtils.hasText(channel)) {
|
||||
throw new ConfigurationException("The 'channel' attribute is required.");
|
||||
}
|
||||
if (!StringUtils.hasText(uri)) {
|
||||
throw new ConfigurationException("The 'uri' attribute is required.");
|
||||
}
|
||||
String marshallerRef = element.getAttribute("marshaller");
|
||||
String unmarshallerRef = element.getAttribute("unmarshaller");
|
||||
String sourceExtractorRef = element.getAttribute("source-extractor");
|
||||
RootBeanDefinition adapterDef = (StringUtils.hasText(marshallerRef)) ?
|
||||
this.parseMarshallingAdapter(uri, marshallerRef, unmarshallerRef) :
|
||||
this.parseSimpleAdapter(uri, sourceExtractorRef);
|
||||
String adapterBeanName = parserContext.getReaderContext().generateBeanName(adapterDef);
|
||||
parserContext.registerBeanComponent(new BeanComponentDefinition(adapterDef, adapterBeanName));
|
||||
builder.addConstructorArgReference(adapterBeanName);
|
||||
Subscription subscription = new Subscription(channel);
|
||||
builder.addPropertyValue("subscription", subscription);
|
||||
}
|
||||
|
||||
private RootBeanDefinition parseMarshallingAdapter(String uri, String marshallerRef, String unmarshallerRef) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(MarshallingWebServiceTargetAdapter.class);
|
||||
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(uri);
|
||||
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(marshallerRef));
|
||||
if (StringUtils.hasText(unmarshallerRef)) {
|
||||
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(unmarshallerRef));
|
||||
}
|
||||
return beanDefinition;
|
||||
}
|
||||
|
||||
private RootBeanDefinition parseSimpleAdapter(String uri, String sourceExtrractorRef) {
|
||||
RootBeanDefinition beanDefinition = new RootBeanDefinition(SimpleWebServiceTargetAdapter.class);
|
||||
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(uri);
|
||||
if (StringUtils.hasText(sourceExtrractorRef)) {
|
||||
beanDefinition.getConstructorArgumentValues().addGenericArgumentValue(new RuntimeBeanReference(sourceExtrractorRef));
|
||||
}
|
||||
return beanDefinition;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,16 +19,15 @@
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
<xsd:element name="ws-target">
|
||||
<xsd:element name="ws-handler">
|
||||
<xsd:complexType>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a Web Service target channel adapter.
|
||||
Defines a Web Service MessageHandler adapter.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="uri" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="channel" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="marshaller" type="xsd:string"/>
|
||||
<xsd:attribute name="unmarshaller" type="xsd:string"/>
|
||||
<xsd:attribute name="source-extractor" type="xsd:string"/>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ws.adapter;
|
||||
package org.springframework.integration.ws.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -32,11 +32,11 @@ import org.springframework.ws.soap.SoapMessage;
|
||||
import org.springframework.ws.soap.client.core.SoapActionCallback;
|
||||
|
||||
/**
|
||||
* Base class for Web Service target channel adapters.
|
||||
* Base class for Web Service {@link MessageHandler} adapters.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractWebServiceTargetAdapter implements MessageHandler {
|
||||
public abstract class AbstractWebServiceHandler implements MessageHandler {
|
||||
|
||||
public static final String SOAP_ACTION_PROPERTY_KEY = "_ws.soapAction";
|
||||
|
||||
@@ -46,8 +46,8 @@ public abstract class AbstractWebServiceTargetAdapter implements MessageHandler
|
||||
private volatile WebServiceMessageCallback requestCallback;
|
||||
|
||||
|
||||
public AbstractWebServiceTargetAdapter(URI uri) {
|
||||
Assert.notNull(uri, "'uri' must not be null");
|
||||
public AbstractWebServiceHandler(URI uri) {
|
||||
Assert.notNull(uri, "URI must not be null");
|
||||
this.webServiceTemplate.setDefaultUri(uri.toString());
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public abstract class AbstractWebServiceTargetAdapter implements MessageHandler
|
||||
|
||||
public final Message<?> handle(Message<?> message) {
|
||||
Object responsePayload = this.doHandle(message.getPayload(), this.getRequestCallback(message));
|
||||
return (responsePayload != null ? new GenericMessage<Object>(responsePayload, message.getHeader()) : null);
|
||||
return responsePayload != null ? new GenericMessage<Object>(responsePayload, message.getHeader()) : null;
|
||||
}
|
||||
|
||||
protected abstract Object doHandle(Object requestPayload, WebServiceMessageCallback requestCallback);
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ws.adapter;
|
||||
package org.springframework.integration.ws.handler;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
@@ -24,15 +24,15 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.ws.client.core.WebServiceMessageCallback;
|
||||
|
||||
/**
|
||||
* A marshalling Web Service target channel adapter.
|
||||
* A marshalling Web Service MessageHandler adapter.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @see Marshaller
|
||||
* @see Unmarshaller
|
||||
*/
|
||||
public class MarshallingWebServiceTargetAdapter extends AbstractWebServiceTargetAdapter {
|
||||
public class MarshallingWebServiceHandler extends AbstractWebServiceHandler {
|
||||
|
||||
public MarshallingWebServiceTargetAdapter(URI uri, Marshaller marshaller, Unmarshaller unmarshaller) {
|
||||
public MarshallingWebServiceHandler(URI uri, Marshaller marshaller, Unmarshaller unmarshaller) {
|
||||
super(uri);
|
||||
Assert.notNull(marshaller, "marshaller must not be null");
|
||||
Assert.notNull(unmarshaller, "unmarshaller must not be null");
|
||||
@@ -40,7 +40,7 @@ public class MarshallingWebServiceTargetAdapter extends AbstractWebServiceTarget
|
||||
this.getWebServiceTemplate().setUnmarshaller(unmarshaller);
|
||||
}
|
||||
|
||||
public MarshallingWebServiceTargetAdapter(URI uri, Marshaller marshaller) {
|
||||
public MarshallingWebServiceHandler(URI uri, Marshaller marshaller) {
|
||||
super(uri);
|
||||
Assert.notNull(marshaller, "marshaller must not be null");
|
||||
Assert.isInstanceOf(Unmarshaller.class, marshaller,
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.ws.adapter;
|
||||
package org.springframework.integration.ws.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -32,20 +32,20 @@ import org.springframework.xml.transform.StringSource;
|
||||
import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
|
||||
/**
|
||||
* A target channel adapter for calling out to a Web Service.
|
||||
* A MessageHandler adapter for invoking a Web Service.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class SimpleWebServiceTargetAdapter extends AbstractWebServiceTargetAdapter {
|
||||
public class SimpleWebServiceHandler extends AbstractWebServiceHandler {
|
||||
|
||||
private final SourceExtractor sourceExtractor;
|
||||
|
||||
|
||||
public SimpleWebServiceTargetAdapter(URI uri) {
|
||||
public SimpleWebServiceHandler(URI uri) {
|
||||
this(uri, null);
|
||||
}
|
||||
|
||||
public SimpleWebServiceTargetAdapter(URI uri, SourceExtractor sourceExtractor) {
|
||||
public SimpleWebServiceHandler(URI uri, SourceExtractor sourceExtractor) {
|
||||
super(uri);
|
||||
this.sourceExtractor = (sourceExtractor != null) ? sourceExtractor : new DefaultSourceExtractor();
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class SimpleWebServiceTargetAdapter extends AbstractWebServiceTargetAdapt
|
||||
}
|
||||
throw new MessagingException("Unsupported payload type '" + requestPayload.getClass() +
|
||||
"'. " + this.getClass().getName() + " only supports 'java.lang.String' and '" + Source.class.getName() +
|
||||
"'. Consider using the '" + MarshallingWebServiceTargetAdapter.class.getName() + "' instead.");
|
||||
"'. Consider using the '" + MarshallingWebServiceHandler.class.getName() + "' instead.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
ws-target=org.springframework.integration.ws.config.WebServiceTargetAdapterParser
|
||||
ws-handler=org.springframework.integration.ws.config.WebServiceHandlerParser
|
||||
Reference in New Issue
Block a user