From 580cfd9e615f4551a03576049359a5e2d80d7475 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Mon, 30 Jun 2008 14:01:04 +0000 Subject: [PATCH] SWS-346 --- .../http/XsdSchemaHandlerAdapter.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java b/core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java index 7b457aaf..4eac58d9 100644 --- a/core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java +++ b/core/src/main/java/org/springframework/ws/transport/http/XsdSchemaHandlerAdapter.java @@ -36,7 +36,14 @@ import org.springframework.xml.transform.TraxUtils; import org.springframework.xml.xsd.XsdSchema; /** + * Adapter to use the {@link XsdSchema} interface with the generic DispatcherServlet. + *

+ * Reads the source from the mapped {@link XsdSchema} implementation, and writes that as the result to the + * HttpServletResponse. Allows for post-processing the schema in subclasses. + * * @author Arjen Poutsma + * @see XsdSchema + * @see #getSchemaSource(XsdSchema) * @since 1.5.3 */ public class XsdSchemaHandlerAdapter extends TransformerObjectSupport implements HandlerAdapter { @@ -81,8 +88,7 @@ public class XsdSchemaHandlerAdapter extends TransformerObjectSupport implements if (HttpTransportConstants.METHOD_GET.equals(request.getMethod())) { response.setContentType(CONTENT_TYPE); Transformer transformer = createTransformer(); - XsdSchema schema = (XsdSchema) handler; - Source schemaSource = schema.getSource(); + Source schemaSource = getSchemaSource((XsdSchema) handler); StreamResult responseResult = new StreamResult(response.getOutputStream()); transformer.transform(schemaSource, responseResult); } @@ -91,4 +97,19 @@ public class XsdSchemaHandlerAdapter extends TransformerObjectSupport implements } return null; } + + /** + * Returns the {@link Source} of the given schema. Allows for post-processing and transformation of the schema in + * sub-classes. + *

+ * Default implementation simply returns {@link XsdSchema#getSource()}. + * + * @param schema the schema + * @return the source of the given schema + * @throws Exception in case of errors + */ + protected Source getSchemaSource(XsdSchema schema) throws Exception { + return schema.getSource(); + } + } \ No newline at end of file