diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2013-09-10 16:50:53 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2013-09-10 16:50:53 +0000 |
commit | 33b786453598495cde754c80f5a9397de68ff60e (patch) | |
tree | 50da8cc403481aa74e818ef59b79112ce0f35108 /sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java | |
parent | ccbc8786378e618d74430f1267ee494f7142ea21 (diff) |
Provide binder context to allow Wink to properly construct relative URIs with UriBuilder
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1521548 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java index 3dfd917da9..52c293090f 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java @@ -30,6 +30,8 @@ import java.util.Properties; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; @@ -176,6 +178,12 @@ public class TuscanyRESTServlet extends RestServlet { } }); + Properties properties = new Properties(); + properties.put("wink.context.uri", getBindingContext()); + //properties.put("wink.http.uri", binding.getURI()); + + config.setProperties(properties); + ProvidersRegistry providers = config.getProvidersRegistry(); providers.addProvider(new DataBindingJAXRSReader(registry), 0.2, true); providers.addProvider(new DataBindingJAXRSWriter(registry), 0.2, true); @@ -214,6 +222,16 @@ public class TuscanyRESTServlet extends RestServlet { } + private String getBindingContext() { + Pattern pattern = Pattern.compile("^[^#]*?://.*?(/.*)$"); + Matcher matcher = pattern.matcher(binding.getURI()); + if(matcher.find()) { + String bindingContext = matcher.group(1); + return bindingContext; + } + return null; + } + /** * TuscanyResponseHandler * |