Merged changes 8933:8939 from 1.0.2 into the trunk

This commit is contained in:
Arjen Poutsma
2007-11-06 19:09:06 +00:00
parent b4e08ec797
commit d7e4b78bea
11 changed files with 176 additions and 109 deletions

View File

@@ -15,12 +15,12 @@
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-oxm</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>

View File

@@ -16,37 +16,6 @@
package org.springframework.oxm.jaxb;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.Map;
import java.util.UUID;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.attachment.AttachmentMarshaller;
import javax.xml.bind.attachment.AttachmentUnmarshaller;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.validation.Schema;
import org.springframework.core.io.Resource;
import org.springframework.oxm.GenericMarshaller;
import org.springframework.oxm.GenericUnmarshaller;
@@ -54,14 +23,39 @@ import org.springframework.oxm.XmlMappingException;
import org.springframework.oxm.mime.MimeContainer;
import org.springframework.oxm.mime.MimeMarshaller;
import org.springframework.oxm.mime.MimeUnmarshaller;
import org.springframework.util.ClassUtils;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.*;
import org.springframework.xml.transform.StaxResult;
import org.springframework.xml.transform.StaxSource;
import org.springframework.xml.validation.SchemaLoaderUtils;
import javax.activation.DataHandler;
import javax.activation.DataSource;
import javax.xml.XMLConstants;
import javax.xml.bind.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.attachment.AttachmentMarshaller;
import javax.xml.bind.attachment.AttachmentUnmarshaller;
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.validation.Schema;
import java.awt.*;
import java.io.*;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;
/**
* Implementation of the <code>Marshaller</code> interface for JAXB 2.0.
* <p/>
@@ -129,7 +123,9 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
this.jaxbContextProperties = jaxbContextProperties;
}
/** Sets the <code>Marshaller.Listener</code> to be registered with the JAXB <code>Marshaller</code>. */
/**
* Sets the <code>Marshaller.Listener</code> to be registered with the JAXB <code>Marshaller</code>.
*/
public void setMarshallerListener(Marshaller.Listener marshallerListener) {
this.marshallerListener = marshallerListener;
}
@@ -152,17 +148,23 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
this.schemaLanguage = schemaLanguage;
}
/** Sets the schema resource to use for validation. */
/**
* Sets the schema resource to use for validation.
*/
public void setSchema(Resource schemaResource) {
schemaResources = new Resource[]{schemaResource};
}
/** Sets the schema resources to use for validation. */
/**
* Sets the schema resources to use for validation.
*/
public void setSchemas(Resource[] schemaResources) {
this.schemaResources = schemaResources;
}
/** Sets the <code>Unmarshaller.Listener</code> to be registered with the JAXB <code>Unmarshaller</code>. */
/**
* Sets the <code>Unmarshaller.Listener</code> to be registered with the JAXB <code>Unmarshaller</code>.
*/
public void setUnmarshallerListener(Unmarshaller.Listener unmarshallerListener) {
this.unmarshallerListener = unmarshallerListener;
}
@@ -170,27 +172,58 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
public boolean supports(Type type) {
if (type instanceof Class) {
return supportsInternal((Class) type, true);
}
else if (type instanceof ParameterizedType) {
} else if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType) type;
if (JAXBElement.class.equals(parameterizedType.getRawType())) {
Type[] typeArguments = parameterizedType.getActualTypeArguments();
for (int i = 0; i < typeArguments.length; i++) {
if (typeArguments[i] instanceof Class) {
if (!supportsInternal((Class) typeArguments[i], false)) {
return false;
}
}
else if (!supports(typeArguments[i])) {
Assert.isTrue(parameterizedType.getActualTypeArguments().length == 1,
"Invalid amount of parameterized types in JAXBElement");
Type typeArgument = parameterizedType.getActualTypeArguments()[0];
if (typeArgument instanceof Class) {
Class clazz = (Class) typeArgument;
if (!isPrimitiveType(clazz) && !isStandardType(clazz) && !supportsInternal(clazz, false)) {
return false;
}
}
else if (typeArgument instanceof GenericArrayType) {
GenericArrayType genericArrayType = (GenericArrayType) typeArgument;
return genericArrayType.getGenericComponentType().equals(Byte.TYPE);
} else if (!supports(typeArgument)) {
return false;
}
return true;
}
}
return false;
}
private boolean isPrimitiveType(Class clazz) {
return (Boolean.class.equals(clazz) ||
Byte.class.equals(clazz) ||
Short.class.equals(clazz) ||
Integer.class.equals(clazz) ||
Long.class.equals(clazz) ||
Float.class.equals(clazz) ||
Double.class.equals(clazz) ||
byte[].class.equals(clazz));
}
private boolean isStandardType(Class clazz) {
return (String.class.equals(clazz) ||
BigInteger.class.equals(clazz) ||
BigDecimal.class.equals(clazz) ||
Calendar.class.isAssignableFrom(clazz) ||
Date.class.isAssignableFrom(clazz) ||
QName.class.equals(clazz) ||
URI.class.equals(clazz) ||
XMLGregorianCalendar.class.isAssignableFrom(clazz) ||
Duration.class.isAssignableFrom(clazz) ||
Object.class.equals(clazz) ||
Image.class.isAssignableFrom(clazz) ||
DataHandler.class.equals(clazz) ||
Source.class.isAssignableFrom(clazz) ||
UUID.class.equals(clazz));
}
public boolean supports(Class clazz) {
return supportsInternal(clazz, true);
}
@@ -216,8 +249,7 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
}
}
return false;
}
else if (!ObjectUtils.isEmpty(classesToBeBound)) {
} else if (!ObjectUtils.isEmpty(classesToBeBound)) {
return Arrays.asList(classesToBeBound).contains(clazz);
}
return false;
@@ -244,11 +276,9 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
}
if (StringUtils.hasLength(getContextPath())) {
return createJaxbContextFromContextPath();
}
else if (!ObjectUtils.isEmpty(classesToBeBound)) {
} else if (!ObjectUtils.isEmpty(classesToBeBound)) {
return createJaxbContextFromClasses();
}
else {
} else {
throw new IllegalArgumentException("setting either contextPath or classesToBeBound is required");
}
}
@@ -260,8 +290,7 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
if (jaxbContextProperties != null) {
return JAXBContext
.newInstance(getContextPath(), ClassUtils.getDefaultClassLoader(), jaxbContextProperties);
}
else {
} else {
return JAXBContext.newInstance(getContextPath());
}
}
@@ -273,8 +302,7 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
}
if (jaxbContextProperties != null) {
return JAXBContext.newInstance(classesToBeBound, jaxbContextProperties);
}
else {
} else {
return JAXBContext.newInstance(classesToBeBound);
}
}
@@ -327,8 +355,7 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
}
if (result instanceof StaxResult) {
marshalStaxResult(marshaller, graph, (StaxResult) result);
}
else {
} else {
marshaller.marshal(graph, result);
}
}
@@ -341,11 +368,9 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
throws JAXBException {
if (staxResult.getXMLStreamWriter() != null) {
jaxbMarshaller.marshal(graph, staxResult.getXMLStreamWriter());
}
else if (staxResult.getXMLEventWriter() != null) {
} else if (staxResult.getXMLEventWriter() != null) {
jaxbMarshaller.marshal(graph, staxResult.getXMLEventWriter());
}
else {
} else {
throw new IllegalArgumentException("StaxResult contains neither XMLStreamWriter nor XMLEventConsumer");
}
}
@@ -366,8 +391,7 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
}
if (source instanceof StaxSource) {
return unmarshalStaxSource(unmarshaller, (StaxSource) source);
}
else {
} else {
return unmarshaller.unmarshal(source);
}
}
@@ -379,11 +403,9 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller
private Object unmarshalStaxSource(Unmarshaller jaxbUnmarshaller, StaxSource staxSource) throws JAXBException {
if (staxSource.getXMLStreamReader() != null) {
return jaxbUnmarshaller.unmarshal(staxSource.getXMLStreamReader());
}
else if (staxSource.getXMLEventReader() != null) {
} else if (staxSource.getXMLEventReader() != null) {
return jaxbUnmarshaller.unmarshal(staxSource.getXMLEventReader());
}
else {
} else {
throw new IllegalArgumentException("StaxSource contains neither XMLStreamReader nor XMLEventReader");
}
}

