Skip to content

Commit 4ffe9c6

Browse files
committed
SWS-229
1 parent fa25ac7 commit 4ffe9c6

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

oxm/src/main/java/org/springframework/oxm/jibx/JibxMarshaller.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,19 @@
4949
import org.jibx.runtime.impl.StAXReaderWrapper;
5050
import org.jibx.runtime.impl.StAXWriter;
5151
import org.jibx.runtime.impl.UnmarshallingContext;
52+
import org.w3c.dom.Node;
53+
import org.xml.sax.ContentHandler;
54+
import org.xml.sax.InputSource;
55+
import org.xml.sax.XMLReader;
56+
import org.xml.sax.ext.LexicalHandler;
57+
5258
import org.springframework.beans.factory.InitializingBean;
5359
import org.springframework.oxm.AbstractMarshaller;
5460
import org.springframework.oxm.XmlMappingException;
5561
import org.springframework.util.Assert;
5662
import org.springframework.util.StringUtils;
5763
import org.springframework.xml.stream.StaxEventContentHandler;
5864
import org.springframework.xml.stream.XmlEventStreamReader;
59-
import org.w3c.dom.Node;
60-
import org.xml.sax.ContentHandler;
61-
import org.xml.sax.InputSource;
62-
import org.xml.sax.XMLReader;
63-
import org.xml.sax.ext.LexicalHandler;
6465

6566
/**
6667
* Implementation of the <code>Marshaller</code> and <code>Unmarshaller</code> interfaces for JiBX.
@@ -138,7 +139,15 @@ public void afterPropertiesSet() throws Exception {
138139
}
139140

140141
public boolean supports(Class clazz) {
141-
return targetClass.isAssignableFrom(clazz);
142+
Assert.notNull(clazz, "'clazz' must not be null");
143+
String[] mappedClasses = bindingFactory.getMappedClasses();
144+
String className = clazz.getName();
145+
for (int i = 0; i < mappedClasses.length; i++) {
146+
if (className.equals(mappedClasses[i])) {
147+
return true;
148+
}
149+
}
150+
return false;
142151
}
143152

144153
/**

oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.oxm.jibx;
1818

1919
import org.custommonkey.xmlunit.XMLUnit;
20+
2021
import org.springframework.oxm.AbstractMarshallerTestCase;
2122
import org.springframework.oxm.Marshaller;
2223
import org.springframework.xml.transform.StringResult;
@@ -69,7 +70,9 @@ public void testEncodingAndStandalone() throws Exception {
6970
}
7071

7172
public void testSupports() throws Exception {
72-
assertTrue("Jaxb2Marshaller does not support Flights", marshaller.supports(Flights.class));
73+
assertTrue("JibxMarshaller does not support Flights", marshaller.supports(Flights.class));
74+
assertTrue("JibxMarshaller does not support FlightType", marshaller.supports(FlightType.class));
75+
assertFalse("JibxMarshaller supports illegal type", marshaller.supports(getClass()));
7376
}
7477

7578

0 commit comments

Comments
 (0)