Support scanned classes in Jaxb2Marshaller

Jaxb2Marshaller#supports now supports classes found via package
scanning.

Issue: SPR-9152
This commit is contained in:
Arjen Poutsma
2012-02-28 09:49:54 +01:00
parent 83f3750fb3
commit 43b4997e3f
2 changed files with 9 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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 {
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 {