diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-04 07:04:07 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-04 07:04:07 +0000 |
commit | 69342b0efcd4e7631e20cab07f624b4907aad6d8 (patch) | |
tree | 3a1f60fd9f16bac49bfb2276f771c9915abc7e49 | |
parent | 4989a995d0a9b221c2f7515c39c6c570db940ae9 (diff) |
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
7 files changed, 69 insertions, 16 deletions
diff --git a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java index a982bb7ff6..e9e5b43944 100644 --- a/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java +++ b/branches/sca-java-1.x/itest/http-jsonrpc/src/test/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCServiceTestCase.java @@ -24,8 +24,6 @@ import junit.framework.Assert; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.json.JSONObject; -import org.junit.After; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -45,12 +43,12 @@ public class JSONRPCServiceTestCase { private SCADomain domain; - //@Before + //@BeforeClass public void setUp() throws Exception { domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/JSONRPCBinding.composite"); } - //@After + //@AfterClass public void tearDown() throws Exception { domain.close(); } 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<JSONRPCOperationSelector> { + 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; } diff --git a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java index 6e01ac5f9f..a9873b4166 100644 --- a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java +++ b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java @@ -37,7 +37,7 @@ import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.PolicySetAttachPoint; import org.apache.tuscany.sca.policy.authentication.AuthenticationConfigurationPolicy; import org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicy; -import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.apache.tuscany.sca.runtime.RuntimeWire; @@ -47,7 +47,7 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; * * @version $Rev$ $Date$ */ -public class HTTPServiceBindingProvider implements ServiceBindingProvider { +public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { private static final QName AUTEHTICATION_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","authentication"); private static final QName CONFIDENTIALITY_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","confidentiality"); @@ -185,5 +185,15 @@ public class HTTPServiceBindingProvider implements ServiceBindingProvider { public boolean supportsOneWayInvocation() { return false; } + + /** + * Add specific http interceptor to invocation chain + * @param runtimeWire + */ + public void configureBindingChain(RuntimeWire runtimeWire) { + InvocationChain bindingChain = runtimeWire.getBindingInvocationChain(); + + + } } |