Generified core & support module

This commit is contained in:
Arjen Poutsma
2010-02-02 15:52:44 +00:00
parent 52b3d2efef
commit 5945f19898
29 changed files with 163 additions and 161 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2005-2010 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.
@@ -26,9 +26,6 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
@@ -62,6 +59,9 @@ import org.springframework.ws.transport.context.TransportContextHolder;
import org.springframework.ws.transport.http.HttpUrlConnectionMessageSender;
import org.springframework.ws.transport.support.TransportUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <strong>The central class for client-side Web services.</strong> It provides a message-driven approach to sending and
* receiving {@link WebServiceMessage} instances.
@@ -408,7 +408,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
return Boolean.TRUE;
}
});
return retVal != null && retVal.booleanValue();
return retVal != null && retVal;
}
catch (TransformerConfigurationException ex) {
throw new WebServiceTransformerException("Could not create transformer", ex);
@@ -479,7 +479,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
Assert.notNull(responseCallback, "responseCallback must not be null");
Boolean result = (Boolean) sendAndReceive(uri, requestCallback,
new WebServiceMessageCallbackMessageExtractor(responseCallback));
return result != null && result.booleanValue();
return result != null && result;
}
public Object sendAndReceive(WebServiceMessageCallback requestCallback,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2005-2010 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.
@@ -34,10 +34,6 @@ import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import org.w3c.dom.Element;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -46,6 +42,10 @@ import org.springframework.ws.soap.saaj.SaajSoapMessageException;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.xml.namespace.QNameUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
/**
* Collection of generic utility methods to work with SAAJ. Includes conversion from SAAJ {@link Name} objects to {@link
* QName}s and vice-versa, and SAAJ version checking.
@@ -71,7 +71,7 @@ public abstract class SaajUtils {
private static final String SAAJ_13_CLASS_NAME = "javax.xml.soap.SAAJMetaFactory";
// Maps SOAPElement class names to Integer SAAJ versions (SAAJ_11, SAAJ_12, SAAJ_13)
private static final Map saajVersions = Collections.synchronizedMap(new HashMap());
private static final Map<String, Integer> saajVersions = Collections.synchronizedMap(new HashMap<String, Integer>());
private static int saajVersion = SAAJ_12;
@@ -175,25 +175,25 @@ public abstract class SaajUtils {
public static int getSaajVersion(SOAPElement soapElement) {
Assert.notNull(soapElement, "'soapElement' must not be null");
Class soapElementClass = soapElement.getClass();
Integer saajVersion = (Integer) saajVersions.get(soapElementClass.getName());
Integer saajVersion = saajVersions.get(soapElementClass.getName());
if (saajVersion == null) {
if (isSaaj12(soapElement)) {
if (isSaaj13(soapElement)) {
saajVersion = new Integer(SAAJ_13);
saajVersion = SAAJ_13;
}
else {
saajVersion = new Integer(SAAJ_12);
saajVersion = SAAJ_12;
}
} else {
saajVersion = new Integer(SAAJ_11);
saajVersion = SAAJ_11;
}
saajVersions.put(soapElementClass.getName(), saajVersion);
if (logger.isTraceEnabled()) {
logger.trace("SOAPElement [" + soapElement.getClass().getName() + "] implements " +
getSaajVersionString(saajVersion.intValue()));
getSaajVersionString(saajVersion));
}
}
return saajVersion.intValue();
return saajVersion;
}
private static boolean isSaaj13(SOAPElement soapElement) {

View File

@@ -60,15 +60,15 @@ public abstract class AbstractReceiverConnection extends AbstractWebServiceConne
/**
* Returns an iteration over all the header names this request contains. Returns an empty <code>Iterator</code> if
* there areno headers.
* there are no headers.
*/
protected abstract Iterator getRequestHeaderNames() throws IOException;
protected abstract Iterator<String> getRequestHeaderNames() throws IOException;
/**
* Returns an iteration over all the string values of the specified header. Returns an empty <code>Iterator</code>
* if there are no headers of the specified name.
*/
protected abstract Iterator getRequestHeaders(String name) throws IOException;
protected abstract Iterator<String> getRequestHeaders(String name) throws IOException;
/** Returns the input stream to read the response from. */
protected abstract InputStream getRequestInputStream() throws IOException;
@@ -94,12 +94,12 @@ public abstract class AbstractReceiverConnection extends AbstractWebServiceConne
}
@Override
public Iterator getHeaderNames() throws IOException {
public Iterator<String> getHeaderNames() throws IOException {
return getRequestHeaderNames();
}
@Override
public Iterator getHeaders(String name) throws IOException {
public Iterator<String> getHeaders(String name) throws IOException {
return getRequestHeaders(name);
}

View File

@@ -80,15 +80,15 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect
/**
* Returns an iteration over all the header names this request contains. Returns an empty <code>Iterator</code> if
* there areno headers.
* there are no headers.
*/
protected abstract Iterator getResponseHeaderNames() throws IOException;
protected abstract Iterator<String> getResponseHeaderNames() throws IOException;
/**
* Returns an iteration over all the string values of the specified header. Returns an empty <code>Iterator</code>
* if there are no headers of the specified name.
*/
protected abstract Iterator getResponseHeaders(String name) throws IOException;
protected abstract Iterator<String> getResponseHeaders(String name) throws IOException;
/** Returns the input stream to read the response from. */
protected abstract InputStream getResponseInputStream() throws IOException;
@@ -116,12 +116,12 @@ public abstract class AbstractSenderConnection extends AbstractWebServiceConnect
}
@Override
public Iterator getHeaderNames() throws IOException {
public Iterator<String> getHeaderNames() throws IOException {
return getResponseHeaderNames();
}
@Override
public Iterator getHeaders(String name) throws IOException {
public Iterator<String> getHeaders(String name) throws IOException {
return getResponseHeaders(name);
}

View File

@@ -108,11 +108,11 @@ public abstract class TransportInputStream extends InputStream {
* Returns an iteration over all the header names this stream contains. Returns an empty <code>Iterator</code> if
* there are no headers.
*/
public abstract Iterator getHeaderNames() throws IOException;
public abstract Iterator<String> getHeaderNames() throws IOException;
/**
* Returns an iteration over all the string values of the specified header. Returns an empty <code>Iterator</code>
* if there are no headers of the specified name.
*/
public abstract Iterator getHeaders(String name) throws IOException;
public abstract Iterator<String> getHeaders(String name) throws IOException;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2005-2010 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.
@@ -25,7 +25,7 @@ package org.springframework.ws.transport.context;
*/
public abstract class TransportContextHolder {
private static final ThreadLocal transportContextHolder = new TransportThreadLocal();
private static final ThreadLocal<TransportContext> transportContextHolder = new TransportThreadLocal();
/**
* Associate the given <code>TransportContext</code> with the current thread.
@@ -45,7 +45,7 @@ public abstract class TransportContextHolder {
return (TransportContext) transportContextHolder.get();
}
private static class TransportThreadLocal extends ThreadLocal {
private static class TransportThreadLocal extends ThreadLocal<TransportContext> {
public String toString() {
return "Transport State";

View File

@@ -90,9 +90,9 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect
/** Determine whether the response is a GZIP response. */
private boolean isGzipResponse() throws IOException {
Iterator iterator = getResponseHeaders(HttpTransportConstants.HEADER_CONTENT_ENCODING);
Iterator<String> iterator = getResponseHeaders(HttpTransportConstants.HEADER_CONTENT_ENCODING);
if (iterator.hasNext()) {
String encodingHeader = (String) iterator.next();
String encodingHeader = iterator.next();
return encodingHeader.toLowerCase().indexOf(HttpTransportConstants.CONTENT_ENCODING_GZIP) != -1;
}
return false;
@@ -120,9 +120,9 @@ public abstract class AbstractHttpSenderConnection extends AbstractSenderConnect
/** Determine whether the response is a XML message. */
private boolean isXmlResponse() throws IOException {
Iterator iterator = getResponseHeaders(HttpTransportConstants.HEADER_CONTENT_TYPE);
Iterator<String> iterator = getResponseHeaders(HttpTransportConstants.HEADER_CONTENT_TYPE);
if (iterator.hasNext()) {
String contentType = ((String) iterator.next()).toLowerCase();
String contentType = iterator.next().toLowerCase();
return contentType.indexOf("xml") != -1;
}
return false;

View File

@@ -25,17 +25,17 @@ import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Iterator;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
import org.springframework.util.Assert;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.transport.WebServiceConnection;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
import org.apache.commons.httpclient.methods.PostMethod;
/**
* Implementation of {@link WebServiceConnection} that is based on Jakarta Commons HttpClient. Exposes a {@link
* PostMethod}.
@@ -148,7 +148,7 @@ public class CommonsHttpConnection extends AbstractHttpSenderConnection {
}
@Override
protected Iterator getResponseHeaderNames() throws IOException {
protected Iterator<String> getResponseHeaderNames() throws IOException {
Header[] headers = postMethod.getResponseHeaders();
String[] names = new String[headers.length];
for (int i = 0; i < headers.length; i++) {
@@ -158,7 +158,7 @@ public class CommonsHttpConnection extends AbstractHttpSenderConnection {
}
@Override
protected Iterator getResponseHeaders(String name) throws IOException {
protected Iterator<String> getResponseHeaders(String name) throws IOException {
Header[] headers = postMethod.getResponseHeaders(name);
String[] values = new String[headers.length];
for (int i = 0; i < headers.length; i++) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2005-2010 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.
@@ -21,6 +21,11 @@ import java.net.URI;
import java.util.Iterator;
import java.util.Properties;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.ws.transport.WebServiceConnection;
import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HostConfiguration;
import org.apache.commons.httpclient.HttpClient;
@@ -34,11 +39,6 @@ import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.PostMethod;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import org.springframework.ws.transport.WebServiceConnection;
/**
* <code>WebServiceMessageSender</code> implementation that uses <a href="http://jakarta.apache.org/commons/httpclient">Jakarta
* Commons HttpClient</a> to execute POST requests.
@@ -167,7 +167,7 @@ public class CommonsHttpMessageSender extends AbstractHttpWebServiceMessageSende
* int)
*/
public void setMaxConnectionsPerHost(Properties maxConnectionsPerHost) throws URIException {
for (Iterator iterator = maxConnectionsPerHost.keySet().iterator(); iterator.hasNext();) {
for (Iterator<?> iterator = maxConnectionsPerHost.keySet().iterator(); iterator.hasNext();) {
String host = (String) iterator.next();
HostConfiguration hostConfiguration = new HostConfiguration();
if ("*".equals(host)) {

View File

@@ -98,12 +98,14 @@ public class HttpServletConnection extends AbstractReceiverConnection
*/
@Override
protected Iterator getRequestHeaderNames() throws IOException {
@SuppressWarnings("unchecked")
protected Iterator<String> getRequestHeaderNames() throws IOException {
return new EnumerationIterator(getHttpServletRequest().getHeaderNames());
}
@Override
protected Iterator getRequestHeaders(String name) throws IOException {
@SuppressWarnings("unchecked")
protected Iterator<String> getRequestHeaders(String name) throws IOException {
return new EnumerationIterator(getHttpServletRequest().getHeaders(name));
}

View File

@@ -99,8 +99,8 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection {
}
@Override
protected Iterator getResponseHeaderNames() throws IOException {
List headerNames = new ArrayList();
protected Iterator<String> getResponseHeaderNames() throws IOException {
List<String> headerNames = new ArrayList<String>();
// Header field 0 is the status line, so we start at 1
int i = 1;
while (true) {
@@ -115,13 +115,13 @@ public class HttpUrlConnection extends AbstractHttpSenderConnection {
}
@Override
protected Iterator getResponseHeaders(String name) throws IOException {
protected Iterator<String> getResponseHeaders(String name) throws IOException {
String headerField = connection.getHeaderField(name);
if (headerField == null) {
return Collections.EMPTY_LIST.iterator();
return Collections.<String>emptyList().iterator();
}
else {
Set tokens = StringUtils.commaDelimitedListToSet(headerField);
Set<String> tokens = StringUtils.commaDelimitedListToSet(headerField);
return tokens.iterator();
}
}

View File

@@ -16,7 +16,6 @@
package org.springframework.ws.transport.http;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -122,9 +121,9 @@ public class MessageDispatcherServlet extends FrameworkServlet {
private WebServiceMessageReceiver messageReceiver;
/** Keys are bean names, values are {@link WsdlDefinition WsdlDefinitions}. */
private Map wsdlDefinitions;
private Map<String, WsdlDefinition> wsdlDefinitions;
private Map xsdSchemas;
private Map<String, XsdSchema> xsdSchemas;
private boolean transformWsdlLocations = false;
@@ -394,10 +393,9 @@ public class MessageDispatcherServlet extends FrameworkServlet {
wsdlDefinitions = BeanFactoryUtils
.beansOfTypeIncludingAncestors(getWebApplicationContext(), WsdlDefinition.class, true, false);
if (logger.isDebugEnabled()) {
for (Iterator iterator = wsdlDefinitions.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String beanName = (String) entry.getKey();
WsdlDefinition definition = (WsdlDefinition) entry.getValue();
for (Map.Entry<String, WsdlDefinition> entry : wsdlDefinitions.entrySet()) {
String beanName = entry.getKey();
WsdlDefinition definition = entry.getValue();
logger.debug("Published [" + definition + "] as " + beanName + WSDL_SUFFIX_NAME);
}
}
@@ -408,10 +406,9 @@ public class MessageDispatcherServlet extends FrameworkServlet {
xsdSchemas = BeanFactoryUtils
.beansOfTypeIncludingAncestors(getWebApplicationContext(), XsdSchema.class, true, false);
if (logger.isDebugEnabled()) {
for (Iterator iterator = xsdSchemas.entrySet().iterator(); iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
String beanName = (String) entry.getKey();
XsdSchema schema = (XsdSchema) entry.getValue();
for (Map.Entry<String, XsdSchema> entry : xsdSchemas.entrySet()) {
String beanName = entry.getKey();
XsdSchema schema = entry.getValue();
logger.debug("Published [" + schema + "] as " + beanName + XSD_SUFFIX_NAME);
}
}

View File

@@ -17,7 +17,6 @@
package org.springframework.ws.transport.http;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
@@ -41,6 +40,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
/**
* Adapter to use the <code>WsdlDefinition</code> interface with the generic <code>DispatcherServlet</code>.
@@ -197,15 +197,17 @@ public class WsdlDefinitionHandlerAdapter extends TransformerObjectSupport imple
* @see #transformLocation(String,javax.servlet.http.HttpServletRequest)
*/
protected void transformLocations(Document definitionDocument, HttpServletRequest request) throws Exception {
List locationNodes = locationXPathExpression.evaluateAsNodeList(definitionDocument);
for (Iterator iterator = locationNodes.iterator(); iterator.hasNext();) {
Attr location = (Attr) iterator.next();
if (location != null && StringUtils.hasLength(location.getValue())) {
String newLocation = transformLocation(location.getValue(), request);
if (logger.isDebugEnabled()) {
logger.debug("Transforming [" + location.getValue() + "] to [" + newLocation + "]");
List<Node> locationNodes = locationXPathExpression.evaluateAsNodeList(definitionDocument);
for (Node locationNode : locationNodes) {
if (locationNode instanceof Attr) {
Attr location = (Attr) locationNode;
if (StringUtils.hasLength(location.getValue())) {
String newLocation = transformLocation(location.getValue(), request);
if (logger.isDebugEnabled()) {
logger.debug("Transforming [" + location.getValue() + "] to [" + newLocation + "]");
}
location.setValue(newLocation);
}
location.setValue(newLocation);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006 the original author or authors.
* Copyright 2005-2010 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.
@@ -25,11 +25,11 @@ import java.util.Iterator;
* @author Arjen Poutsma
* @since 1.0.0
*/
public class EnumerationIterator implements Iterator {
public class EnumerationIterator<T> implements Iterator<T> {
private final Enumeration enumeration;
private final Enumeration<T> enumeration;
public EnumerationIterator(Enumeration enumeration) {
public EnumerationIterator(Enumeration<T> enumeration) {
this.enumeration = enumeration;
}
@@ -37,7 +37,7 @@ public class EnumerationIterator implements Iterator {
return enumeration.hasMoreElements();
}
public Object next() {
public T next() {
return enumeration.nextElement();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008 the original author or authors.
* Copyright 2005-2010 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.
@@ -32,12 +32,12 @@ import javax.wsdl.PortType;
import javax.wsdl.WSDLException;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Abstract base class for {@link PortTypesProvider} implementations.
*
@@ -94,14 +94,15 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider {
}
private void createOperations(Definition definition, PortType portType) throws WSDLException {
Map operations = new HashMap();
for (Iterator iterator = definition.getMessages().values().iterator(); iterator.hasNext();) {
// TODO: use MultivaluedMap
Map<String, List<Message>> operations = new HashMap<String, List<Message>>();
for (Iterator<?> iterator = definition.getMessages().values().iterator(); iterator.hasNext();) {
Message message = (Message) iterator.next();
String operationName = getOperationName(message);
if (StringUtils.hasText(operationName)) {
List messages = (List) operations.get(operationName);
List<Message> messages = operations.get(operationName);
if (messages == null) {
messages = new ArrayList();
messages = new ArrayList<Message>();
operations.put(operationName, messages);
}
messages.add(message);
@@ -110,13 +111,11 @@ public abstract class AbstractPortTypesProvider implements PortTypesProvider {
if (operations.isEmpty() && logger.isWarnEnabled()) {
logger.warn("No operations were created, make sure the WSDL contains messages");
}
for (Iterator iterator = operations.keySet().iterator(); iterator.hasNext();) {
String operationName = (String) iterator.next();
for (String operationName : operations.keySet()) {
Operation operation = definition.createOperation();
operation.setName(operationName);
List messages = (List) operations.get(operationName);
for (Iterator messagesIterator = messages.iterator(); messagesIterator.hasNext();) {
Message message = (Message) messagesIterator.next();
List<Message> messages = operations.get(operationName);
for (Message message : messages) {
if (isInputMessage(message)) {
Input input = definition.createInput();
input.setMessage(message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008 the original author or authors.
* Copyright 2005-2010 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.
@@ -34,12 +34,12 @@ import javax.wsdl.Service;
import javax.wsdl.WSDLException;
import javax.xml.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Default implementation of the {@link BindingsProvider} and {@link ServicesProvider} interfaces.
* <p/>
@@ -96,7 +96,7 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr
* @see #populateBindingFault(Definition,javax.wsdl.BindingFault,javax.wsdl.Fault)
*/
public void addBindings(Definition definition) throws WSDLException {
for (Iterator iterator = definition.getPortTypes().values().iterator(); iterator.hasNext();) {
for (Iterator<?> iterator = definition.getPortTypes().values().iterator(); iterator.hasNext();) {
PortType portType = (PortType) iterator.next();
Binding binding = definition.createBinding();
binding.setPortType(portType);
@@ -136,7 +136,7 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr
private void createBindingOperations(Definition definition, Binding binding) throws WSDLException {
PortType portType = binding.getPortType();
for (Iterator operationIterator = portType.getOperations().iterator(); operationIterator.hasNext();) {
for (Iterator<?> operationIterator = portType.getOperations().iterator(); operationIterator.hasNext();) {
Operation operation = (Operation) operationIterator.next();
BindingOperation bindingOperation = definition.createBindingOperation();
bindingOperation.setOperation(operation);
@@ -155,7 +155,7 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr
createBindingOutput(definition, operation, bindingOperation);
createBindingInput(definition, operation, bindingOperation);
}
for (Iterator faultIterator = operation.getFaults().values().iterator(); faultIterator.hasNext();) {
for (Iterator<?> faultIterator = operation.getFaults().values().iterator(); faultIterator.hasNext();) {
Fault fault = (Fault) faultIterator.next();
BindingFault bindingFault = definition.createBindingFault();
populateBindingFault(definition, bindingFault, fault);
@@ -284,10 +284,10 @@ public class DefaultConcretePartProvider implements BindingsProvider, ServicesPr
}
private void createPorts(Definition definition, Service service) throws WSDLException {
for (Iterator iterator = definition.getBindings().values().iterator(); iterator.hasNext();) {
for (Iterator<?> iterator = definition.getBindings().values().iterator(); iterator.hasNext();) {
Binding binding = (Binding) iterator.next();
Port port = null;
for (Iterator iterator1 = service.getPorts().values().iterator(); iterator1.hasNext();) {
for (Iterator<?> iterator1 = service.getPorts().values().iterator(); iterator1.hasNext();) {
Port existingPort = (Port) iterator1.next();
if (binding.equals(existingPort.getBinding())) {
port = existingPort;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2008 the original author or authors.
* Copyright 2005-2010 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.
@@ -26,14 +26,14 @@ import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.extensions.schema.Schema;
import javax.xml.namespace.QName;
import org.springframework.util.Assert;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.springframework.util.Assert;
/**
* Default implementation of the {@link MessagesProvider}.
* <p/>
@@ -49,7 +49,7 @@ public class DefaultMessagesProvider implements MessagesProvider {
public void addMessages(Definition definition) throws WSDLException {
Types types = definition.getTypes();
Assert.notNull(types, "No types element present in definition");
for (Iterator iterator = types.getExtensibilityElements().iterator(); iterator.hasNext();) {
for (Iterator<?> iterator = types.getExtensibilityElements().iterator(); iterator.hasNext();) {
ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next();
if (extensibilityElement instanceof Schema) {
Schema schema = (Schema) extensibilityElement;

View File

@@ -307,7 +307,7 @@ public class Soap11Provider extends DefaultConcretePartProvider {
*/
@Override
protected void populatePort(Definition definition, Port port) throws WSDLException {
for (Iterator iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) {
for (Iterator<?> iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) {
if (iterator.next() instanceof SOAPBinding) {
// this is a SOAP 1.1 binding, create a SOAP Address for it
super.populatePort(definition, port);
@@ -342,7 +342,7 @@ public class Soap11Provider extends DefaultConcretePartProvider {
* @throws WSDLException in case of errors
* @see ExtensionRegistry#createExtension(Class, QName)
*/
private ExtensibilityElement createSoapExtension(Definition definition, Class parentType, String localName)
private ExtensibilityElement createSoapExtension(Definition definition, Class<?> parentType, String localName)
throws WSDLException {
return definition.getExtensionRegistry()
.createExtension(parentType, new QName(SOAP_11_NAMESPACE_URI, localName));

View File

@@ -310,7 +310,7 @@ public class Soap12Provider extends DefaultConcretePartProvider {
*/
@Override
protected void populatePort(Definition definition, Port port) throws WSDLException {
for (Iterator iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) {
for (Iterator<?> iterator = port.getBinding().getExtensibilityElements().iterator(); iterator.hasNext();) {
if (iterator.next() instanceof SOAP12Binding) {
// this is a SOAP 1.2 binding, create a SOAP Address for it
super.populatePort(definition, port);
@@ -345,7 +345,7 @@ public class Soap12Provider extends DefaultConcretePartProvider {
* @throws WSDLException in case of errors
* @see javax.wsdl.extensions.ExtensionRegistry#createExtension(Class, QName)
*/
private ExtensibilityElement createSoapExtension(Definition definition, Class parentType, String localName)
private ExtensibilityElement createSoapExtension(Definition definition, Class<?> parentType, String localName)
throws WSDLException {
return definition.getExtensionRegistry()
.createExtension(parentType, new QName(SOAP_12_NAMESPACE_URI, localName));

View File

@@ -27,8 +27,6 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.custommonkey.xmlunit.XMLTestCase;
import org.easymock.MockControl;
import org.springframework.oxm.Marshaller;
import org.springframework.oxm.Unmarshaller;
import org.springframework.oxm.XmlMappingException;
@@ -42,6 +40,9 @@ import org.springframework.ws.mime.MimeMessage;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
import org.custommonkey.xmlunit.XMLTestCase;
import org.easymock.MockControl;
public class MarshallingPayloadEndpointTest extends XMLTestCase {
private Transformer transformer;
@@ -70,7 +71,7 @@ public class MarshallingPayloadEndpointTest extends XMLTestCase {
StringWriter writer = new StringWriter();
transformer.transform(source, new StreamResult(writer));
assertXMLEqual("Invalid source", "<request/>", writer.toString());
return new Long(42);
return 42L;
}
catch (Exception e) {
fail(e.getMessage());
@@ -93,7 +94,7 @@ public class MarshallingPayloadEndpointTest extends XMLTestCase {
AbstractMarshallingPayloadEndpoint endpoint = new AbstractMarshallingPayloadEndpoint() {
@Override
protected Object invokeInternal(Object requestObject) throws Exception {
assertEquals("Invalid request object", new Long(42), requestObject);
assertEquals("Invalid request object", 42L, requestObject);
return "result";
}
};

View File

@@ -19,19 +19,20 @@ package org.springframework.ws.transport;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Properties;
import java.util.Map;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
public class MockTransportInputStream extends TransportInputStream {
private Properties headers;
private Map<String, String> headers;
private InputStream inputStream;
public MockTransportInputStream(InputStream inputStream, Properties headers) {
public MockTransportInputStream(InputStream inputStream, Map<String, String> headers) {
Assert.notNull(inputStream, "inputStream must not be null");
Assert.notNull(headers, "headers must not be null");
this.inputStream = inputStream;
@@ -41,7 +42,7 @@ public class MockTransportInputStream extends TransportInputStream {
public MockTransportInputStream(InputStream inputStream) {
Assert.notNull(inputStream, "inputStream must not be null");
this.inputStream = inputStream;
headers = new Properties();
headers = new HashMap<String, String>();
}
@Override
@@ -50,13 +51,13 @@ public class MockTransportInputStream extends TransportInputStream {
}
@Override
public Iterator getHeaderNames() throws IOException {
public Iterator<String> getHeaderNames() throws IOException {
return headers.keySet().iterator();
}
@Override
public Iterator getHeaders(String name) throws IOException {
String[] values = StringUtils.delimitedListToStringArray(headers.getProperty(name), ", ");
public Iterator<String> getHeaders(String name) throws IOException {
String[] values = StringUtils.delimitedListToStringArray(headers.get(name), ", ");
return Arrays.asList(values).iterator();
}
}

View File

@@ -25,7 +25,7 @@ import org.springframework.util.Assert;
public class MockTransportOutputStream extends TransportOutputStream {
private Map headers = new HashMap();
private Map<String, String> headers = new HashMap<String, String>();
private OutputStream outputStream;
@@ -39,7 +39,7 @@ public class MockTransportOutputStream extends TransportOutputStream {
return outputStream;
}
public Map getHeaders() {
public Map<String, String> getHeaders() {
return headers;
}

View File

@@ -36,12 +36,7 @@ import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.FileCopyUtils;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.WebServiceMessageFactory;
@@ -51,7 +46,12 @@ import org.springframework.ws.transport.FaultAwareWebServiceConnection;
import org.springframework.ws.transport.WebServiceConnection;
import org.springframework.xml.transform.StringResult;
import org.springframework.xml.transform.StringSource;
import org.springframework.beans.factory.InitializingBean;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase extends XMLTestCase {
@@ -244,7 +244,7 @@ public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase ext
}
public void setContentLength(int contentLength) {
this.contentLength = new Integer(contentLength);
this.contentLength = contentLength;
}
public void setResponse(boolean response) {
@@ -273,7 +273,7 @@ public abstract class AbstractHttpWebServiceMessageSenderIntegrationTestCase ext
if (response) {
httpServletResponse.setContentType("text/xml");
if (contentLength != null) {
httpServletResponse.setContentLength(contentLength.intValue());
httpServletResponse.setContentLength(contentLength);
}
if (gzip) {
httpServletResponse.addHeader("Content-Encoding", "gzip");

View File

@@ -26,8 +26,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import com.sun.net.httpserver.HttpExchange;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
import org.springframework.ws.WebServiceMessage;
@@ -36,6 +34,8 @@ import org.springframework.ws.transport.EndpointAwareWebServiceConnection;
import org.springframework.ws.transport.FaultAwareWebServiceConnection;
import org.springframework.ws.transport.WebServiceConnection;
import com.sun.net.httpserver.HttpExchange;
/**
* Implementation of {@link WebServiceConnection} that is based on the Java 6 HttpServer {@link HttpExchange}.
*
@@ -93,14 +93,14 @@ public class HttpExchangeConnection extends AbstractReceiverConnection
*/
@Override
protected Iterator getRequestHeaderNames() throws IOException {
protected Iterator<String> getRequestHeaderNames() throws IOException {
return httpExchange.getRequestHeaders().keySet().iterator();
}
@Override
protected Iterator getRequestHeaders(String name) throws IOException {
List headers = httpExchange.getRequestHeaders().get(name);
return headers != null ? headers.iterator() : Collections.EMPTY_LIST.iterator();
protected Iterator<String> getRequestHeaders(String name) throws IOException {
List<String> headers = httpExchange.getRequestHeaders().get(name);
return headers != null ? headers.iterator() : Collections.<String>emptyList().iterator();
}
@Override

View File

@@ -137,7 +137,7 @@ public class JmsReceiverConnection extends AbstractReceiverConnection {
*/
@Override
protected Iterator getRequestHeaderNames() throws IOException {
protected Iterator<String> getRequestHeaderNames() throws IOException {
try {
return JmsTransportUtils.getHeaderNames(requestMessage);
}
@@ -147,7 +147,7 @@ public class JmsReceiverConnection extends AbstractReceiverConnection {
}
@Override
protected Iterator getRequestHeaders(String name) throws IOException {
protected Iterator<String> getRequestHeaders(String name) throws IOException {
try {
return JmsTransportUtils.getHeaders(requestMessage, name);
}

View File

@@ -290,7 +290,7 @@ public class JmsSenderConnection extends AbstractSenderConnection {
}
@Override
protected Iterator getResponseHeaderNames() throws IOException {
protected Iterator<String> getResponseHeaderNames() throws IOException {
try {
return JmsTransportUtils.getHeaderNames(responseMessage);
}
@@ -300,7 +300,7 @@ public class JmsSenderConnection extends AbstractSenderConnection {
}
@Override
protected Iterator getResponseHeaders(String name) throws IOException {
protected Iterator<String> getResponseHeaders(String name) throws IOException {
try {
return JmsTransportUtils.getHeaders(responseMessage, name);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007 the original author or authors.
* Copyright 2005-2010 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.
@@ -130,9 +130,9 @@ public abstract class JmsTransportUtils {
* Returns an iterator over all header names in the given message. Delegates to {@link
* #jmsPropertyToHeader(String)}.
*/
public static Iterator getHeaderNames(Message message) throws JMSException {
public static Iterator<String> getHeaderNames(Message message) throws JMSException {
Enumeration properties = message.getPropertyNames();
List results = new ArrayList();
List<String> results = new ArrayList<String>();
while (properties.hasMoreElements()) {
String property = (String) properties.nextElement();
if (property.startsWith(JmsTransportConstants.PROPERTY_PREFIX)) {
@@ -147,14 +147,14 @@ public abstract class JmsTransportUtils {
* Returns an iterator over all the header values of the given message and header name. Delegates to {@link
* #headerToJmsProperty(String)}.
*/
public static Iterator getHeaders(Message message, String name) throws JMSException {
public static Iterator<String> getHeaders(Message message, String name) throws JMSException {
String propertyName = headerToJmsProperty(name);
String value = message.getStringProperty(propertyName);
if (value != null) {
return Collections.singletonList(value).iterator();
}
else {
return Collections.EMPTY_LIST.iterator();
return Collections.<String>emptyList().iterator();
}
}

View File

@@ -134,9 +134,9 @@ public class MailReceiverConnection extends AbstractReceiverConnection {
*/
@Override
protected Iterator getRequestHeaderNames() throws IOException {
protected Iterator<String> getRequestHeaderNames() throws IOException {
try {
List headers = new ArrayList();
List<String> headers = new ArrayList<String>();
Enumeration enumeration = requestMessage.getAllHeaders();
while (enumeration.hasMoreElements()) {
Header header = (Header) enumeration.nextElement();
@@ -150,7 +150,7 @@ public class MailReceiverConnection extends AbstractReceiverConnection {
}
@Override
protected Iterator getRequestHeaders(String name) throws IOException {
protected Iterator<String> getRequestHeaders(String name) throws IOException {
try {
String[] headers = requestMessage.getHeader(name);
return Arrays.asList(headers).iterator();

View File

@@ -45,9 +45,6 @@ import javax.mail.internet.MimeMessage;
import javax.mail.search.HeaderTerm;
import javax.mail.search.SearchTerm;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
import org.springframework.ws.WebServiceMessage;
import org.springframework.ws.transport.AbstractSenderConnection;
@@ -55,6 +52,9 @@ import org.springframework.ws.transport.TransportConstants;
import org.springframework.ws.transport.WebServiceConnection;
import org.springframework.ws.transport.mail.support.MailTransportUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Implementation of {@link WebServiceConnection} that is used for client-side Mail access. Exposes a {@link Message}
* request and response message.
@@ -255,9 +255,9 @@ public class MailSenderConnection extends AbstractSenderConnection {
}
@Override
protected Iterator getResponseHeaderNames() throws IOException {
protected Iterator<String> getResponseHeaderNames() throws IOException {
try {
List headers = new ArrayList();
List<String> headers = new ArrayList<String>();
Enumeration enumeration = responseMessage.getAllHeaders();
while (enumeration.hasMoreElements()) {
Header header = (Header) enumeration.nextElement();
@@ -271,7 +271,7 @@ public class MailSenderConnection extends AbstractSenderConnection {
}
@Override
protected Iterator getResponseHeaders(String name) throws IOException {
protected Iterator<String> getResponseHeaders(String name) throws IOException {
try {
String[] headers = responseMessage.getHeader(name);
return Arrays.asList(headers).iterator();