summaryrefslogtreecommitdiff
path: root/jsonrpc/src/main/java/com/orbekk/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'jsonrpc/src/main/java/com/orbekk/rpc')
-rw-r--r--jsonrpc/src/main/java/com/orbekk/rpc/App.java19
-rw-r--r--jsonrpc/src/main/java/com/orbekk/rpc/Client.java16
-rw-r--r--jsonrpc/src/main/java/com/orbekk/rpc/PingService.java5
-rw-r--r--jsonrpc/src/main/java/com/orbekk/rpc/PingServiceImpl.java8
4 files changed, 25 insertions, 23 deletions
diff --git a/jsonrpc/src/main/java/com/orbekk/rpc/App.java b/jsonrpc/src/main/java/com/orbekk/rpc/App.java
index e112008..ffd316d 100644
--- a/jsonrpc/src/main/java/com/orbekk/rpc/App.java
+++ b/jsonrpc/src/main/java/com/orbekk/rpc/App.java
@@ -1,15 +1,24 @@
package com.orbekk.rpc;
-import org.eclipse.jetty.server.Server;
-
import com.googlecode.jsonrpc4j.JsonRpcServer;
+import com.orbekk.same.SameService;
+import com.orbekk.same.SameServiceImpl;
+import org.eclipse.jetty.server.Server;
public class App {
public static void main(String[] args) {
- PingService service = new PingServiceImpl();
- JsonRpcServer jsonServer = new JsonRpcServer(service, PingService.class);
+ if (args.length < 2) {
+ System.err.println("Arguments: port networkName");
+ System.exit(1);
+ }
+ int port = Integer.parseInt(args[0]);
+ String networkName = args[1];
+
+ SameService service = new SameServiceImpl(networkName);
+ JsonRpcServer jsonServer = new JsonRpcServer(service,
+ SameService.class);
- Server server = new Server(10080);
+ Server server = new Server(port);
RpcHandler rpcHandler = new RpcHandler(jsonServer);
server.setHandler(rpcHandler);
diff --git a/jsonrpc/src/main/java/com/orbekk/rpc/Client.java b/jsonrpc/src/main/java/com/orbekk/rpc/Client.java
index bfb6c52..ba77df6 100644
--- a/jsonrpc/src/main/java/com/orbekk/rpc/Client.java
+++ b/jsonrpc/src/main/java/com/orbekk/rpc/Client.java
@@ -3,23 +3,29 @@ package com.orbekk.rpc;
import java.net.MalformedURLException;
import java.net.URL;
+import com.orbekk.same.SameService;
import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
import com.googlecode.jsonrpc4j.ProxyUtil;
public class Client {
public static void main(String[] args) {
+ if (args.length < 1) {
+ System.err.println("Arguments: networkAddress");
+ System.exit(1);
+ }
+ String networkAddress = args[0];
JsonRpcHttpClient client = null;
try {
- client = new JsonRpcHttpClient(
- new URL("http://10.0.0.96:10080/PingService.json"));
+ client = new JsonRpcHttpClient(new URL(networkAddress));
} catch (MalformedURLException e) {
e.printStackTrace();
}
- PingService service = ProxyUtil.createProxy(
+ SameService service = ProxyUtil.createProxy(
client.getClass().getClassLoader(),
- PingService.class,
+ SameService.class,
client);
- System.out.println(service.ping());
+ service.notifyNetwork("NoNetwork");
+ System.out.println(service.participateNetwork("FirstNetwork"));
}
}
diff --git a/jsonrpc/src/main/java/com/orbekk/rpc/PingService.java b/jsonrpc/src/main/java/com/orbekk/rpc/PingService.java
deleted file mode 100644
index 353f7c5..0000000
--- a/jsonrpc/src/main/java/com/orbekk/rpc/PingService.java
+++ /dev/null
@@ -1,5 +0,0 @@
-package com.orbekk.rpc;
-
-public interface PingService {
- String ping();
-}
diff --git a/jsonrpc/src/main/java/com/orbekk/rpc/PingServiceImpl.java b/jsonrpc/src/main/java/com/orbekk/rpc/PingServiceImpl.java
deleted file mode 100644
index 9472846..0000000
--- a/jsonrpc/src/main/java/com/orbekk/rpc/PingServiceImpl.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.orbekk.rpc;
-
-public class PingServiceImpl implements PingService {
- @Override
- public String ping() {
- return "Pong";
- }
-}