diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-11 10:47:27 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-01-11 10:47:27 +0100 |
commit | 52088a08a9edb6d4b60e1e8923e1b3199db9f391 (patch) | |
tree | 191f3bbde90eb14b011c772c27a5f67aff28049e /jsonrpc/src/main/java/com/orbekk/same/ConnectionManagerImpl.java | |
parent | 5befe48a4cca6121cbce7f7fd5436cfc09f643f0 (diff) |
Continue SameService implementation.
- Implement ConnectionManager.
- SameService now calls notifyParticipation() when a client tries to
join.
- Add client ids – this may or may not be a good idea.
- Refactor App and Client code.
Diffstat (limited to 'jsonrpc/src/main/java/com/orbekk/same/ConnectionManagerImpl.java')
-rw-r--r-- | jsonrpc/src/main/java/com/orbekk/same/ConnectionManagerImpl.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/jsonrpc/src/main/java/com/orbekk/same/ConnectionManagerImpl.java b/jsonrpc/src/main/java/com/orbekk/same/ConnectionManagerImpl.java index e3a6928..841d5fa 100644 --- a/jsonrpc/src/main/java/com/orbekk/same/ConnectionManagerImpl.java +++ b/jsonrpc/src/main/java/com/orbekk/same/ConnectionManagerImpl.java @@ -1,16 +1,31 @@ package com.orbekk.same; +import com.googlecode.jsonrpc4j.JsonRpcHttpClient; +import com.googlecode.jsonrpc4j.ProxyUtil; +import java.net.MalformedURLException; +import java.net.URL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ConnectionManagerImpl { +public class ConnectionManagerImpl implements ConnectionManager { + private Logger logger = LoggerFactory.getLogger(getClass()); public ConnectionManagerImpl() { } - SameService getConnection(String url) { - // TODO: Implement this class. - return null; + @Override + public SameService getConnection(String url) { + SameService service = null; + try { + JsonRpcHttpClient client = new JsonRpcHttpClient(new URL(url)); + service = ProxyUtil.createProxy( + this.getClass().getClassLoader(), + SameService.class, + client); + } catch (MalformedURLException e) { + logger.warn("Unable to create client for {}, {}", url, e); + } + return service; } } |