diff --git a/archetype/src/main/resources/archetype-resources/pom.xml b/archetype/src/main/resources/archetype-resources/pom.xml index ec5d04be..df6b65a4 100644 --- a/archetype/src/main/resources/archetype-resources/pom.xml +++ b/archetype/src/main/resources/archetype-resources/pom.xml @@ -15,12 +15,12 @@ org.springframework.ws spring-oxm - 1.0.1 + 1.0.2 org.springframework.ws spring-ws-core - 1.0.1 + 1.0.2 diff --git a/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 5c4bcfad..d825aaf4 100644 --- a/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -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 Marshaller interface for JAXB 2.0. *

@@ -129,7 +123,9 @@ public class Jaxb2Marshaller extends AbstractJaxbMarshaller this.jaxbContextProperties = jaxbContextProperties; } - /** Sets the Marshaller.Listener to be registered with the JAXB Marshaller. */ + /** + * Sets the Marshaller.Listener to be registered with the JAXB Marshaller. + */ 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 Unmarshaller.Listener to be registered with the JAXB Unmarshaller. */ + /** + * Sets the Unmarshaller.Listener to be registered with the JAXB Unmarshaller. + */ 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"); } } diff --git a/oxm-tiger/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTest.java b/oxm-tiger/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTest.java index 5560c86e..fdae544d 100644 --- a/oxm-tiger/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTest.java +++ b/oxm-tiger/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTest.java @@ -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 bool, JAXBElement aByte, JAXBElement aShort, + JAXBElement anInteger, JAXBElement aLong, JAXBElement aFloat, + JAXBElement aDouble, JAXBElement byteArray) { + } + + private void standards(JAXBElement string, JAXBElement integer, JAXBElement decimal, + JAXBElement calendar, JAXBElement date, JAXBElement qName, + JAXBElement uri, JAXBElement xmlGregorianCalendar, + JAXBElement duration, JAXBElement object, JAXBElement image, + JAXBElement dataHandler, JAXBElement source, JAXBElement uuid) { + } } diff --git a/readme.txt b/readme.txt index f2c502c5..b7192c31 100644 --- a/readme.txt +++ b/readme.txt @@ -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] diff --git a/samples/airline/client/spring-ws/build.xml b/samples/airline/client/spring-ws/build.xml index dd39706d..7926329d 100644 --- a/samples/airline/client/spring-ws/build.xml +++ b/samples/airline/client/spring-ws/build.xml @@ -14,7 +14,7 @@ - + diff --git a/samples/echo/client/spring-ws/build.xml b/samples/echo/client/spring-ws/build.xml index 30d04ad7..1e557398 100644 --- a/samples/echo/client/spring-ws/build.xml +++ b/samples/echo/client/spring-ws/build.xml @@ -12,7 +12,7 @@ - + diff --git a/samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml b/samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml index acd04225..2915d8e5 100644 --- a/samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml +++ b/samples/mtom/src/main/webapp/WEB-INF/spring-ws-servlet.xml @@ -10,7 +10,7 @@ - + diff --git a/sandbox/pom.xml b/sandbox/pom.xml index 0b71da12..18c3c524 100644 --- a/sandbox/pom.xml +++ b/sandbox/pom.xml @@ -3,7 +3,7 @@ spring-ws org.springframework.ws - 1.0.2-SNAPSHOT + 1.0.3-SNAPSHOT 4.0.0 spring-ws-sandbox diff --git a/src/docbkx/tutorial.xml b/src/docbkx/tutorial.xml index 00360ec1..7afbb0be 100644 --- a/src/docbkx/tutorial.xml +++ b/src/docbkx/tutorial.xml @@ -474,7 +474,7 @@ 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 @@ -634,7 +634,7 @@ public class HolidayEndpoint extends AbstractJDomPayloadEndpoint { org.springframework.ws spring-ws-core - 1.0.1 + 1.0.2 jdom diff --git a/src/site/apt/downloads/releases.apt b/src/site/apt/downloads/releases.apt index 568997ef..171202a8 100644 --- a/src/site/apt/downloads/releases.apt +++ b/src/site/apt/downloads/releases.apt @@ -6,11 +6,11 @@ Downloads * Get the latest Spring Web Services releases here - * <> + * <> - * {{{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}} - * <> + * <> * {{{snapshots.html}Download nighly snapshots}} diff --git a/src/site/apt/downloads/snapshots.apt b/src/site/apt/downloads/snapshots.apt index c5260d13..c8abc9c9 100644 --- a/src/site/apt/downloads/snapshots.apt +++ b/src/site/apt/downloads/snapshots.apt @@ -23,10 +23,10 @@ Snapshot Builds org.springframework.ws spring-ws-core - 1.0.2-SNAPSHOT + 1.0.3-SNAPSHOT +--------------- 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.