summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org')
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java11
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java5
-rw-r--r--sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/TuscanyRESTServlet.java2
3 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/RESTBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
index b5017c71f2..325aeff018 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java
@@ -60,6 +60,7 @@ import org.apache.tuscany.sca.invocation.Message;
import org.apache.wink.client.ClientConfig;
import org.apache.wink.client.Resource;
import org.apache.wink.client.RestClient;
+import org.apache.wink.client.handlers.BasicAuthSecurityHandler;
/**
*
@@ -101,6 +102,9 @@ public class RESTBindingInvoker implements Invoker {
private RestClient createRestClient() {
ClientConfig config = new ClientConfig();
+
+ // configureBasicAuth(config, userName, password);
+
config.applications(new Application() {
@Override
@@ -134,6 +138,13 @@ public class RESTBindingInvoker implements Invoker {
return client;
}
+ private void configureBasicAuth(ClientConfig config, String userName, String password) {
+ BasicAuthSecurityHandler basicAuthSecurityHandler = new BasicAuthSecurityHandler();
+ basicAuthSecurityHandler.setUserName(userName);
+ basicAuthSecurityHandler.setPassword(password);
+ config.handlers(basicAuthSecurityHandler);
+ }
+
public Message invoke(Message msg) {
Object entity = null;
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
index b672c3ee2d..46002e3226 100644
--- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java
@@ -283,6 +283,11 @@ public class RESTServiceBindingProvider implements EndpointProvider {
String uri = endpoint.getBinding().getURI();
String path = URI.create(uri).getPath();
+
+ // FIXME: [rfeng] We need to have a better way to deal with URI template for bindings
+ if(path.startsWith(servletHost.getContextPath())) {
+ path = path.substring(servletHost.getContextPath().length());
+ }
Class<?> cls =
RootResourceClassGenerator.generateRootResourceClass(interfaze,
path,
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 13f13e4dde..23b951c88a 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
@@ -54,6 +54,7 @@ public class TuscanyRESTServlet extends RestServlet {
public DeploymentConfiguration getDeploymentConfiguration() throws ClassNotFoundException, InstantiationException,
IllegalAccessException, IOException {
DeploymentConfiguration config = super.getDeploymentConfiguration();
+
// [rfeng] FIXME: This is a hack to fool Apache wink to not remove the servlet path
config.setFilterConfig(new FilterConfig() {
@@ -73,6 +74,7 @@ public class TuscanyRESTServlet extends RestServlet {
return getServletName();
}
});
+
ProvidersRegistry providers = config.getProvidersRegistry();
providers.addProvider(new DataBindingJAXRSReader(registry), 0.001, true);
providers.addProvider(new DataBindingJAXRSWriter(registry), 0.001, true);