Skip to content

Commit 9fae822

Browse files
committed
[maven-release-plugin] copy for tag spring-ws-1.0.2
2 parents 7951d79 + cf00834 commit 9fae822

File tree

97 files changed

+7511
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+7511
-6
lines changed

oxm-tiger/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,13 @@ private boolean supportsInternal(Class<?> clazz, boolean checkForXmlRootElement)
209209
return false;
210210
}
211211
String packageName = className.substring(0, lastDotIndex);
212-
return getContextPath().startsWith(packageName);
212+
String[] contextPaths = StringUtils.tokenizeToStringArray(getContextPath(), ":");
213+
for (int i = 0; i < contextPaths.length; i++) {
214+
if (contextPaths[i].equals(packageName)) {
215+
return true;
216+
}
217+
}
218+
return false;
213219
}
214220
else if (!ObjectUtils.isEmpty(classesToBeBound)) {
215221
return Arrays.asList(classesToBeBound).contains(clazz);

oxm-tiger/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,23 @@ public void testMarshalSaxResult() throws Exception {
194194
verify(handlerMock);
195195
}
196196

197-
public void testSupports() throws Exception {
197+
public void testSupportsContextPath() throws Exception {
198+
Method createFlights = ObjectFactory.class.getDeclaredMethod("createFlights");
199+
assertTrue("Jaxb2Marshaller does not support Flights",
200+
marshaller.supports(createFlights.getGenericReturnType()));
201+
Method createFlight = ObjectFactory.class.getDeclaredMethod("createFlight", FlightType.class);
202+
assertTrue("Jaxb2Marshaller does not support JAXBElement<FlightsType>",
203+
marshaller.supports(createFlight.getGenericReturnType()));
204+
assertFalse("Jaxb2Marshaller supports non-parameterized JAXBElement", marshaller.supports(JAXBElement.class));
205+
JAXBElement<Jaxb2MarshallerTest> testElement =
206+
new JAXBElement<Jaxb2MarshallerTest>(new QName("something"), Jaxb2MarshallerTest.class, null, this);
207+
assertFalse("Jaxb2Marshaller supports wrong JAXBElement", marshaller.supports(testElement.getClass()));
208+
}
209+
210+
public void testSupportsClassesToBeBound() throws Exception {
211+
marshaller = new Jaxb2Marshaller();
212+
marshaller.setClassesToBeBound(new Class[]{Flights.class, FlightType.class});
213+
marshaller.afterPropertiesSet();
198214
Method createFlights = ObjectFactory.class.getDeclaredMethod("createFlights");
199215
assertTrue("Jaxb2Marshaller does not support Flights",
200216
marshaller.supports(createFlights.getGenericReturnType()));

oxm/src/main/java/org/springframework/oxm/jaxb/AbstractJaxbMarshaller.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.apache.commons.logging.LogFactory;
2929
import org.springframework.beans.factory.InitializingBean;
3030
import org.springframework.oxm.XmlMappingException;
31+
import org.springframework.util.Assert;
32+
import org.springframework.util.StringUtils;
3133

3234
/**
3335
* Abstract base class for implementations of the <code>Marshaller</code> and <code>Unmarshaller</code> interfaces that
@@ -64,9 +66,19 @@ protected String getContextPath() {
6466

6567
/** Sets the JAXB Context path. */
6668
public void setContextPath(String contextPath) {
69+
Assert.notNull(contextPath, "'contextPath' must not be null");
6770
this.contextPath = contextPath;
6871
}
6972

73+
/**
74+
* Sets multiple JAXB Context paths. The given array of context paths is converted to a colon-delimited string, as
75+
* supported by JAXB.
76+
*/
77+
public void setContextPaths(String[] contextPaths) {
78+
Assert.notEmpty(contextPaths, "'contextPaths' must not be empty");
79+
this.contextPath = StringUtils.arrayToDelimitedString(contextPaths, ":");
80+
}
81+
7082
/**
7183
* Sets the JAXB <code>Marshaller</code> properties. These properties will be set on the underlying JAXB
7284
* <code>Marshaller</code>, and allow for features such as indentation.

oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb1Marshaller.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import javax.xml.transform.Result;
2323
import javax.xml.transform.Source;
2424

25-
import org.springframework.beans.factory.InitializingBean;
25+
import org.springframework.util.ClassUtils;
2626
import org.springframework.util.StringUtils;
2727

2828
/**
@@ -38,7 +38,7 @@
3838
* @see #setValidating(boolean)
3939
* @since 1.0.0
4040
*/
41-
public class Jaxb1Marshaller extends AbstractJaxbMarshaller implements InitializingBean {
41+
public class Jaxb1Marshaller extends AbstractJaxbMarshaller {
4242

4343
private boolean validating = false;
4444

@@ -48,7 +48,26 @@ public void setValidating(boolean validating) {
4848
}
4949

5050
public boolean supports(Class clazz) {
51-
return Element.class.isAssignableFrom(clazz);
51+
if (!Element.class.isAssignableFrom(clazz)) {
52+
return false;
53+
}
54+
if (StringUtils.hasLength(getContextPath())) {
55+
String className = ClassUtils.getQualifiedName(clazz);
56+
int lastDotIndex = className.lastIndexOf('.');
57+
if (lastDotIndex == -1) {
58+
return false;
59+
}
60+
String packageName = className.substring(0, lastDotIndex);
61+
String[] contextPaths = StringUtils.tokenizeToStringArray(getContextPath(), ":");
62+
for (int i = 0; i < contextPaths.length; i++) {
63+
if (contextPaths[i].equals(packageName)) {
64+
return true;
65+
}
66+
}
67+
return false;
68+
}
69+
return false;
70+
5271
}
5372

5473
protected final JAXBContext createJaxbContext() throws JAXBException {

oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb1MarshallerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Jaxb1MarshallerTest extends AbstractJaxbMarshallerTestCase {
3131

3232
protected final Marshaller createMarshaller() throws Exception {
3333
Jaxb1Marshaller marshaller = new Jaxb1Marshaller();
34-
marshaller.setContextPath(CONTEXT_PATH);
34+
marshaller.setContextPaths(new String[]{CONTEXT_PATH});
3535
marshaller.afterPropertiesSet();
3636
return marshaller;
3737
}

xml/pom.xml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<parent>
3+
<artifactId>spring-ws</artifactId>
4+
<groupId>org.springframework.ws</groupId>
5+
<version>1.0.2</version>
6+
</parent>
7+
<modelVersion>4.0.0</modelVersion>
8+
<artifactId>spring-xml</artifactId>
9+
<packaging>jar</packaging>
10+
<name>Spring XML</name>
11+
<description>Various XML support classes for Spring Web Services</description>
12+
<reporting>
13+
<plugins>
14+
<plugin>
15+
<artifactId>maven-javadoc-plugin</artifactId>
16+
<configuration>
17+
<stylesheetfile>${basedir}/../src/main/javadoc/javadoc.css</stylesheetfile>
18+
</configuration>
19+
</plugin>
20+
</plugins>
21+
</reporting>
22+
<dependencies>
23+
<!-- XML handling dependencies -->
24+
<dependency>
25+
<groupId>xml-apis</groupId>
26+
<artifactId>xml-apis</artifactId>
27+
<scope>provided</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>stax</groupId>
31+
<artifactId>stax-api</artifactId>
32+
<optional>true</optional>
33+
</dependency>
34+
<dependency>
35+
<groupId>xalan</groupId>
36+
<artifactId>xalan</artifactId>
37+
<scope>provided</scope>
38+
</dependency>
39+
<dependency>
40+
<groupId>xerces</groupId>
41+
<artifactId>xercesImpl</artifactId>
42+
<scope>provided</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>jaxen</groupId>
46+
<artifactId>jaxen</artifactId>
47+
<optional>true</optional>
48+
<exclusions>
49+
<exclusion>
50+
<groupId>dom4j</groupId>
51+
<artifactId>dom4j</artifactId>
52+
</exclusion>
53+
<exclusion>
54+
<groupId>jdom</groupId>
55+
<artifactId>jdom</artifactId>
56+
</exclusion>
57+
<exclusion>
58+
<groupId>xom</groupId>
59+
<artifactId>xom</artifactId>
60+
</exclusion>
61+
<exclusion>
62+
<groupId>xerces</groupId>
63+
<artifactId>xmlParserAPIs</artifactId>
64+
</exclusion>
65+
<exclusion>
66+
<groupId>xerces</groupId>
67+
<artifactId>xercesImpl</artifactId>
68+
</exclusion>
69+
</exclusions>
70+
</dependency>
71+
<dependency>
72+
<groupId>org.codehaus.woodstox</groupId>
73+
<artifactId>wstx-asl</artifactId>
74+
<scope>test</scope>
75+
</dependency>
76+
<!-- Test dependencies -->
77+
<dependency>
78+
<groupId>easymock</groupId>
79+
<artifactId>easymock</artifactId>
80+
<version>1.2_Java1.3</version>
81+
<scope>test</scope>
82+
</dependency>
83+
</dependencies>
84+
</project>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright 2006 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.xml;
18+
19+
import org.springframework.util.ClassUtils;
20+
21+
/**
22+
* Helper class used to find the current version of JAXP. We cannot depend on the Java version, since JAXP can be
23+
* upgraded independently of the Java version.
24+
* <p/>
25+
* Only distinguishes between JAXP 1.0, 1.1, 1.3, and 1.4, since JAXP 1.2 was a maintenance release with no new
26+
* classes.
27+
*
28+
* @author Arjen Poutsma
29+
* @since 1.0.0
30+
*/
31+
public abstract class JaxpVersion {
32+
33+
public static final int JAXP_10 = 0;
34+
35+
public static final int JAXP_11 = 1;
36+
37+
public static final int JAXP_13 = 3;
38+
39+
public static final int JAXP_14 = 4;
40+
41+
private static final String JAXP_11_CLASS_NAME = "javax.xml.transform.Transformer";
42+
43+
private static final String JAXP_13_CLASS_NAME = "javax.xml.xpath.XPath";
44+
45+
private static final String JAXP_14_CLASS_NAME = "javax.xml.transform.stax.StAXSource";
46+
47+
private static int jaxpVersion = JAXP_10;
48+
49+
static {
50+
try {
51+
ClassUtils.forName(JAXP_14_CLASS_NAME);
52+
jaxpVersion = JAXP_14;
53+
}
54+
catch (ClassNotFoundException ex1) {
55+
try {
56+
ClassUtils.forName(JAXP_13_CLASS_NAME);
57+
jaxpVersion = JAXP_13;
58+
}
59+
catch (ClassNotFoundException ex2) {
60+
try {
61+
ClassUtils.forName(JAXP_11_CLASS_NAME);
62+
jaxpVersion = JAXP_11;
63+
}
64+
catch (ClassNotFoundException ex3) {
65+
// default to JAXP 1.0
66+
}
67+
}
68+
}
69+
}
70+
71+
/**
72+
* Gets the JAXP version. This means we can do things like if <code>(getJaxpVersion() < JAXP_13)</code>.
73+
*
74+
* @return a code comparable to the JAXP_XX codes in this class
75+
* @see #JAXP_10
76+
* @see #JAXP_11
77+
* @see #JAXP_13
78+
* @see #JAXP_14
79+
*/
80+
public static int getJaxpVersion() {
81+
return jaxpVersion;
82+
}
83+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2006 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.xml;
18+
19+
import org.springframework.core.NestedRuntimeException;
20+
21+
/**
22+
* Root of the hierarchy of XML exception.
23+
*
24+
* @author Arjen Poutsma
25+
* @since 1.0.0
26+
*/
27+
public abstract class XmlException extends NestedRuntimeException {
28+
29+
/**
30+
* Constructs a new instance of the <code>XmlException</code> with the specific detail message.
31+
*
32+
* @param message the detail message
33+
*/
34+
protected XmlException(String message) {
35+
super(message);
36+
}
37+
38+
/**
39+
* Constructs a new instance of the <code>XmlException</code> with the specific detail message and exception.
40+
*
41+
* @param message the detail message
42+
* @param throwable the wrapped exception
43+
*/
44+
protected XmlException(String message, Throwable throwable) {
45+
super(message, throwable);
46+
}
47+
}

0 commit comments

Comments
 (0)