summaryrefslogtreecommitdiff
path: root/java/demo/Ice/hello
diff options
context:
space:
mode:
Diffstat (limited to 'java/demo/Ice/hello')
-rw-r--r--java/demo/Ice/hello/Client.java45
-rw-r--r--java/demo/Ice/hello/README11
-rw-r--r--java/demo/Ice/hello/Server.java44
3 files changed, 28 insertions, 72 deletions
diff --git a/java/demo/Ice/hello/Client.java b/java/demo/Ice/hello/Client.java
index ed4b39b89ca..ba39718b957 100644
--- a/java/demo/Ice/hello/Client.java
+++ b/java/demo/Ice/hello/Client.java
@@ -9,7 +9,7 @@
import Demo.*;
-public class Client
+public class Client extends Ice.Application
{
private static void
menu()
@@ -29,10 +29,10 @@ public class Client
"?: help\n");
}
- private static int
- run(String[] args, Ice.Communicator communicator)
+ public int
+ run(String[] args)
{
- Ice.Properties properties = communicator.getProperties();
+ Ice.Properties properties = communicator().getProperties();
final String proxyProperty = "Hello.Proxy";
String proxy = properties.getProperty(proxyProperty);
if(proxy.length() == 0)
@@ -41,8 +41,8 @@ public class Client
return 1;
}
- Ice.ObjectPrx base = communicator.stringToProxy(proxy);
- HelloPrx twoway = HelloPrxHelper.checkedCast(base.ice_twoway().ice_timeout(-1).ice_secure(false));
+ HelloPrx twoway = HelloPrxHelper.checkedCast(
+ communicator().stringToProxy(proxy).ice_twoway().ice_timeout(-1).ice_secure(false));
if(twoway == null)
{
System.err.println("invalid proxy");
@@ -108,7 +108,7 @@ public class Client
}
else if(line.equals("f"))
{
- communicator.flushBatchRequests();
+ communicator().flushBatchRequests();
}
else if(line.equals("T"))
{
@@ -188,35 +188,8 @@ public class Client
public static void
main(String[] args)
{
- int status = 0;
- Ice.Communicator communicator = null;
-
- try
- {
- Ice.Properties properties = Ice.Util.createProperties();
- properties.load("config");
- communicator = Ice.Util.initializeWithProperties(args, properties);
- status = run(args, communicator);
- }
- catch(Ice.LocalException ex)
- {
- ex.printStackTrace();
- status = 1;
- }
-
- if(communicator != null)
- {
- try
- {
- communicator.destroy();
- }
- catch(Ice.LocalException ex)
- {
- ex.printStackTrace();
- status = 1;
- }
- }
-
+ Client app = new Client();
+ int status = app.main("Client", args, "config");
System.exit(status);
}
}
diff --git a/java/demo/Ice/hello/README b/java/demo/Ice/hello/README
new file mode 100644
index 00000000000..4ccfddd8f3b
--- /dev/null
+++ b/java/demo/Ice/hello/README
@@ -0,0 +1,11 @@
+This demo illustrates how to invoke ordinary (twoway)
+operations, as well as how to make oneway, datagram,
+secure, and batched invocations.
+
+To run the demo, first start the server:
+
+$ java Server
+
+In a separate window, start the client:
+
+$ java Client
diff --git a/java/demo/Ice/hello/Server.java b/java/demo/Ice/hello/Server.java
index 10bd5b1352a..b486c45d52e 100644
--- a/java/demo/Ice/hello/Server.java
+++ b/java/demo/Ice/hello/Server.java
@@ -9,51 +9,23 @@
import Demo.*;
-public class Server
+public class Server extends Ice.Application
{
- private static int
- run(String[] args, Ice.Communicator communicator)
+ public int
+ run(String[] args)
{
- Ice.ObjectAdapter adapter = communicator.createObjectAdapter("Hello");
- Ice.Object object = new HelloI();
- adapter.add(object, Ice.Util.stringToIdentity("hello"));
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello");
+ adapter.add(new HelloI(), Ice.Util.stringToIdentity("hello"));
adapter.activate();
- communicator.waitForShutdown();
+ communicator().waitForShutdown();
return 0;
}
public static void
main(String[] args)
{
- int status = 0;
- Ice.Communicator communicator = null;
-
- try
- {
- Ice.Properties properties = Ice.Util.createProperties();
- properties.load("config");
- communicator = Ice.Util.initializeWithProperties(args, properties);
- status = run(args, communicator);
- }
- catch(Ice.LocalException ex)
- {
- ex.printStackTrace();
- status = 1;
- }
-
- if(communicator != null)
- {
- try
- {
- communicator.destroy();
- }
- catch(Ice.LocalException ex)
- {
- ex.printStackTrace();
- status = 1;
- }
- }
-
+ Server app = new Server();
+ int status = app.main("Server", args, "config");
System.exit(status);
}
}