|
16 | 16 |
|
17 | 17 | package org.springframework.oxm.jaxb;
|
18 | 18 |
|
19 |
| -import java.awt.*; |
| 19 | +import java.awt.Image; |
20 | 20 | import java.io.ByteArrayInputStream;
|
21 | 21 | import java.io.IOException;
|
22 | 22 | import java.io.InputStream;
|
|
65 | 65 | import javax.xml.validation.Schema;
|
66 | 66 | import javax.xml.validation.SchemaFactory;
|
67 | 67 |
|
68 |
| -import org.apache.commons.logging.Log; |
69 |
| -import org.apache.commons.logging.LogFactory; |
70 |
| -import org.xml.sax.InputSource; |
71 |
| -import org.xml.sax.SAXException; |
72 |
| -import org.xml.sax.XMLReader; |
73 |
| -import org.xml.sax.helpers.XMLReaderFactory; |
74 |
| - |
75 | 68 | import org.springframework.beans.factory.BeanClassLoaderAware;
|
76 | 69 | import org.springframework.beans.factory.InitializingBean;
|
77 | 70 | import org.springframework.core.annotation.AnnotationUtils;
|
|
94 | 87 | import org.springframework.util.StringUtils;
|
95 | 88 | import org.springframework.util.xml.StaxUtils;
|
96 | 89 |
|
| 90 | +import org.apache.commons.logging.Log; |
| 91 | +import org.apache.commons.logging.LogFactory; |
| 92 | +import org.w3c.dom.ls.LSResourceResolver; |
| 93 | +import org.xml.sax.InputSource; |
| 94 | +import org.xml.sax.SAXException; |
| 95 | +import org.xml.sax.XMLReader; |
| 96 | +import org.xml.sax.helpers.XMLReaderFactory; |
| 97 | + |
97 | 98 | /**
|
98 | 99 | * Implementation of the <code>Marshaller</code> interface for JAXB 2.0.
|
99 | 100 | *
|
@@ -160,6 +161,8 @@ public class Jaxb2Marshaller
|
160 | 161 |
|
161 | 162 | private boolean supportJaxbElementClass = false;
|
162 | 163 |
|
| 164 | + private LSResourceResolver schemaResourceResolver; |
| 165 | + |
163 | 166 |
|
164 | 167 | /**
|
165 | 168 | * Set multiple JAXB context paths. The given array of context paths is converted to a
|
@@ -286,7 +289,17 @@ public void setSchemaLanguage(String schemaLanguage) {
|
286 | 289 | this.schemaLanguage = schemaLanguage;
|
287 | 290 | }
|
288 | 291 |
|
289 |
| - /** |
| 292 | + /** |
| 293 | + * Sets the resource resolver, as used to load the schema resources. |
| 294 | + * @see SchemaFactory#setResourceResolver(org.w3c.dom.ls.LSResourceResolver) |
| 295 | + * @see #setSchema(Resource) |
| 296 | + * @see #setSchemas(Resource[]) |
| 297 | + */ |
| 298 | + public void setSchemaResourceResolver(LSResourceResolver schemaResourceResolver) { |
| 299 | + this.schemaResourceResolver = schemaResourceResolver; |
| 300 | + } |
| 301 | + |
| 302 | + /** |
290 | 303 | * Specify whether MTOM support should be enabled or not.
|
291 | 304 | * Default is <code>false</code>: marshalling using XOP/MTOM not being enabled.
|
292 | 305 | */
|
@@ -407,6 +420,9 @@ private Schema loadSchema(Resource[] resources, String schemaLanguage) throws IO
|
407 | 420 | schemaSources[i] = new SAXSource(xmlReader, inputSource);
|
408 | 421 | }
|
409 | 422 | SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage);
|
| 423 | + if (schemaResourceResolver != null) { |
| 424 | + schemaFactory.setResourceResolver(schemaResourceResolver); |
| 425 | + } |
410 | 426 | return schemaFactory.newSchema(schemaSources);
|
411 | 427 | }
|
412 | 428 |
|
|
0 commit comments