Browse Source

Support scanned classes in Jaxb2Marshaller

Jaxb2Marshaller#supports now supports classes found via package
scanning.

Issue: SPR-9152
pull/43/head
Arjen Poutsma 13 years ago
parent
commit
43b4997e3f
  1. 1
      spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java
  2. 15
      spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java

1
spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

@ -457,6 +457,7 @@ public class Jaxb2Marshaller @@ -457,6 +457,7 @@ public class Jaxb2Marshaller
if (logger.isDebugEnabled()) {
logger.debug("Found JAXB2 classes: [" + StringUtils.arrayToCommaDelimitedString(jaxb2Classes) + "]");
}
this.classesToBeBound = jaxb2Classes;
if (this.jaxbContextProperties != null) {
return JAXBContext.newInstance(jaxb2Classes, this.jaxbContextProperties);
}

15
spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java

@ -163,6 +163,14 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests { @@ -163,6 +163,14 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests {
marshaller.afterPropertiesSet();
testSupports();
}
@Test
public void supportsPackagesToScan() throws Exception {
marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(new String[] {CONTEXT_PATH});
marshaller.afterPropertiesSet();
testSupports();
}
private void testSupports() throws Exception {
assertTrue("Jaxb2Marshaller does not support Flights class", marshaller.supports(Flights.class));
@ -279,13 +287,6 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests { @@ -279,13 +287,6 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests {
assertTrue("No XML written", writer.toString().length() > 0);
}
@Test
public void supportsPackagesToScan() throws Exception {
marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(new String[] {CONTEXT_PATH});
marshaller.afterPropertiesSet();
}
@XmlRootElement
public static class DummyRootElement {

Loading…
Cancel
Save