diff options
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/RESTServiceBindingProvider.java | 101 |
1 files changed, 52 insertions, 49 deletions
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 ec607e9e13..fab971de53 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 @@ -157,6 +157,42 @@ public class RESTServiceBindingProvider implements EndpointProvider { } + public InterfaceContract getBindingInterfaceContract() { + return serviceContract; + } + + + /** + * Add specific rest interceptor to invocation chain + */ + public void configure() { + + InvocationChain bindingChain = endpoint.getBindingInvocationChain(); + + if (wfProvider != null) { + Interceptor interceptor = wfProvider.createInterceptor(); + if (interceptor != null) { + bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, interceptor); + } + } + + if (wfResponseProvider != null) { + Interceptor interceptor = wfResponseProvider.createInterceptor(); + if (interceptor != null) { + bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, interceptor); + } + + } + + if (osProvider != null) { + Interceptor interceptor = osProvider.createInterceptor(); + if (interceptor != null) { + bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, interceptor); + } + } + + } + public void start() { InvocationChain bindingChain = endpoint.getBindingInvocationChain(); @@ -214,7 +250,21 @@ public class RESTServiceBindingProvider implements EndpointProvider { servletMapping = registerServlet(servlet); } - public String registerServlet(Servlet servlet) { + public void stop() { + if (application != null) { + application.destroy(); + } + // Unregister the Servlet from the Servlet host + servletHost.removeServletMapping(servletMapping); + } + + + public boolean supportsOneWayInvocation() { + return false; + } + + + private String registerServlet(Servlet servlet) { // Create our HTTP service listener Servlet and register it with the // Servlet host String servletMapping = binding.getURI(); @@ -234,22 +284,6 @@ public class RESTServiceBindingProvider implements EndpointProvider { return mappedURI; } - public void stop() { - if (application != null) { - application.destroy(); - } - // Unregister the Servlet from the Servlet host - servletHost.removeServletMapping(servletMapping); - } - - public InterfaceContract getBindingInterfaceContract() { - return serviceContract; - } - - public boolean supportsOneWayInvocation() { - return false; - } - /** * Register a Tuscany REST Servlet to handle JAX-RS Resources on a binding endpoint * @return @@ -269,7 +303,7 @@ public class RESTServiceBindingProvider implements EndpointProvider { TuscanyRESTServlet restServlet = new TuscanyRESTServlet(extensionPoints, binding, application.resourceClass); servletMapping = registerServlet(restServlet); - + RegistrationUtils.registerApplication(application, restServlet.getServletContext()); return application; } else { @@ -338,35 +372,4 @@ public class RESTServiceBindingProvider implements EndpointProvider { } } - /** - * Add specific rest interceptor to invocation chain - */ - public void configure() { - - InvocationChain bindingChain = endpoint.getBindingInvocationChain(); - - if (wfProvider != null) { - Interceptor interceptor = wfProvider.createInterceptor(); - if (interceptor != null) { - bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, interceptor); - } - } - - if (wfResponseProvider != null) { - Interceptor interceptor = wfResponseProvider.createInterceptor(); - if (interceptor != null) { - bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, interceptor); - } - - } - - if (osProvider != null) { - Interceptor interceptor = osProvider.createInterceptor(); - if (interceptor != null) { - bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, interceptor); - } - } - - } - } |