From 93240046708547db398dbe4f93583f92b19ef7f1 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 28 Aug 2009 10:15:19 +0000 Subject: Update to add a method to check if a wire target is out of date compared to teh endpoint registry (see ML discussion 'Endpoint registry and stopping/starting nodes' git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@808838 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/core/assembly/impl/RuntimeWireImpl.java | 4 ++ .../core/invocation/impl/JDKInvocationHandler.java | 61 ++++++---------------- 2 files changed, 20 insertions(+), 45 deletions(-) (limited to 'java/sca/modules/core') diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java index b31a8e7d1a..78811ebf7e 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java @@ -771,5 +771,9 @@ public class RuntimeWireImpl implements RuntimeWire { // No promoted service return null; } + } + + public boolean isOutOfDate() { + return endpointReferenceBuilder.isOutOfDate(getEndpointReference()); } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java index 6bd7ebd301..42625e9ea1 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java @@ -130,54 +130,25 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { throw new ServiceRuntimeException("No runtime wire is available"); } - try { - InvocationChain chain = getInvocationChain(method, wire); - - if (chain == null) { - throw new IllegalArgumentException("No matching operation is found: " + method); - } - - // The EndpointReference is not now resolved until the invocation chain - // is first created so reset the source here - source = wire.getEndpointReference(); - - // send the invocation down the wire - Object result = invoke(chain, args, wire, source); - - return result; - } catch (TargetResolutionException e) { - // the service node has gone so clear and rebuild and try invoke again + if (wire.isOutOfDate()) { wire.rebuild(); chains.clear(); - try { - InvocationChain chain = getInvocationChain(method, wire); - - if (chain == null) { - throw new IllegalArgumentException("No matching operation is found: " + method); - } - - // The EndpointReference is not now resolved until the invocation chain - // is first created so reset the source here - source = wire.getEndpointReference(); - - // send the invocation down the wire - Object result = invoke(chain, args, wire, source); - - return result; - } catch (SCARuntimeException e1) { - // this can be thrown by getInvocationChain if the endpoint isn't available - // clean up so a later request can work - wire.rebuild(); - chains.clear(); - throw e1; - } catch (TargetResolutionException e2) { - //this can be thrown by the invoke if the endpoint has disapeared - // clean up so a later request can work - wire.rebuild(); - chains.clear(); - throw e2; - } } + + InvocationChain chain = getInvocationChain(method, wire); + + if (chain == null) { + throw new IllegalArgumentException("No matching operation is found: " + method); + } + + // The EndpointReference is not now resolved until the invocation chain + // is first created so reset the source here + source = wire.getEndpointReference(); + + // send the invocation down the wire + Object result = invoke(chain, args, wire, source); + + return result; } /** -- cgit v1.2.3