Provide binder context to allow Wink to properly construct relative URIs with UriBuilder

git-svn-id: https://svn.apache.org/repos/asf/tuscany/sca-java-2.x/trunk@1521548 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java b/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
index 3dfd917..52c2930 100644
--- a/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
+++ b/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java
@@ -30,6 +30,8 @@
 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;
@@ -175,6 +177,12 @@
                 return TuscanyRESTServlet.this.getServletName();
             }
         });
+        
+        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);
@@ -213,6 +221,16 @@
         }
         
     }
+    
+    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