summaryrefslogtreecommitdiff
path: root/same/src/main/java/com/orbekk
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 13:47:26 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-01-27 13:47:26 +0100
commit3d0ddd70342bee8826997e9a2343a5741e243a0d (patch)
treea464317e76395d2177010ebbdd2487c0b52e07c6 /same/src/main/java/com/orbekk
parent52c1e7a6643d4a010c5571f565386440e17fe5e6 (diff)
ClientService supports network discovery.
Diffstat (limited to 'same/src/main/java/com/orbekk')
-rw-r--r--same/src/main/java/com/orbekk/same/ClientServiceImpl.java19
-rw-r--r--same/src/main/java/com/orbekk/same/NetworkNotificationListener.java5
2 files changed, 19 insertions, 5 deletions
diff --git a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
index 43c8b2f..8aaaa95 100644
--- a/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
+++ b/same/src/main/java/com/orbekk/same/ClientServiceImpl.java
@@ -9,7 +9,8 @@ public class ClientServiceImpl implements ClientService, UrlReceiver {
private ConnectionManager connections;
private State state;
private String myUrl = null;
- private StateChangedListener listener;
+ private StateChangedListener stateListener;
+ private NetworkNotificationListener networkListener;
public ClientServiceImpl(State state, ConnectionManager connections) {
this.state = state;
@@ -18,15 +19,19 @@ public class ClientServiceImpl implements ClientService, UrlReceiver {
@Override
public void notifyNetwork(String networkName, String masterUrl) {
- logger.error("NotifyNetwork not yet implemented.");
+ logger.info("NotifyNetwork(networkName={}, masterUrl={})",
+ networkName, masterUrl);
+ if (networkListener != null) {
+ networkListener.notifyNetwork(networkName, masterUrl);
+ }
}
@Override
public void setState(String component, String data, long revision) {
boolean status = state.update(component, data, revision);
if (status) {
- if (listener != null) {
- listener.stateChanged(component, data);
+ if (stateListener != null) {
+ stateListener.stateChanged(component, data);
}
} else {
logger.warn("Ignoring update: {}",
@@ -93,6 +98,10 @@ public class ClientServiceImpl implements ClientService, UrlReceiver {
}
public void setStateChangedListener(StateChangedListener listener) {
- this.listener = listener;
+ this.stateListener = listener;
+ }
+
+ public void setNetworkListener(NetworkNotificationListener listener) {
+ this.networkListener = listener;
}
}
diff --git a/same/src/main/java/com/orbekk/same/NetworkNotificationListener.java b/same/src/main/java/com/orbekk/same/NetworkNotificationListener.java
new file mode 100644
index 0000000..14c758f
--- /dev/null
+++ b/same/src/main/java/com/orbekk/same/NetworkNotificationListener.java
@@ -0,0 +1,5 @@
+package com.orbekk.same;
+
+public interface NetworkNotificationListener {
+ void notifyNetwork(String networkName, String masterUrl);
+}