summaryrefslogtreecommitdiff
path: root/java/demo/IceGrid/simple/Client.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/demo/IceGrid/simple/Client.java')
-rw-r--r--java/demo/IceGrid/simple/Client.java25
1 files changed, 23 insertions, 2 deletions
diff --git a/java/demo/IceGrid/simple/Client.java b/java/demo/IceGrid/simple/Client.java
index 1637604185b..834b4569c04 100644
--- a/java/demo/IceGrid/simple/Client.java
+++ b/java/demo/IceGrid/simple/Client.java
@@ -29,11 +29,32 @@ public class Client extends Ice.Application
properties.parseCommandLineOptions("", args);
+ //
+ // First we try to connect to the object with the `hello'
+ // identity. If it's not registered with the registry, we
+ // search for an object with the ::Demo::Hello type.
+ //
Ice.ObjectPrx base = communicator().stringToProxy(properties.getPropertyWithDefault("Identity", "hello"));
- HelloPrx twoway = HelloPrxHelper.checkedCast(base);
+ HelloPrx twoway = null;
+ try
+ {
+ twoway = HelloPrxHelper.checkedCast(base);
+ }
+ catch(Ice.NotRegisteredException ex)
+ {
+ IceGrid.QueryPrx query =
+ IceGrid.QueryPrxHelper.uncheckedCast(communicator().stringToProxy("IceGrid/Query"));
+ try
+ {
+ twoway = HelloPrxHelper.checkedCast(query.findObjectByType("::Demo::Hello"));
+ }
+ catch(IceGrid.ObjectNotExistException ex1)
+ {
+ }
+ }
if(twoway == null)
{
- System.err.println("invalid proxy");
+ System.err.println(": couldn't find a `::Demo::Hello' object.");
return 1;
}