diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-06-01 22:58:01 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2010-06-01 22:58:01 +0000 |
commit | 0f3e6d06982ce1f7c43a1411021bf0192489bd63 (patch) | |
tree | 3fbdefafb6e7ec4332556c28033ce2126f9bbf66 /sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org | |
parent | 5921316d0d9517868c28714e336e46a16eb73573 (diff) |
Adjust the path URI for web app deployment
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@950296 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org')
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); |