From 69342b0efcd4e7631e20cab07f624b4907aad6d8 Mon Sep 17 00:00:00 2001 From: lresende Date: Mon, 4 May 2009 07:04:07 +0000 Subject: TUSCANY-2968 - Further changes trying to add the json-rpc wireformat and operation selector interceptors to the invocation chain git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@771209 13f79535-47bb-0310-9956-ffa450edef68 --- .../JSONRPCOperationSelectorInterceptor.java | 6 +++--- .../JSONRPCOperationSelectorProviderFactory.java | 6 ++++++ .../JSONRPCOperationSelectorServiceProvider.java | 13 ++++++++++++- .../provider/JSONRPCWireFormatInterceptor.java | 20 +++++++++++++++----- .../provider/JSONRPCWireFormatServiceProvider.java | 20 +++++++++++++++++++- 5 files changed, 55 insertions(+), 10 deletions(-) (limited to 'branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache') diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorInterceptor.java b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorInterceptor.java index f189b940ad..094a27d7a2 100644 --- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorInterceptor.java +++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorInterceptor.java @@ -38,15 +38,15 @@ public class JSONRPCOperationSelectorInterceptor implements Interceptor { } public Invoker getNext() { - return null; + return this.next; } public void setNext(Invoker next) { - + this.next = next; } public Message invoke(Message msg) { - return null; + return getNext().invoke(msg); } } diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorProviderFactory.java b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorProviderFactory.java index 786e8f8855..12c4bd7cf4 100644 --- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorProviderFactory.java +++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorProviderFactory.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.provider; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.JSONRPCOperationSelector; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.provider.OperationSelectorProvider; import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; @@ -28,6 +29,11 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; public class JSONRPCOperationSelectorProviderFactory implements OperationSelectorProviderFactory { + private ExtensionPointRegistry extensionPoints; + + public JSONRPCOperationSelectorProviderFactory(ExtensionPointRegistry extensionPoints) { + this.extensionPoints = extensionPoints; + } public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, RuntimeComponentReference reference, diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorServiceProvider.java b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorServiceProvider.java index a57105ed3f..d1581fff95 100644 --- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorServiceProvider.java +++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/operationselector/jsonrpc/provider/JSONRPCOperationSelectorServiceProvider.java @@ -20,7 +20,10 @@ package org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.provider; import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.BindingRRB; +import org.apache.tuscany.sca.assembly.OperationSelector; import org.apache.tuscany.sca.binding.http.HTTPBinding; +import org.apache.tuscany.sca.binding.http.operationselector.jsonrpc.JSONRPCOperationSelector; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; import org.apache.tuscany.sca.provider.OperationSelectorProvider; @@ -40,7 +43,15 @@ public class JSONRPCOperationSelectorServiceProvider implements OperationSelecto } public Interceptor createInterceptor() { - return new JSONRPCOperationSelectorInterceptor((HTTPBinding) binding, service.getRuntimeWire(binding)); + if(binding instanceof BindingRRB) { + BindingRRB rrbBinding = (BindingRRB) binding; + OperationSelector operationSelector = rrbBinding.getOperationSelector(); + if(operationSelector != null && operationSelector instanceof JSONRPCOperationSelector) { + return new JSONRPCOperationSelectorInterceptor((HTTPBinding) binding, service.getRuntimeWire(binding)); + } + } + + return null; } public String getPhase() { diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java index 68152b0321..5778a2908c 100644 --- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java +++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java @@ -19,25 +19,35 @@ package org.apache.tuscany.sca.binding.http.wireformat.jsonrpc.provider; +import org.apache.tuscany.sca.binding.http.HTTPBinding; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.RuntimeWire; public class JSONRPCWireFormatInterceptor implements Interceptor { + private Invoker next; + + private RuntimeWire runtimeWire; + private HTTPBinding binding; + + public JSONRPCWireFormatInterceptor(HTTPBinding binding, RuntimeWire runtimeWire) { + this.binding = binding; + this.runtimeWire = runtimeWire; + + } public Invoker getNext() { - // TODO Auto-generated method stub - return null; + return next; } public void setNext(Invoker next) { - // TODO Auto-generated method stub + this.next = next; } public Message invoke(Message msg) { - // TODO Auto-generated method stub - return null; + return getNext().invoke(msg); } } diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java index 983e54c1a7..91d35546ae 100644 --- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java +++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java @@ -20,6 +20,10 @@ package org.apache.tuscany.sca.binding.http.wireformat.jsonrpc.provider; import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.BindingRRB; +import org.apache.tuscany.sca.assembly.WireFormat; +import org.apache.tuscany.sca.binding.http.HTTPBinding; +import org.apache.tuscany.sca.binding.http.wireformat.jsonrpc.JSONRPCWireFormat; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.invocation.Interceptor; @@ -32,12 +36,19 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService; * @version $Rev$ $Date$ */ public class JSONRPCWireFormatServiceProvider implements WireFormatProvider { + private RuntimeComponent component; + private RuntimeComponentService service; + private Binding binding; public JSONRPCWireFormatServiceProvider(ExtensionPointRegistry extensionPoints, RuntimeComponent component, RuntimeComponentService service, Binding binding) { + super(); + this.component = component; + this.service = service; + this.binding = binding; } public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) { @@ -46,7 +57,14 @@ public class JSONRPCWireFormatServiceProvider implements WireFormatProvider { } public Interceptor createInterceptor() { - // TODO Auto-generated method stub + if(binding instanceof BindingRRB) { + BindingRRB rrbBinding = (BindingRRB) binding; + WireFormat wireFormat = rrbBinding.getRequestWireFormat(); + if(wireFormat != null && wireFormat instanceof JSONRPCWireFormat) { + return new JSONRPCWireFormatInterceptor((HTTPBinding) binding, service.getRuntimeWire(binding)); + } + } + return null; } -- cgit v1.2.3