diff options
Diffstat (limited to 'sandbox/event/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java')
-rw-r--r-- | sandbox/event/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/sandbox/event/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java b/sandbox/event/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java index 2c8cc49d47..8d578bc4f3 100644 --- a/sandbox/event/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java +++ b/sandbox/event/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeWireImpl.java @@ -123,7 +123,9 @@ public class RuntimeWireImpl implements RuntimeWire { } if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable())) { return chain; - } + } else if( isConsumer(wireTarget) ) { + return chain; + } // end if } return null; } @@ -145,7 +147,7 @@ public class RuntimeWireImpl implements RuntimeWire { chains = new ArrayList<InvocationChain>(); InterfaceContract sourceContract = wireSource.getInterfaceContract(); InterfaceContract targetContract = wireTarget.getInterfaceContract(); - + Contract source = wireSource.getContract(); if (source instanceof RuntimeComponentReference) { // It's the reference wire @@ -154,12 +156,26 @@ public class RuntimeWireImpl implements RuntimeWire { for (Operation operation : sourceContract.getInterface().getOperations()) { Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); if (targetOperation == null) { - throw new ServiceRuntimeException("No matching operation for " + operation.getName() - + " is found in reference " - + wireSource.getComponent().getURI() - + "#" - + reference.getName()); - } + // Consumer handling added - Mike Edwards, 06/11/2008 + Contract theContract = wireTarget.getContract(); + boolean error = true; + if( theContract != null ) { + ComponentService theService = (ComponentService)theContract; + if( theService.isConsumer() ) { + error = false; + // Put in the 1st operation in the interface (the actual operation is computed later... + targetOperation = targetContract.getInterface().getOperations().get(0); + } // end if + } // end if + if( error ) { + throw new ServiceRuntimeException("No matching operation for " + operation.getName() + + " is found in reference " + + wireSource.getComponent().getURI() + + "#" + + reference.getName()); + } // end if + // End of consumer handling + } // end if InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true); if (operation.isNonBlocking()) { addNonBlockingInterceptor(reference, refBinding, chain); @@ -175,12 +191,27 @@ public class RuntimeWireImpl implements RuntimeWire { for (Operation operation : sourceContract.getInterface().getOperations()) { Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation); if (targetOperation == null) { - throw new ServiceRuntimeException("No matching operation for " + operation.getName() - + " is found in service " - + serviceComponent.getURI() - + "#" - + service.getName()); - } + // Consumer handling added - Mike Edwards, 06/11/2008 + Contract theContract = wireTarget.getContract(); + boolean error = true; + if( theContract != null ) { + ComponentService theService = (ComponentService)theContract; + if( theService.isConsumer() ) { + error = false; + // Put in the 1st operation in the interface (the actual operation is computed later... + targetOperation = targetContract.getInterface().getOperations().get(0); + } // end if + } // end if + if( error ) { + throw new ServiceRuntimeException("No matching operation for " + operation.getName() + + " is found in service " + + serviceComponent.getURI() + + "#" + + service.getName()); + } // end if + // End of consumer handling + } // end if + InvocationChain chain = new InvocationChainImpl(operation, targetOperation, false); if (operation.isNonBlocking()) { addNonBlockingInterceptor(service, serviceBinding, chain); @@ -376,4 +407,21 @@ public class RuntimeWireImpl implements RuntimeWire { private void setClonedFrom(RuntimeWireImpl wire) { clonedFrom = wire; } + + /** + * Checks if a target reference is a Consumer + * @param ref - target endpoint reference + * @return true if the endpoint is a Consumer, false otherwise + */ + private static boolean isConsumer( EndpointReference ref ){ + Contract theContract = ref.getContract(); + if( theContract != null ) { + ComponentService theService = (ComponentService)theContract; + if( theService.isConsumer() ) { + return true; + } // end if + } // end if + + return false; + } // end isConsumer } |