View File

@@ -16,24 +16,6 @@
package org.springframework.oxm.jaxb;
import java.io.ByteArrayOutputStream;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.util.Collections;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Result;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import org.custommonkey.xmlunit.XMLTestCase;
import static org.easymock.EasyMock.*;
import org.springframework.core.io.ClassPathResource;
@@ -53,6 +35,36 @@ import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.Duration;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import java.awt.*;
import java.io.ByteArrayOutputStream;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URI;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.UUID;
public class Jaxb2MarshallerTest extends XMLTestCase {
private static final String CONTEXT_PATH = "org.springframework.oxm.jaxb2";
@@ -223,6 +235,27 @@ public class Jaxb2MarshallerTest extends XMLTestCase {
assertFalse("Jaxb2Marshaller supports wrong JAXBElement", marshaller.supports(testElement.getClass()));
}
public void testSupportsPrimitives() throws Exception {
Method primitives = getClass().getDeclaredMethod("primitives", JAXBElement.class, JAXBElement.class, JAXBElement.class,
JAXBElement.class, JAXBElement.class, JAXBElement.class, JAXBElement.class, JAXBElement.class);
Type[] types = primitives.getGenericParameterTypes();
for (int i = 0; i < types.length; i++) {
ParameterizedType type = (ParameterizedType) types[i];
assertTrue("Jaxb2Marshaller does not support " + type, marshaller.supports(types[i]));
}
}
public void testSupportsStandards() throws Exception {
Method standards = getClass().getDeclaredMethod("standards", JAXBElement.class, JAXBElement.class, JAXBElement.class,
JAXBElement.class, JAXBElement.class, JAXBElement.class, JAXBElement.class, JAXBElement.class, JAXBElement.class, JAXBElement.class,
JAXBElement.class, JAXBElement.class, JAXBElement.class, JAXBElement.class);
Type[] types = standards.getGenericParameterTypes();
for (int i = 0; i < types.length; i++) {
ParameterizedType type = (ParameterizedType) types[i];
assertTrue("Jaxb2Marshaller does not support " + type, marshaller.supports(types[i]));
}
}
public void testMarshalAttachments() throws Exception {
marshaller = new Jaxb2Marshaller();
marshaller.setClassesToBeBound(new Class[]{BinaryObject.class});
@@ -245,4 +278,16 @@ public class Jaxb2MarshallerTest extends XMLTestCase {
verify(mimeContainer);
assertTrue("No XML written", result.toString().length() > 0);
}
private void primitives(JAXBElement<Boolean> bool, JAXBElement<Byte> aByte, JAXBElement<Short> aShort,
JAXBElement<Integer> anInteger, JAXBElement<Long> aLong, JAXBElement<Float> aFloat,
JAXBElement<Double> aDouble, JAXBElement<byte[]> byteArray) {
}
private void standards(JAXBElement<String> string, JAXBElement<BigInteger> integer, JAXBElement<BigDecimal> decimal,
JAXBElement<Calendar> calendar, JAXBElement<Date> date, JAXBElement<QName> qName,
JAXBElement<URI> uri, JAXBElement<XMLGregorianCalendar> xmlGregorianCalendar,
JAXBElement<Duration> duration, JAXBElement<Object> object, JAXBElement<Image> image,
JAXBElement<DataHandler> dataHandler, JAXBElement<Source> source, JAXBElement<UUID> uuid) {
}
}

View File

@@ -1,4 +1,4 @@
SPRING WEB SERVICES 1.0.1 (September 2007)
SPRING WEB SERVICES 1.0.2 (November 2007)
-------------------------------
http://www.springframework.org/spring-ws
http://forum.springframework.org/forumdisplay.php?f=39
@@ -37,30 +37,30 @@ The following distinct jar files are included in the distribution. This list spe
third-party dependencies. Libraries in [brackets] are optional, i.e. just necessary for certain functionality. For an
exact list of Spring-WS project dependencies see the respective Maven2 pom.xml files.
* spring-oxm-1.0.1.jar
* spring-oxm-1.0.2.jar
- Contents: The Spring Object/XML Mapping framework
- Dependencies: Commons Logging, spring-beans, spring-core
[Log4J, JAXB 1, Castor, XMLBeans, StAX, JiBX, XStream]
* spring-oxm-tiger-1.0.1.jar
* spring-oxm-tiger-1.0.2.jar
- Contents: The Spring Object/XML Mapping framework for Java 5
- Dependencies: Commons Logging, spring-beans, spring-core, JAXB 2
* spring-ws-core-1.0.1.jar
* spring-ws-core-1.0.2.jar
- Contents: The Spring-WS Core
- Dependencies: Commons Logging, spring-beans, spring-core, spring-context, spring-oxm
[Log4J, spring-web, spring-webmvc, SAAJ, JDOM, StAX, Servlet API, JAF, Axiom, DOM4J, XOM]
* spring-ws-core-tiger-1.0.1.jar
* spring-ws-core-tiger-1.0.2.jar
- Contents: The Spring-WS Core for Java 5
- Dependencies: Commons Logging, spring-beans, spring-core, spring-context, spring-core
* spring-ws-security-1.0.1.jar
* spring-ws-security-1.0.2.jar
- Contents: Spring-WS Security integration
- Dependencies: Commons Logging, spring-beans, spring-core, spring-context, spring-ws-core
[Log4J, xmlsdig, xmlsec, XWS-security, Acegi]
* spring-xml-1.0.1.jar
* spring-xml-1.0.2.jar
- Contents: Spring XML utility framework
- Dependencies: Commons Logging, spring-beans, spring-core
[StAX, Xalan, Jaxen]

View File

@@ -14,7 +14,7 @@
</typedef>
<artifact:dependencies pathId="classpath">
<dependency groupId="org.springframework.ws" artifactId="spring-ws-core" version="1.0.1"/>
<dependency groupId="org.springframework.ws" artifactId="spring-ws-core" version="1.0.2"/>
<dependency groupId="com.sun.xml.messaging.saaj" artifactId="saaj-impl" version="1.3"/>
<dependency groupId="commons-httpclient" artifactId="commons-httpclient" version="3.0.1"/>
<dependency groupId="commons-httpclient" artifactId="commons-httpclient" version="3.0.1"/>

View File

@@ -12,7 +12,7 @@
</typedef>
<artifact:dependencies pathId="classpath">
<dependency groupId="org.springframework.ws" artifactId="spring-ws-core" version="1.0.1"/>
<dependency groupId="org.springframework.ws" artifactId="spring-ws-core" version="1.0.2"/>
<dependency groupId="com.sun.xml.messaging.saaj" artifactId="saaj-impl" version="1.3"/>
<dependency groupId="commons-httpclient" artifactId="commons-httpclient" version="3.0.1"/>
</artifact:dependencies>

View File

@@ -10,7 +10,7 @@
<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping"/>
<bean class="org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter">
<bean class="org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter">
<constructor-arg ref="marshaller"/>
</bean>

View File

@@ -3,7 +3,7 @@
<parent>
<artifactId>spring-ws</artifactId>
<groupId>org.springframework.ws</groupId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-ws-sandbox</artifactId>

View File

@@ -474,7 +474,7 @@
</para>
<screen>mvn archetype:create -DarchetypeGroupId=org.springframework.ws \
-DarchetypeArtifactId=spring-ws-archetype \
-DarchetypeVersion=1.0.1 \
-DarchetypeVersion=1.0.2 \
-DgroupId=com.mycompany.hr \
-DartifactId=holidayService
</screen>
@@ -634,7 +634,7 @@ public class HolidayEndpoint extends AbstractJDomPayloadEndpoint {
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>jdom</groupId>

View File

@@ -6,11 +6,11 @@ Downloads
* Get the latest Spring Web Services releases here
* <<Spring-WS 1.0.1 is the current production release>>
* <<Spring-WS 1.0.2 is the current production release>>
* {{{http://sourceforge.net/project/showfiles.php?group_id=73357&package_id=178569&release_id=542737}Download}} | {{{http://static.springframework.org/spring-ws/docs/1.0.1/changelog.txt}Changelog}} | {{{http://forum.springframework.org/showthread.php?t=44351}Announcement}}
* {{{http://sourceforge.net/project/showfiles.php?group_id=73357&package_id=178569&release_id=552258}Download}} | {{{http://static.springframework.org/spring-ws/docs/1.0.2/changelog.txt}Changelog}} | {{{http://forum.springframework.org/showthread.php?t=45879}Announcement}}
* <<Spring-WS 1.0.2 is the upcoming development release>>
* <<Spring-WS 1.0.3 is the upcoming development release>>
* {{{snapshots.html}Download nighly snapshots}}

View File

@@ -23,10 +23,10 @@ Snapshot Builds
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>1.0.2-SNAPSHOT</version>
<version>1.0.3-SNAPSHOT</version>
</dependency>
+---------------
Additionally, there are
{{{http://s3browse.com/explore/maven.springframework.org/snapshot/org/springframework/ws/spring-ws/1.0.2-SNAPSHOT/}zips}}
{{{http://s3browse.com/explore/maven.springframework.org/snapshot/org/springframework/ws/spring-ws/1.0.3-SNAPSHOT/}zips}}
available which contain all jars. Make sure to click 'Next >' a couple of times to get the most recent snapshots.