summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--same/src/main/java/com/orbekk/same/ConnectionManager.java3
-rw-r--r--same/src/main/java/com/orbekk/same/ConnectionManagerImpl.java17
2 files changed, 15 insertions, 5 deletions
diff --git a/same/src/main/java/com/orbekk/same/ConnectionManager.java b/same/src/main/java/com/orbekk/same/ConnectionManager.java
index 985f6f0..aa4151e 100644
--- a/same/src/main/java/com/orbekk/same/ConnectionManager.java
+++ b/same/src/main/java/com/orbekk/same/ConnectionManager.java
@@ -6,5 +6,6 @@ package com.orbekk.same;
* When testing, this interface can be mocked to use local participants only.
*/
public interface ConnectionManager {
- SameService getConnection(String url);
+ ClientService getClient(String url);
+ MasterService getMaster(String url);
}
diff --git a/same/src/main/java/com/orbekk/same/ConnectionManagerImpl.java b/same/src/main/java/com/orbekk/same/ConnectionManagerImpl.java
index 841d5fa..0a1e54f 100644
--- a/same/src/main/java/com/orbekk/same/ConnectionManagerImpl.java
+++ b/same/src/main/java/com/orbekk/same/ConnectionManagerImpl.java
@@ -14,18 +14,27 @@ public class ConnectionManagerImpl implements ConnectionManager {
public ConnectionManagerImpl() {
}
- @Override
- public SameService getConnection(String url) {
- SameService service = null;
+ private <T>T getClassProxy(String url, Class<T> clazz) {
+ T service = null;
try {
JsonRpcHttpClient client = new JsonRpcHttpClient(new URL(url));
service = ProxyUtil.createProxy(
this.getClass().getClassLoader(),
- SameService.class,
+ clazz,
client);
} catch (MalformedURLException e) {
logger.warn("Unable to create client for {}, {}", url, e);
}
return service;
}
+
+ @Override
+ public ClientService getClient(String url) {
+ return getClassProxy(url, ClientService.class);
+ }
+
+ @Override
+ public MasterService getMaster(String url) {
+ return getClassProxy(url, MasterService.class);
+ }
}