diff options
Diffstat (limited to 'java/demo/IceGrid')
-rw-r--r-- | java/demo/IceGrid/allocate/Client.java | 430 | ||||
-rw-r--r-- | java/demo/IceGrid/allocate/HelloI.java | 2 | ||||
-rw-r--r-- | java/demo/IceGrid/allocate/Server.java | 10 | ||||
-rw-r--r-- | java/demo/IceGrid/sessionActivation/Client.java | 336 | ||||
-rw-r--r-- | java/demo/IceGrid/sessionActivation/HelloI.java | 2 | ||||
-rw-r--r-- | java/demo/IceGrid/sessionActivation/Server.java | 10 | ||||
-rw-r--r-- | java/demo/IceGrid/simple/Client.java | 82 | ||||
-rw-r--r-- | java/demo/IceGrid/simple/HelloI.java | 2 | ||||
-rw-r--r-- | java/demo/IceGrid/simple/Server.java | 10 |
9 files changed, 442 insertions, 442 deletions
diff --git a/java/demo/IceGrid/allocate/Client.java b/java/demo/IceGrid/allocate/Client.java index 23f4ed77418..806f95b6f73 100644 --- a/java/demo/IceGrid/allocate/Client.java +++ b/java/demo/IceGrid/allocate/Client.java @@ -13,257 +13,257 @@ public class Client extends Ice.Application { class ShutdownHook extends Thread { - public void - run() - { - cleanup(); - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } + public void + run() + { + cleanup(); + try + { + communicator().destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } } static private class SessionKeepAliveThread extends Thread { SessionKeepAliveThread(IceGrid.SessionPrx session, long timeout) - { - _session = session; - _timeout = timeout; - _terminated = false; - } + { + _session = session; + _timeout = timeout; + _terminated = false; + } - synchronized public void - run() - { - while(!_terminated) - { - try - { - wait(_timeout); - } - catch(InterruptedException e) - { - } - if(_terminated) - { - break; - } - try - { - _session.keepAlive(); - } - catch(Ice.LocalException ex) - { - break; - } - } - } + synchronized public void + run() + { + while(!_terminated) + { + try + { + wait(_timeout); + } + catch(InterruptedException e) + { + } + if(_terminated) + { + break; + } + try + { + _session.keepAlive(); + } + catch(Ice.LocalException ex) + { + break; + } + } + } - synchronized private void - terminate() - { - _terminated = true; - notify(); - } + synchronized private void + terminate() + { + _terminated = true; + notify(); + } - final private IceGrid.SessionPrx _session; - final private long _timeout; - private boolean _terminated; + final private IceGrid.SessionPrx _session; + final private long _timeout; + private boolean _terminated; } private void menu() { - System.out.println( - "usage:\n" + - "t: send greeting\n" + - "s: shutdown server\n" + - "x: exit\n" + - "?: help\n"); + System.out.println( + "usage:\n" + + "t: send greeting\n" + + "s: shutdown server\n" + + "x: exit\n" + + "?: help\n"); } public int run(String[] args) { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); + // + // Since this is an interactive demo we want to clear the + // Application installed interrupt callback and install our + // own shutdown hook. + // + setInterruptHook(new ShutdownHook()); - int status = 0; - IceGrid.RegistryPrx registry = - IceGrid.RegistryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Registry")); - if(registry == null) - { - System.err.println("could not contact registry"); - return 1; - } + int status = 0; + IceGrid.RegistryPrx registry = + IceGrid.RegistryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Registry")); + if(registry == null) + { + System.err.println("could not contact registry"); + return 1; + } - java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - while(true) - { - System.out.println("This demo accepts any user-id / password combination."); + java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); + while(true) + { + System.out.println("This demo accepts any user-id / password combination."); - try - { - String id; - System.out.print("user id: "); - System.out.flush(); - id = in.readLine(); - - String pw; - System.out.print("password: "); - System.out.flush(); - pw = in.readLine(); - - try - { - synchronized(this) - { - _session = registry.createSession(id, pw); - } - break; - } - catch(IceGrid.PermissionDeniedException ex) - { - System.out.println("permission denied:\n" + ex.reason); - } - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - } + try + { + String id; + System.out.print("user id: "); + System.out.flush(); + id = in.readLine(); + + String pw; + System.out.print("password: "); + System.out.flush(); + pw = in.readLine(); + + try + { + synchronized(this) + { + _session = registry.createSession(id, pw); + } + break; + } + catch(IceGrid.PermissionDeniedException ex) + { + System.out.println("permission denied:\n" + ex.reason); + } + } + catch(java.io.IOException ex) + { + ex.printStackTrace(); + } + } - synchronized(this) - { - _keepAlive = new SessionKeepAliveThread(_session, registry.getSessionTimeout() / 2); - _keepAlive.start(); - } + synchronized(this) + { + _keepAlive = new SessionKeepAliveThread(_session, registry.getSessionTimeout() / 2); + _keepAlive.start(); + } - try - { - // - // First try to retrieve object by identity, which will - // work if the application-single.xml descriptor is - // used. Otherwise we retrieve object by type, which will - // succeed if the application-multiple.xml descriptor is - // used. - // - HelloPrx hello; - try - { - hello = HelloPrxHelper.checkedCast( - _session.allocateObjectById(communicator().stringToIdentity("hello"))); - } - catch(IceGrid.ObjectNotRegisteredException ex) - { - hello = HelloPrxHelper.checkedCast(_session.allocateObjectByType("::Demo::Hello")); - } + try + { + // + // First try to retrieve object by identity, which will + // work if the application-single.xml descriptor is + // used. Otherwise we retrieve object by type, which will + // succeed if the application-multiple.xml descriptor is + // used. + // + HelloPrx hello; + try + { + hello = HelloPrxHelper.checkedCast( + _session.allocateObjectById(communicator().stringToIdentity("hello"))); + } + catch(IceGrid.ObjectNotRegisteredException ex) + { + hello = HelloPrxHelper.checkedCast(_session.allocateObjectByType("::Demo::Hello")); + } - menu(); - - String line = null; - do - { - try - { - System.out.print("==> "); - System.out.flush(); - line = in.readLine(); - if(line == null) - { - break; - } - if(line.equals("t")) - { - hello.sayHello(); - } - else if(line.equals("s")) - { - hello.shutdown(); - } - else if(line.equals("x")) - { - // Nothing to do - } - else if(line.equals("?")) - { - menu(); - } - else - { - System.out.println("unknown command `" + line + "'"); - menu(); - } - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - while(!line.equals("x")); - } - catch(IceGrid.AllocationException ex) - { - System.err.println("could not allocate object: " + ex.reason); - status = 1; - } - catch(Exception ex) - { - System.err.println("expected exception: " + ex); - status = 1; - } + menu(); + + String line = null; + do + { + try + { + System.out.print("==> "); + System.out.flush(); + line = in.readLine(); + if(line == null) + { + break; + } + if(line.equals("t")) + { + hello.sayHello(); + } + else if(line.equals("s")) + { + hello.shutdown(); + } + else if(line.equals("x")) + { + // Nothing to do + } + else if(line.equals("?")) + { + menu(); + } + else + { + System.out.println("unknown command `" + line + "'"); + menu(); + } + } + catch(java.io.IOException ex) + { + ex.printStackTrace(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } + while(!line.equals("x")); + } + catch(IceGrid.AllocationException ex) + { + System.err.println("could not allocate object: " + ex.reason); + status = 1; + } + catch(Exception ex) + { + System.err.println("expected exception: " + ex); + status = 1; + } - cleanup(); + cleanup(); - return status; + return status; } synchronized void cleanup() { - // - // Destroy the keepAlive thread and the sesion object otherwise - // the session will be kept allocated until the timeout occurs. - // Destroying the session will release all allocated objects. - // - if(_keepAlive != null) - { - _keepAlive.terminate(); - try - { - _keepAlive.join(); - } - catch(InterruptedException e) - { - } - _keepAlive = null; - } - if(_session != null) - { - _session.destroy(); - _session = null; - } + // + // Destroy the keepAlive thread and the sesion object otherwise + // the session will be kept allocated until the timeout occurs. + // Destroying the session will release all allocated objects. + // + if(_keepAlive != null) + { + _keepAlive.terminate(); + try + { + _keepAlive.join(); + } + catch(InterruptedException e) + { + } + _keepAlive = null; + } + if(_session != null) + { + _session.destroy(); + _session = null; + } } public static void main(String[] args) { - Client app = new Client(); - int status = app.main("Client", args, "config.client"); - System.exit(status); + Client app = new Client(); + int status = app.main("Client", args, "config.client"); + System.exit(status); } SessionKeepAliveThread _keepAlive; diff --git a/java/demo/IceGrid/allocate/HelloI.java b/java/demo/IceGrid/allocate/HelloI.java index cece7b2bc8b..39bfae4682d 100644 --- a/java/demo/IceGrid/allocate/HelloI.java +++ b/java/demo/IceGrid/allocate/HelloI.java @@ -13,7 +13,7 @@ public class HelloI extends _HelloDisp { public HelloI(String name) { - _name = name; + _name = name; } public void diff --git a/java/demo/IceGrid/allocate/Server.java b/java/demo/IceGrid/allocate/Server.java index b622578f9f4..1c7722e7a71 100644 --- a/java/demo/IceGrid/allocate/Server.java +++ b/java/demo/IceGrid/allocate/Server.java @@ -13,8 +13,8 @@ public class Server extends Ice.Application run(String[] args) { Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - Ice.Properties properties = communicator().getProperties(); - Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity")); + Ice.Properties properties = communicator().getProperties(); + Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity")); adapter.add(new HelloI(properties.getProperty("Ice.ServerId")), id); adapter.activate(); communicator().waitForShutdown(); @@ -24,8 +24,8 @@ public class Server extends Ice.Application static public void main(String[] args) { - Server app = new Server(); - int status = app.main("Server", args); - System.exit(status); + Server app = new Server(); + int status = app.main("Server", args); + System.exit(status); } } diff --git a/java/demo/IceGrid/sessionActivation/Client.java b/java/demo/IceGrid/sessionActivation/Client.java index b77fbd9fa13..f16c19c13a0 100644 --- a/java/demo/IceGrid/sessionActivation/Client.java +++ b/java/demo/IceGrid/sessionActivation/Client.java @@ -13,33 +13,33 @@ public class Client extends Ice.Application { class ShutdownHook extends Thread { - public void - run() - { - cleanup(); - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } + public void + run() + { + cleanup(); + try + { + communicator().destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } } static private class SessionKeepAliveThread extends Thread { SessionKeepAliveThread(IceGrid.SessionPrx session, long timeout) - { - _session = session; - _timeout = timeout; - _terminated = false; - } + { + _session = session; + _timeout = timeout; + _terminated = false; + } - synchronized public void - run() - { + synchronized public void + run() + { while(!_terminated) { try @@ -51,29 +51,29 @@ public class Client extends Ice.Application } if(_terminated) { - break; - } + break; + } try { _session.keepAlive(); } catch(Ice.LocalException ex) { - break; + break; } } - } + } - synchronized private void - terminate() - { - _terminated = true; - notify(); - } + synchronized private void + terminate() + { + _terminated = true; + notify(); + } - final private IceGrid.SessionPrx _session; - final private long _timeout; - private boolean _terminated; + final private IceGrid.SessionPrx _session; + final private long _timeout; + private boolean _terminated; } private void @@ -89,129 +89,129 @@ public class Client extends Ice.Application public int run(String[] args) { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); + // + // Since this is an interactive demo we want to clear the + // Application installed interrupt callback and install our + // own shutdown hook. + // + setInterruptHook(new ShutdownHook()); - int status = 0; + int status = 0; IceGrid.RegistryPrx registry = - IceGrid.RegistryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Registry")); - if(registry == null) - { + IceGrid.RegistryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Registry")); + if(registry == null) + { System.err.println("could not contact registry"); - return 1; - } + return 1; + } java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in)); - while(true) - { - System.out.println("This demo accepts any user-id / password combination."); + while(true) + { + System.out.println("This demo accepts any user-id / password combination."); - try - { - String id; - System.out.print("user id: "); - System.out.flush(); - id = in.readLine(); - - String pw; - System.out.print("password: "); - System.out.flush(); - pw = in.readLine(); - - try - { - synchronized(this) - { - _session = registry.createSession(id, pw); - } - break; - } - catch(IceGrid.PermissionDeniedException ex) - { - System.out.println("permission denied:\n" + ex.reason); - } - } + try + { + String id; + System.out.print("user id: "); + System.out.flush(); + id = in.readLine(); + + String pw; + System.out.print("password: "); + System.out.flush(); + pw = in.readLine(); + + try + { + synchronized(this) + { + _session = registry.createSession(id, pw); + } + break; + } + catch(IceGrid.PermissionDeniedException ex) + { + System.out.println("permission denied:\n" + ex.reason); + } + } catch(java.io.IOException ex) { ex.printStackTrace(); } - } + } - synchronized(this) - { - _keepAlive = new SessionKeepAliveThread(_session, registry.getSessionTimeout() / 2); - _keepAlive.start(); - } + synchronized(this) + { + _keepAlive = new SessionKeepAliveThread(_session, registry.getSessionTimeout() / 2); + _keepAlive.start(); + } - try - { - HelloPrx hello = HelloPrxHelper.checkedCast( - _session.allocateObjectById(communicator().stringToIdentity("hello"))); + try + { + HelloPrx hello = HelloPrxHelper.checkedCast( + _session.allocateObjectById(communicator().stringToIdentity("hello"))); - menu(); - - String line = null; - do - { - try - { - System.out.print("==> "); - System.out.flush(); - line = in.readLine(); - if(line == null) - { - break; - } - if(line.equals("t")) - { - hello.sayHello(); - } - else if(line.equals("x")) - { - // Nothing to do - } - else if(line.equals("?")) - { - menu(); - } - else - { - System.out.println("unknown command `" + line + "'"); - menu(); - } - } - catch(java.io.IOException ex) - { - ex.printStackTrace(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } - while(!line.equals("x")); - } - catch(IceGrid.AllocationException ex) - { - System.err.println("could not allocate object: " + ex.reason); - status = 1; - } - catch(IceGrid.ObjectNotRegisteredException ex) - { - System.err.println("object not registered with registry"); - status = 1; - } - catch(Exception ex) - { - System.err.println("expected exception: " + ex); - status = 1; - } + menu(); + + String line = null; + do + { + try + { + System.out.print("==> "); + System.out.flush(); + line = in.readLine(); + if(line == null) + { + break; + } + if(line.equals("t")) + { + hello.sayHello(); + } + else if(line.equals("x")) + { + // Nothing to do + } + else if(line.equals("?")) + { + menu(); + } + else + { + System.out.println("unknown command `" + line + "'"); + menu(); + } + } + catch(java.io.IOException ex) + { + ex.printStackTrace(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } + while(!line.equals("x")); + } + catch(IceGrid.AllocationException ex) + { + System.err.println("could not allocate object: " + ex.reason); + status = 1; + } + catch(IceGrid.ObjectNotRegisteredException ex) + { + System.err.println("object not registered with registry"); + status = 1; + } + catch(Exception ex) + { + System.err.println("expected exception: " + ex); + status = 1; + } - cleanup(); + cleanup(); return status; } @@ -219,36 +219,36 @@ public class Client extends Ice.Application synchronized void cleanup() { - // - // Destroy the keepAlive thread and the sesion object otherwise - // the session will be kept allocated until the timeout occurs. - // Destroying the session will release all allocated objects. - // - if(_keepAlive != null) - { - _keepAlive.terminate(); - try - { - _keepAlive.join(); - } - catch(InterruptedException e) - { - } - _keepAlive = null; - } - if(_session != null) - { - _session.destroy(); - _session = null; - } + // + // Destroy the keepAlive thread and the sesion object otherwise + // the session will be kept allocated until the timeout occurs. + // Destroying the session will release all allocated objects. + // + if(_keepAlive != null) + { + _keepAlive.terminate(); + try + { + _keepAlive.join(); + } + catch(InterruptedException e) + { + } + _keepAlive = null; + } + if(_session != null) + { + _session.destroy(); + _session = null; + } } public static void main(String[] args) { - Client app = new Client(); - int status = app.main("Client", args, "config.client"); - System.exit(status); + Client app = new Client(); + int status = app.main("Client", args, "config.client"); + System.exit(status); } SessionKeepAliveThread _keepAlive; diff --git a/java/demo/IceGrid/sessionActivation/HelloI.java b/java/demo/IceGrid/sessionActivation/HelloI.java index a7906b1237c..9d24965de41 100644 --- a/java/demo/IceGrid/sessionActivation/HelloI.java +++ b/java/demo/IceGrid/sessionActivation/HelloI.java @@ -13,7 +13,7 @@ public class HelloI extends _HelloDisp { public HelloI(String name) { - _name = name; + _name = name; } public void diff --git a/java/demo/IceGrid/sessionActivation/Server.java b/java/demo/IceGrid/sessionActivation/Server.java index b622578f9f4..1c7722e7a71 100644 --- a/java/demo/IceGrid/sessionActivation/Server.java +++ b/java/demo/IceGrid/sessionActivation/Server.java @@ -13,8 +13,8 @@ public class Server extends Ice.Application run(String[] args) { Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - Ice.Properties properties = communicator().getProperties(); - Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity")); + Ice.Properties properties = communicator().getProperties(); + Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity")); adapter.add(new HelloI(properties.getProperty("Ice.ServerId")), id); adapter.activate(); communicator().waitForShutdown(); @@ -24,8 +24,8 @@ public class Server extends Ice.Application static public void main(String[] args) { - Server app = new Server(); - int status = app.main("Server", args); - System.exit(status); + Server app = new Server(); + int status = app.main("Server", args); + System.exit(status); } } diff --git a/java/demo/IceGrid/simple/Client.java b/java/demo/IceGrid/simple/Client.java index d877a201051..58ed8b8a64d 100644 --- a/java/demo/IceGrid/simple/Client.java +++ b/java/demo/IceGrid/simple/Client.java @@ -13,18 +13,18 @@ public class Client extends Ice.Application { class ShutdownHook extends Thread { - public void - run() - { - try - { - communicator().destroy(); - } - catch(Ice.LocalException ex) - { - ex.printStackTrace(); - } - } + public void + run() + { + try + { + communicator().destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } } private void @@ -41,34 +41,34 @@ public class Client extends Ice.Application public int run(String[] args) { - // - // Since this is an interactive demo we want to clear the - // Application installed interrupt callback and install our - // own shutdown hook. - // - setInterruptHook(new ShutdownHook()); + // + // Since this is an interactive demo we want to clear the + // Application installed interrupt callback and install our + // own shutdown hook. + // + setInterruptHook(new ShutdownHook()); - // - // 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. - // - HelloPrx hello = null; - try - { - hello = HelloPrxHelper.checkedCast(communicator().stringToProxy("hello")); - } - catch(Ice.NotRegisteredException ex) - { - IceGrid.QueryPrx query = - IceGrid.QueryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Query")); - hello = HelloPrxHelper.checkedCast(query.findObjectByType("::Demo::Hello")); - } - if(hello == null) - { + // + // 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. + // + HelloPrx hello = null; + try + { + hello = HelloPrxHelper.checkedCast(communicator().stringToProxy("hello")); + } + catch(Ice.NotRegisteredException ex) + { + IceGrid.QueryPrx query = + IceGrid.QueryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Query")); + hello = HelloPrxHelper.checkedCast(query.findObjectByType("::Demo::Hello")); + } + if(hello == null) + { System.err.println("couldn't find a `::Demo::Hello' object"); - return 1; - } + return 1; + } menu(); @@ -125,8 +125,8 @@ public class Client extends Ice.Application public static void main(String[] args) { - Client app = new Client(); - int status = app.main("Client", args, "config.client"); - System.exit(status); + Client app = new Client(); + int status = app.main("Client", args, "config.client"); + System.exit(status); } } diff --git a/java/demo/IceGrid/simple/HelloI.java b/java/demo/IceGrid/simple/HelloI.java index cece7b2bc8b..39bfae4682d 100644 --- a/java/demo/IceGrid/simple/HelloI.java +++ b/java/demo/IceGrid/simple/HelloI.java @@ -13,7 +13,7 @@ public class HelloI extends _HelloDisp { public HelloI(String name) { - _name = name; + _name = name; } public void diff --git a/java/demo/IceGrid/simple/Server.java b/java/demo/IceGrid/simple/Server.java index b622578f9f4..1c7722e7a71 100644 --- a/java/demo/IceGrid/simple/Server.java +++ b/java/demo/IceGrid/simple/Server.java @@ -13,8 +13,8 @@ public class Server extends Ice.Application run(String[] args) { Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - Ice.Properties properties = communicator().getProperties(); - Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity")); + Ice.Properties properties = communicator().getProperties(); + Ice.Identity id = communicator().stringToIdentity(properties.getProperty("Identity")); adapter.add(new HelloI(properties.getProperty("Ice.ServerId")), id); adapter.activate(); communicator().waitForShutdown(); @@ -24,8 +24,8 @@ public class Server extends Ice.Application static public void main(String[] args) { - Server app = new Server(); - int status = app.main("Server", args); - System.exit(status); + Server app = new Server(); + int status = app.main("Server", args); + System.exit(status); } } |