diff --git a/org.springframework.oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java b/org.springframework.oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java
index 218d158147e..2864a6c68a1 100644
--- a/org.springframework.oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java
+++ b/org.springframework.oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2009 the original author or authors.
+ * Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -176,7 +176,14 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
}
/**
- * Set the package names of packages with the Castor descriptor classes.
+ * Set the names of package with the Castor descriptor classes.
+ */
+ public void setTargetPackage(String targetPackage) {
+ this.targetPackages = new String[] {targetPackage};
+ }
+
+ /**
+ * Set the names of packages with the Castor descriptor classes.
*/
public void setTargetPackages(String[] targetPackages) {
this.targetPackages = targetPackages;
diff --git a/org.springframework.oxm/src/main/java/org/springframework/oxm/config/CastorMarshallerBeanDefinitionParser.java b/org.springframework.oxm/src/main/java/org/springframework/oxm/config/CastorMarshallerBeanDefinitionParser.java
new file mode 100644
index 00000000000..60fdf715d3c
--- /dev/null
+++ b/org.springframework.oxm/src/main/java/org/springframework/oxm/config/CastorMarshallerBeanDefinitionParser.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2002-2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.springframework.oxm.config;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
+
+/**
+ * Parser for the <oxm:castor-marshaller/> element.
+ *
+ * @author Jakub Narloch
+ * @since 3.1
+ */
+public class CastorMarshallerBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
+
+ private static final String CASTOR_MARSHALLER_CLASS_NAME = "org.springframework.oxm.castor.CastorMarshaller";
+
+ @Override
+ protected String getBeanClassName(Element element) {
+ return CASTOR_MARSHALLER_CLASS_NAME;
+ }
+}
diff --git a/org.springframework.oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java b/org.springframework.oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java
index 7d9d1c797f0..f4196b70017 100644
--- a/org.springframework.oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java
+++ b/org.springframework.oxm/src/main/java/org/springframework/oxm/config/OxmNamespaceHandler.java
@@ -1,6 +1,6 @@
/*
-* Copyright 2002-2009 the original author or authors.
- *
+ * Copyright 2002-2011 the original author or authors.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -31,6 +31,7 @@ public class OxmNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("jaxb2-marshaller", new Jaxb2MarshallerBeanDefinitionParser());
registerBeanDefinitionParser("jibx-marshaller", new JibxMarshallerBeanDefinitionParser());
registerBeanDefinitionParser("xmlbeans-marshaller", new XmlBeansMarshallerBeanDefinitionParser());
+ registerBeanDefinitionParser("castor-marshaller", new CastorMarshallerBeanDefinitionParser());
}
}
diff --git a/org.springframework.oxm/src/main/resources/org/springframework/oxm/config/spring-oxm-3.1.xsd b/org.springframework.oxm/src/main/resources/org/springframework/oxm/config/spring-oxm-3.1.xsd
index 67325c70b90..b3807913ceb 100644
--- a/org.springframework.oxm/src/main/resources/org/springframework/oxm/config/spring-oxm-3.1.xsd
+++ b/org.springframework.oxm/src/main/resources/org/springframework/oxm/config/spring-oxm-3.1.xsd
@@ -102,6 +102,46 @@
+
+
+
+
+ Defines a Castor Marshaller.
+
+
+
+
+
+
+
+
+
+
+
+ The encoding to use for stream reading.
+
+
+
+
+ The target class to be bound with Castor marshaller.
+
+
+
+
+ The target package that contains Castor descriptor classes.
+
+
+
+
+ The path to Castor mapping file.
+
+
+
+
+
+
+
A class supported by a marshaller.
diff --git a/org.springframework.oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTest.java b/org.springframework.oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java
similarity index 54%
rename from org.springframework.oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTest.java
rename to org.springframework.oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java
index f01c230b201..f9dd3eeb240 100644
--- a/org.springframework.oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTest.java
+++ b/org.springframework.oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright ${YEAR} the original author or authors.
+ * Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,18 +17,24 @@
package org.springframework.oxm.config;
import org.apache.xmlbeans.XmlOptions;
-import static org.junit.Assert.*;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.oxm.castor.CastorMarshaller;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
-import org.springframework.oxm.jibx.JibxMarshaller;
import org.springframework.oxm.xmlbeans.XmlBeansMarshaller;
-public class OxmNamespaceHandlerTest {
+import static org.junit.Assert.*;
+
+/**
+ * Tests the {@link OxmNamespaceHandler} class.
+ *
+ * @author Arjen Poustma
+ * @author Jakub Narloch
+ */
+public class OxmNamespaceHandlerTests {
private ApplicationContext applicationContext;
@@ -37,12 +43,6 @@ public class OxmNamespaceHandlerTest {
applicationContext = new ClassPathXmlApplicationContext("oxmNamespaceHandlerTest.xml", getClass());
}
- @Test
- @Ignore
- public void jibxMarshaller() throws Exception {
- applicationContext.getBean("jibxMarshaller", JibxMarshaller.class);
- }
-
@Test
public void xmlBeansMarshaller() throws Exception {
XmlBeansMarshaller marshaller = applicationContext.getBean("xmlBeansMarshaller", XmlBeansMarshaller.class);
@@ -54,12 +54,37 @@ public class OxmNamespaceHandlerTest {
@Test
public void jaxb2ContextPathMarshaller() throws Exception {
- applicationContext.getBean("contextPathMarshaller", Jaxb2Marshaller.class);
+ Jaxb2Marshaller jaxb2Marshaller = applicationContext.getBean("jaxb2ContextPathMarshaller", Jaxb2Marshaller.class);
+ assertNotNull(jaxb2Marshaller);
}
@Test
public void jaxb2ClassesToBeBoundMarshaller() throws Exception {
- applicationContext.getBean("classesMarshaller", Jaxb2Marshaller.class);
+ Jaxb2Marshaller jaxb2Marshaller = applicationContext.getBean("jaxb2ClassesMarshaller", Jaxb2Marshaller.class);
+ assertNotNull(jaxb2Marshaller);
}
+ @Test
+ public void castorEncodingMarshaller() throws Exception {
+ CastorMarshaller castorMarshaller = applicationContext.getBean("castorEncodingMarshaller", CastorMarshaller.class);
+ assertNotNull(castorMarshaller);
+ }
+
+ @Test
+ public void castorTargetClassMarshaller() throws Exception {
+ CastorMarshaller castorMarshaller = applicationContext.getBean("castorTargetClassMarshaller", CastorMarshaller.class);
+ assertNotNull(castorMarshaller);
+ }
+
+ @Test
+ public void castorTargetPackageMarshaller() throws Exception {
+ CastorMarshaller castorMarshaller = applicationContext.getBean("castorTargetPackageMarshaller", CastorMarshaller.class);
+ assertNotNull(castorMarshaller);
+ }
+
+ @Test
+ public void castorMappingLocationMarshaller() throws Exception {
+ CastorMarshaller castorMarshaller = applicationContext.getBean("castorMappingLocationMarshaller", CastorMarshaller.class);
+ assertNotNull(castorMarshaller);
+ }
}
\ No newline at end of file
diff --git a/org.springframework.oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml b/org.springframework.oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml
index e977871622e..9e7385f5ae7 100644
--- a/org.springframework.oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml
+++ b/org.springframework.oxm/src/test/resources/org/springframework/oxm/config/oxmNamespaceHandlerTest.xml
@@ -1,23 +1,38 @@
-
-
-
+
-
-
-
- true
-
-
-
+
+
-
-
-
-
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+