summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-01-20 16:42:59 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-01-20 16:42:59 +0000
commit630599c9de5bce09c7fb1f1b657ae36164c5cc40 (patch)
treecac9a8b81dd1a10644128a0725183bc79b7d59fa /sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache
parent1006c4802c6dadbcc4ffc874044b8a8e7bf0ec2e (diff)
Start of making the Tuscany sca client impl work for both local or remote nodes and to be generic for any binding. Work in progress, only local invocations work presently
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@901270 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache')
-rw-r--r--sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java82
1 files changed, 44 insertions, 38 deletions
diff --git a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
index 42d2eda6a3..fc16db7a74 100644
--- a/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
+++ b/sca-java-2.x/trunk/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
@@ -319,55 +319,61 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi
}
public List<Endpoint> findEndpoint(EndpointReference endpointReference) {
- List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
-
logger.fine("Find endpoint for reference - " + endpointReference);
if (endpointReference.getReference() != null) {
Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
-
- // in the failure case we repeat the look up after a short
- // delay to take account of tribes replication delays
- int repeat = FIND_REPEAT_COUNT;
-
- while (repeat > 0){
- for (Object v : map.values()) {
- Endpoint endpoint = (Endpoint)v;
- // TODO: implement more complete matching
- logger.fine("Matching against - " + endpoint);
- if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
- MapEntry entry = map.getInternal(endpoint.getURI());
- if (!isLocal(entry)) {
- endpoint.setRemote(true);
- }
- // if (!entry.isPrimary()) {
- ((RuntimeEndpoint) endpoint).bind(registry, this);
- // }
- foundEndpoints.add(endpoint);
- logger.fine("Found endpoint with matching service - " + endpoint);
- repeat = 0;
- }
- // else the service name doesn't match
- }
-
- if (foundEndpoints.size() == 0) {
- // the service name doesn't match any endpoints so wait a little and try
- // again in case this is caused by tribes synch delays
- logger.info("Repeating endpoint reference match - " + endpointReference);
- repeat--;
- try {
- Thread.sleep(1000);
- } catch(Exception ex){
- // do nothing
- repeat=0;
+ return findEndpoint(targetEndpoint.getURI());
+ }
+
+ return new ArrayList<Endpoint>();
+ }
+
+ public List<Endpoint> findEndpoint(String uri) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+
+ // in the failure case we repeat the look up after a short
+ // delay to take account of tribes replication delays
+ int repeat = FIND_REPEAT_COUNT;
+
+ while (repeat > 0){
+ for (Object v : map.values()) {
+ Endpoint endpoint = (Endpoint)v;
+ // TODO: implement more complete matching
+ logger.fine("Matching against - " + endpoint);
+ if (matches(uri, endpoint.getURI())) {
+ MapEntry entry = map.getInternal(endpoint.getURI());
+ if (!isLocal(entry)) {
+ endpoint.setRemote(true);
}
+ // if (!entry.isPrimary()) {
+ ((RuntimeEndpoint) endpoint).bind(registry, this);
+ // }
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ repeat = 0;
+ }
+ // else the service name doesn't match
+ }
+
+ if (foundEndpoints.size() == 0) {
+ // the service name doesn't match any endpoints so wait a little and try
+ // again in case this is caused by tribes synch delays
+ logger.info("Repeating endpoint reference match - " + uri);
+ repeat--;
+ try {
+ Thread.sleep(1000);
+ } catch(Exception ex){
+ // do nothing
+ repeat=0;
}
}
}
-
+
return foundEndpoints;
}
+
private boolean isLocal(MapEntry entry) {
return entry.getPrimary().equals(map.getChannel().getLocalMember(false));
}