summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java3
-rw-r--r--java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java2
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java4
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java61
-rw-r--r--java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java9
5 files changed, 34 insertions, 45 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java
index 7c56f965a0..733555e001 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/EndpointReferenceBuilder.java
@@ -20,6 +20,7 @@
package org.apache.tuscany.sca.assembly.builder;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.monitor.Problem;
@@ -50,4 +51,6 @@ public interface EndpointReferenceBuilder {
*/
Problem runtimeBuild(EndpointReference endpointReference);
+ boolean isOutOfDate(EndpointReference endpointReference);
+
}
diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
index 0d9e4d1c86..c0150c6138 100644
--- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
+++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
@@ -109,4 +109,6 @@ public interface RuntimeWire extends Cloneable {
* @throws CloneNotSupportedException
*/
Object clone() throws CloneNotSupportedException;
+
+ boolean isOutOfDate();
}
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;
}
/**
diff --git a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java
index 8ad3b471e1..4c8fbc9f29 100644
--- a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java
+++ b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java
@@ -304,4 +304,13 @@ public class EndpointReferenceBuilderImpl implements EndpointReferenceBuilder {
return true;
}
+ public boolean isOutOfDate(EndpointReference endpointReference) {
+ Endpoint te = endpointReference.getTargetEndpoint();
+ if (!te.isUnresolved() && te.getURI()!= null) {
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+ return ! endpoints.contains(endpointReference.getTargetEndpoint());
+ }
+ return false;
+ }
+
}