Got rid of circular package dependency between saaj & saaj.support

This commit is contained in:
Arjen Poutsma
2010-05-06 11:24:01 +00:00
parent b9d93cb3c8
commit a7323de799
2 changed files with 20 additions and 18 deletions

View File

@@ -170,8 +170,17 @@ public class SaajSoapMessage extends AbstractSoapMessage {
}
}
private int getSaajVersion() {
try {
return SaajUtils.getSaajVersion(saajMessage);
}
catch (SOAPException ex) {
throw new SaajSoapEnvelopeException("Could not access envelope: " + ex.getMessage(), ex);
}
}
public boolean isXopPackage() {
if (SaajUtils.getSaajVersion(saajMessage) >= SaajUtils.SAAJ_13) {
if (getSaajVersion() >= SaajUtils.SAAJ_13) {
SOAPPart saajPart = saajMessage.getSOAPPart();
String[] contentTypes = saajPart.getMimeHeader(TransportConstants.HEADER_CONTENT_TYPE);
for (String contentType : contentTypes) {
@@ -184,7 +193,7 @@ public class SaajSoapMessage extends AbstractSoapMessage {
}
public boolean convertToXopPackage() {
if (SaajUtils.getSaajVersion(saajMessage) >= SaajUtils.SAAJ_13) {
if (getSaajVersion() >= SaajUtils.SAAJ_13) {
convertMessageToXop();
convertPartToXop();
return true;
@@ -248,13 +257,14 @@ public class SaajSoapMessage extends AbstractSoapMessage {
protected final SaajImplementation getImplementation() {
if (implementation == null) {
if (SaajUtils.getSaajVersion(saajMessage) == SaajUtils.SAAJ_13) {
int saajVersion = getSaajVersion();
if (saajVersion == SaajUtils.SAAJ_13) {
implementation = Saaj13Implementation.getInstance();
}
else if (SaajUtils.getSaajVersion(saajMessage) == SaajUtils.SAAJ_12) {
else if (saajVersion == SaajUtils.SAAJ_12) {
implementation = Saaj12Implementation.getInstance();
}
else if (SaajUtils.getSaajVersion(saajMessage) == SaajUtils.SAAJ_11) {
else if (saajVersion == SaajUtils.SAAJ_11) {
implementation = Saaj11Implementation.getInstance();
}
else {

View File

@@ -20,10 +20,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
@@ -38,7 +37,6 @@ import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.ws.soap.saaj.SaajSoapMessageException;
import org.springframework.ws.transport.TransportConstants;
import org.springframework.xml.namespace.QNameUtils;
@@ -71,7 +69,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<String, Integer> saajVersions = Collections.synchronizedMap(new HashMap<String, Integer>());
private static final Map<String, Integer> saajVersions = new ConcurrentHashMap<String, Integer>();
private static int saajVersion = SAAJ_12;
@@ -89,7 +87,7 @@ public abstract class SaajUtils {
private static boolean isSaaj13() {
try {
ClassUtils.forName(SAAJ_13_CLASS_NAME);
ClassUtils.forName(SAAJ_13_CLASS_NAME, SaajUtils.class.getClassLoader());
MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
return true;
}
@@ -152,15 +150,9 @@ public abstract class SaajUtils {
* @see #SAAJ_12
* @see #SAAJ_13
*/
public static int getSaajVersion(SOAPMessage soapMessage) {
public static int getSaajVersion(SOAPMessage soapMessage) throws SOAPException {
Assert.notNull(soapMessage, "'soapMessage' must not be null");
SOAPEnvelope soapEnvelope;
try {
soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
}
catch (SOAPException ex) {
throw new SaajSoapMessageException("Could not access envelope: " + ex.getMessage(), ex);
}
SOAPEnvelope soapEnvelope = soapMessage.getSOAPPart().getEnvelope();
return getSaajVersion(soapEnvelope);
}