You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2013/10/18 20:26:02 UTC
svn commit: r1533582 - in
/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs:
ext/xml/XSISchemaLocation.java provider/JAXBElementProvider.java
Author: sergeyb
Date: Fri Oct 18 18:26:01 2013
New Revision: 1533582
URL: http://svn.apache.org/r1533582
Log:
[CXF-5342] Making it possible to pass relative XSI locations
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XSISchemaLocation.java
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XSISchemaLocation.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XSISchemaLocation.java?rev=1533582&r1=1533581&r2=1533582&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XSISchemaLocation.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/xml/XSISchemaLocation.java Fri Oct 18 18:26:01 2013
@@ -31,9 +31,17 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
public @interface XSISchemaLocation {
/**
- * schema location relative to a base URI of the web application
+ * Schema location
+ * By default it is assumed to be relative to a base URI of the web application
*/
String value();
+
+ /**
+ * If the location is relative and this property is set to true then
+ * the location will be resolved against the base URI of the web application
+ */
+ boolean resolve() default true;
+
/**
* Can be used to get xsi:noNamespaceSchemaLocation produced.
* By default, xsi:schemaLocation will be set.
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1533582&r1=1533581&r2=1533582&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java Fri Oct 18 18:26:01 2013
@@ -445,7 +445,7 @@ public class JAXBElementProvider<T> exte
if (relRef.endsWith("'")) {
relRef = relRef.substring(0, relRef.length() - 1);
}
- String absRef = buildAbsoluteXMLResourceURI(relRef);
+ String absRef = resolveXMLResourceURI(relRef);
value = value.substring(0, ind + 6) + absRef + "'?>";
}
setXmlPiProperty(ms, value);
@@ -455,14 +455,14 @@ public class JAXBElementProvider<T> exte
private void addSchemaLocation(Marshaller ms, Annotation[] anns) throws Exception {
XSISchemaLocation sl = AnnotationUtils.getAnnotation(anns, XSISchemaLocation.class);
if (sl != null) {
- String value = buildAbsoluteXMLResourceURI(sl.value());
+ String value = sl.resolve() ? resolveXMLResourceURI(sl.value()) : sl.value();
String propName = !sl.noNamespace()
? Marshaller.JAXB_SCHEMA_LOCATION : Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION;
ms.setProperty(propName, value);
}
}
- private String buildAbsoluteXMLResourceURI(String path) {
+ protected String resolveXMLResourceURI(String path) {
MessageContext mc = getContext();
if (mc != null) {
String httpBasePath = (String)mc.get("http.base.path");