Moved SAAJ 1.2 and 1.3 implementation into separate packages.

This commit is contained in:
Arjen Poutsma
2006-10-15 15:01:11 +00:00
parent ea17660308
commit db482346d2
20 changed files with 108 additions and 100 deletions

View File

@@ -1,49 +0,0 @@
/*
* Copyright 2006 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.ws.soap.saaj;
import javax.xml.soap.MessageFactory;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
/**
* Spring <code>FactoryBean</code> for SAAJ <code>MessageFactory</code> objects.
*
* @author Arjen Poutsma
* @see javax.xml.soap.MessageFactory
*/
public class SaajMessageFactoryBean implements FactoryBean, InitializingBean {
private MessageFactory messageFactory;
public Object getObject() throws Exception {
return messageFactory;
}
public Class getObjectType() {
return MessageFactory.class;
}
public boolean isSingleton() {
return true;
}
public void afterPropertiesSet() throws Exception {
messageFactory = MessageFactory.newInstance();
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright 2006 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.ws.soap.saaj;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapEnvelope;
/**
* Abstract base class for implementations of the <code>SoapEnvelope</code> interface that use SAAJ. Used by
* <code>SaajSoapMessage</code>.
*
* @author Arjen Poutsma
*/
public abstract class SaajSoapEnvelope implements SoapEnvelope {
private final SOAPEnvelope saajEnvelope;
protected SaajSoapEnvelope(SOAPEnvelope saajEnvelope) {
Assert.notNull(saajEnvelope, "No saajEnvelope given");
this.saajEnvelope = saajEnvelope;
}
protected SOAPEnvelope getSaajEnvelope() {
return saajEnvelope;
}
public Source getSource() {
return new DOMSource(saajEnvelope);
}
}

View File

@@ -39,6 +39,8 @@ import org.springframework.ws.soap.Attachment;
import org.springframework.ws.soap.AttachmentException;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapVersion;
import org.springframework.ws.soap.saaj.saaj12.Saaj12SoapEnvelope;
import org.springframework.ws.soap.saaj.saaj13.Saaj13SoapEnvelope;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
@@ -53,7 +55,7 @@ public class SaajSoapMessage extends AbstractSoapMessage {
private final SOAPMessage saajMessage;
private SoapEnvelope envelope;
private SaajSoapEnvelope envelope;
/**
* Create a new <code>SaajSoapMessage</code> based on the given SAAJ <code>SOAPMessage</code>.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import java.util.Iterator;
import java.util.Locale;
@@ -33,6 +33,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import java.util.Locale;
import javax.xml.namespace.QName;
@@ -26,6 +26,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
import org.springframework.ws.soap.soap11.Soap11Fault;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPEnvelope;
@@ -22,10 +22,11 @@ import javax.xml.soap.SOAPException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.saaj.SaajSoapBodyException;
import org.springframework.ws.soap.saaj.SaajSoapEnvelope;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**
@@ -34,31 +35,29 @@ import org.springframework.ws.soap.saaj.support.SaajUtils;
*
* @author Arjen Poutsma
*/
class Saaj12SoapEnvelope implements SoapEnvelope {
private final SOAPEnvelope saajEnvelope;
public class Saaj12SoapEnvelope extends SaajSoapEnvelope {
private Saaj12SoapHeader header;
private Saaj12Soap11Body body;
Saaj12SoapEnvelope(SOAPEnvelope saajEnvelope) {
Assert.notNull(saajEnvelope, "No saajEnvelope given");
this.saajEnvelope = saajEnvelope;
public Saaj12SoapEnvelope(SOAPEnvelope saajEnvelope) {
super(saajEnvelope);
}
public QName getName() {
return SaajUtils.toQName(saajEnvelope.getElementName());
return SaajUtils.toQName(getSaajEnvelope().getElementName());
}
public Source getSource() {
return new DOMSource(saajEnvelope);
return new DOMSource(getSaajEnvelope());
}
public SoapHeader getHeader() {
if (header != null) {
try {
header = saajEnvelope.getHeader() != null ? new Saaj12SoapHeader(saajEnvelope.getHeader()) : null;
header = getSaajEnvelope().getHeader() != null ? new Saaj12SoapHeader(getSaajEnvelope().getHeader()) :
null;
}
catch (SOAPException ex) {
throw new SaajSoapHeaderException(ex);
@@ -70,7 +69,7 @@ class Saaj12SoapEnvelope implements SoapEnvelope {
public SoapBody getBody() {
if (body == null) {
try {
body = new Saaj12Soap11Body(saajEnvelope.getBody());
body = new Saaj12Soap11Body(getSaajEnvelope().getBody());
}
catch (SOAPException ex) {
throw new SaajSoapBodyException(ex);

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import java.util.Iterator;
import javax.xml.namespace.QName;
@@ -31,6 +31,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.SoapFaultDetailElement;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.namespace.QName;
import javax.xml.soap.DetailEntry;
@@ -26,6 +26,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetailElement;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import java.util.Iterator;
import javax.xml.namespace.QName;
@@ -29,6 +29,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj12;
import javax.xml.namespace.QName;
import javax.xml.soap.Name;
@@ -29,6 +29,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
import org.springframework.ws.soap.saaj.support.SaajUtils;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Locale;
import javax.xml.namespace.QName;
@@ -25,6 +25,7 @@ import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap11.Soap11Body;
import org.springframework.ws.soap.soap11.Soap11Fault;
import org.springframework.xml.namespace.QNameUtils;
@@ -82,13 +83,12 @@ class Saaj13Soap11Body extends Saaj13SoapBody implements Soap11Body {
private Soap11Fault addStandardFault(String localName, String faultString, Locale faultStringLocale) {
try {
QName faultCode = QNameUtils.createQName(saajBody.getElementQName().getNamespaceURI(),
localName,
QName faultCode = QNameUtils.createQName(saajBody.getElementQName().getNamespaceURI(), localName,
QNameUtils.getPrefix(saajBody.getElementQName()));
saajBody.removeContents();
SOAPFault saajFault = faultStringLocale == null ? saajBody.addFault(faultCode, faultString) :
saajBody.addFault(faultCode, faultString, faultStringLocale);
return new Saaj12Soap11Fault(saajFault);
return new Saaj13Soap11Fault(saajFault);
}
catch (SOAPException ex) {
throw new SaajSoapFaultException(ex);

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Locale;
import javax.xml.namespace.QName;
@@ -26,6 +26,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap11.Soap11Fault;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Locale;
import javax.xml.namespace.QName;
@@ -26,6 +26,7 @@ import javax.xml.soap.SOAPFault;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap12.Soap12Body;
import org.springframework.ws.soap.soap12.Soap12Fault;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Iterator;
import java.util.Locale;
@@ -26,6 +26,7 @@ import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
import org.springframework.ws.soap.soap12.Soap12Fault;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
@@ -22,6 +22,7 @@ import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
import org.springframework.ws.soap.soap12.Soap12Header;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Iterator;
import javax.xml.namespace.QName;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
@@ -22,13 +22,14 @@ import javax.xml.soap.SOAPConstants;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapBody;
import org.springframework.ws.soap.SoapEnvelope;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.saaj.SaajSoapBodyException;
import org.springframework.ws.soap.saaj.SaajSoapEnvelope;
import org.springframework.ws.soap.saaj.SaajSoapEnvelopeException;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>SoapEnvelope</code> interface. Used by
@@ -36,36 +37,30 @@ import org.springframework.ws.soap.SoapHeader;
*
* @author Arjen Poutsma
*/
class Saaj13SoapEnvelope implements SoapEnvelope {
private final SOAPEnvelope saajEnvelope;
public class Saaj13SoapEnvelope extends SaajSoapEnvelope {
private Saaj13SoapHeader header;
private Saaj13SoapBody body;
Saaj13SoapEnvelope(SOAPEnvelope saajEnvelope) {
public Saaj13SoapEnvelope(SOAPEnvelope saajEnvelope) {
super(saajEnvelope);
Assert.notNull(saajEnvelope, "No saajEnvelope given");
this.saajEnvelope = saajEnvelope;
}
public QName getName() {
return saajEnvelope.getElementQName();
}
public Source getSource() {
return new DOMSource(saajEnvelope);
return getSaajEnvelope().getElementQName();
}
public SoapHeader getHeader() {
if (header == null) {
try {
if (saajEnvelope.getHeader() == null) {
if (getSaajEnvelope().getHeader() == null) {
return null;
}
else {
SOAPHeader saajHeader = saajEnvelope.getHeader();
String namespaceURI = saajEnvelope.getElementQName().getNamespaceURI();
SOAPHeader saajHeader = getSaajEnvelope().getHeader();
String namespaceURI = getSaajEnvelope().getElementQName().getNamespaceURI();
if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) {
header = new Saaj13SoapHeader(saajHeader);
}
@@ -87,8 +82,8 @@ class Saaj13SoapEnvelope implements SoapEnvelope {
public SoapBody getBody() {
if (body == null) {
try {
SOAPBody saajBody = saajEnvelope.getBody();
String namespaceURI = saajEnvelope.getElementQName().getNamespaceURI();
SOAPBody saajBody = getSaajEnvelope().getBody();
String namespaceURI = getSaajEnvelope().getElementQName().getNamespaceURI();
if (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespaceURI)) {
body = new Saaj13Soap11Body(saajBody);
}

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Iterator;
import javax.xml.namespace.QName;
@@ -29,6 +29,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapFaultDetail;
import org.springframework.ws.soap.SoapFaultDetailElement;
import org.springframework.ws.soap.saaj.SaajSoapFaultException;
/**
* @author Arjen Poutsma

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import java.util.Iterator;
import javax.xml.namespace.QName;
@@ -27,6 +27,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeader;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>SoapHeader</code> interface.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.ws.soap.saaj;
package org.springframework.ws.soap.saaj.saaj13;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPException;
@@ -27,6 +27,7 @@ import javax.xml.transform.dom.DOMSource;
import org.springframework.util.Assert;
import org.springframework.ws.soap.SoapHeaderElement;
import org.springframework.ws.soap.SoapHeaderException;
import org.springframework.ws.soap.saaj.SaajSoapHeaderException;
/**
* Internal class that uses SAAJ 1.3 to implement the <code>SoapHeaderElement</code> interface.