From 43b4997e3f7e8959aff44d778430945c0fe76e6a Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 28 Feb 2012 09:49:54 +0100 Subject: [PATCH] Support scanned classes in Jaxb2Marshaller Jaxb2Marshaller#supports now supports classes found via package scanning. Issue: SPR-9152 --- .../springframework/oxm/jaxb/Jaxb2Marshaller.java | 1 + .../oxm/jaxb/Jaxb2MarshallerTests.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 9c6d621c4c..1886db9487 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -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); } diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index 63af36289f..a9a749dc0f 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -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 {