This commit is contained in:
Arjen Poutsma
2007-11-10 13:33:03 +00:00
parent 4965d354e9
commit 7ca4e47c60
3 changed files with 114 additions and 83 deletions

View File

@@ -22,6 +22,7 @@ import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
@@ -38,10 +39,16 @@ import org.springframework.util.StringUtils;
* @see #setValidating(boolean)
* @since 1.0.0
*/
public class Jaxb1Marshaller extends AbstractJaxbMarshaller {
public class Jaxb1Marshaller extends AbstractJaxbMarshaller implements BeanClassLoaderAware {
private boolean validating = false;
private ClassLoader classLoader;
public void setBeanClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
/** Set if the JAXB <code>Unmarshaller</code> should validate the incoming document. Default is <code>false</code>. */
public void setValidating(boolean validating) {
this.validating = validating;
@@ -77,7 +84,8 @@ public class Jaxb1Marshaller extends AbstractJaxbMarshaller {
if (logger.isInfoEnabled()) {
logger.info("Creating JAXBContext with context path [" + getContextPath() + "]");
}
return JAXBContext.newInstance(getContextPath());
return classLoader != null ? JAXBContext.newInstance(getContextPath(), classLoader) :
JAXBContext.newInstance(getContextPath());
}
protected void initJaxbUnmarshaller(Unmarshaller unmarshaller) throws JAXBException {