summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/endpoint-tribes
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-06-12 20:57:24 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-06-12 20:57:24 +0000
commit667940fec12c91bb231d7f8ff477f9e78112b80b (patch)
tree3b3051540279487817ed2fef8bdbff6b85f0e5d6 /java/sca/modules/endpoint-tribes
parentc2b73c42cf96cb67efdf76a7c73635343a747ad3 (diff)
Add methods to Endpoint/EndpointReference to set the ExtensionPointRegistry so that deserialized object can be resolved
Make the EndpointSerializer a declared utility git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@784270 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/endpoint-tribes')
-rw-r--r--java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java55
2 files changed, 41 insertions, 15 deletions
diff --git a/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF b/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF
index a30d94554b..3d4e95d384 100644
--- a/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF
+++ b/java/sca/modules/endpoint-tribes/META-INF/MANIFEST.MF
@@ -16,6 +16,7 @@ Import-Package: org.apache.catalina.tribes,
org.apache.catalina.tribes.group,
org.apache.catalina.tribes.membership,
org.apache.catalina.tribes.tipis,
+ org.apache.juli.logging;resolution:=optional,
org.apache.tuscany.sca.assembly;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
diff --git a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
index 26fa76b14e..3d6ba89a74 100644
--- a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
+++ b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
@@ -33,6 +33,7 @@ import org.apache.catalina.tribes.group.GroupChannel;
import org.apache.catalina.tribes.membership.McastService;
import org.apache.catalina.tribes.tipis.AbstractReplicatedMap;
import org.apache.catalina.tribes.tipis.ReplicatedMap;
+import org.apache.catalina.tribes.tipis.AbstractReplicatedMap.MapEntry;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
@@ -57,6 +58,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry {
private List<EndpointReference> endpointreferences = new CopyOnWriteArrayList<EndpointReference>();
private List<EndpointListener> listeners = new CopyOnWriteArrayList<EndpointListener>();
+ private ExtensionPointRegistry registry;
private ReplicatedMap map;
private static final Channel createChannel(String address, int port, String bindAddress) {
@@ -70,15 +72,34 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry {
// REVIEW: In my case, there are multiple IP addresses
// One for the WIFI and the other one for VPN. For some reason the VPN one doesn't support
// Multicast
+ /*
+ try {
+ Enumeration<NetworkInterface> nis = NetworkInterface.getNetworkInterfaces();
+ while (nis.hasMoreElements()) {
+ NetworkInterface ni = nis.nextElement();
+ if (ni.isLoopback() || !ni.isUp() || !ni.supportsMulticast()) {
+ continue;
+ }
+ Enumeration<InetAddress> ips = ni.getInetAddresses();
+ while (ips.hasMoreElements()) {
+ InetAddress addr = ips.nextElement();
+ System.out.println(addr.getHostAddress());
+ }
+ }
+ } catch (SocketException e) {
+ e.printStackTrace();
+ }
+ */
if (bindAddress != null) {
mcastService.setBind(bindAddress);
}
- mcastService.setBind("192.168.1.100");
+ // mcastService.setBind("192.168.1.100");
return channel;
}
public ReplicatedEndpointRegistry(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ this.registry = registry;
String portStr = attributes.get("port");
if (portStr != null) {
port = Integer.parseInt(portStr);
@@ -111,8 +132,18 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry {
}
}
+ public void stop() {
+ Channel channel = map.getChannel();
+ map.breakdown();
+ try {
+ channel.stop(Channel.DEFAULT);
+ } catch (ChannelException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
public void addEndpoint(Endpoint endpoint) {
- map.put(getURI(endpoint), endpoint);
+ map.put(endpoint.getURI(), endpoint);
for (EndpointListener listener : listeners) {
listener.endpointAdded(endpoint);
}
@@ -183,6 +214,10 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry {
Endpoint endpoint = (Endpoint)v;
// TODO: implement more complete matching
if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
+ MapEntry entry = map.getInternal(endpoint.getURI());
+ if (!entry.isPrimary()) {
+ endpoint.setExtensionPointRegistry(registry);
+ }
foundEndpoints.add(endpoint);
logger.info("EndpointRegistry: Found endpoint with matching service - " + endpoint);
}
@@ -212,18 +247,8 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry {
return listeners;
}
- private String getURI(Endpoint ep) {
- String bindingName = ep.getBinding().getName();
- if (bindingName == null) {
- bindingName = ep.getService().getName();
- }
- String epURI =
- ep.getComponent().getURI() + "#service-binding(" + ep.getService().getName() + "/" + bindingName + ")";
- return epURI;
- }
-
public void removeEndpoint(Endpoint endpoint) {
- map.remove(getURI(endpoint));
+ map.remove(endpoint.getURI());
for (EndpointListener listener : listeners) {
listener.endpointRemoved(endpoint);
}
@@ -244,7 +269,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry {
if (oldEndpoint == null) {
throw new IllegalArgumentException("Endpoint is not found: " + uri);
}
- map.put(getURI(endpoint), endpoint);
+ map.put(endpoint.getURI(), endpoint);
for (EndpointListener listener : listeners) {
listener.endpointUpdated(oldEndpoint, endpoint);
}
@@ -273,7 +298,7 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry {
for (Object e : map.entrySetFull()) {
Map.Entry en = (Map.Entry)e;
AbstractReplicatedMap.MapEntry entry = (AbstractReplicatedMap.MapEntry)en.getValue();
- entry.isPrimary();
+ System.out.println(entry);
}
map.breakdown();
channel.stop(Channel.DEFAULT);