diff options
Diffstat (limited to 'java/demo/Ice/async')
-rw-r--r-- | java/demo/Ice/async/Client.java | 44 | ||||
-rw-r--r-- | java/demo/Ice/async/HelloI.java | 34 | ||||
-rw-r--r-- | java/demo/Ice/async/Server.java | 22 | ||||
-rw-r--r-- | java/demo/Ice/async/WorkQueue.java | 142 |
4 files changed, 121 insertions, 121 deletions
diff --git a/java/demo/Ice/async/Client.java b/java/demo/Ice/async/Client.java index 3a89d037dd2..d87aee7e8a1 100644 --- a/java/demo/Ice/async/Client.java +++ b/java/demo/Ice/async/Client.java @@ -30,25 +30,25 @@ public class Client extends Ice.Application public class AMI_Hello_sayHelloI extends AMI_Hello_sayHello { public void ice_response() - { - } + { + } - public void ice_exception(Ice.LocalException ex) - { - ex.printStackTrace(); - } + public void ice_exception(Ice.LocalException ex) + { + ex.printStackTrace(); + } - public void ice_exception(Ice.UserException ex) - { - if(ex instanceof Demo.RequestCanceledException) - { - System.out.println("Request canceled"); - } - else - { - ex.printStackTrace(); - } - } + public void ice_exception(Ice.UserException ex) + { + if(ex instanceof Demo.RequestCanceledException) + { + System.out.println("Request canceled"); + } + else + { + ex.printStackTrace(); + } + } } private static void @@ -71,7 +71,7 @@ public class Client extends Ice.Application // Application installed interrupt callback and install our // own shutdown hook. // - setInterruptHook(new ShutdownHook()); + setInterruptHook(new ShutdownHook()); HelloPrx hello = HelloPrxHelper.checkedCast(communicator().propertyToProxy("Hello.Proxy")); if(hello == null) @@ -98,16 +98,16 @@ public class Client extends Ice.Application } if(line.equals("i")) { - hello.sayHello(0); + hello.sayHello(0); } else if(line.equals("d")) { hello.sayHello_async(new AMI_Hello_sayHelloI(), 5000); - } + } else if(line.equals("s")) { - hello.shutdown(); - } + hello.shutdown(); + } else if(line.equals("x")) { // Nothing to do diff --git a/java/demo/Ice/async/HelloI.java b/java/demo/Ice/async/HelloI.java index ce555b3e9dd..9df4d2c71cc 100644 --- a/java/demo/Ice/async/HelloI.java +++ b/java/demo/Ice/async/HelloI.java @@ -21,14 +21,14 @@ public class HelloI extends _HelloDisp sayHello_async(AMD_Hello_sayHello cb, int delay, Ice.Current current) { if(delay == 0) - { - System.out.println("Hello World!"); - cb.ice_response(); - } - else - { - _workQueue.add(cb, delay); - } + { + System.out.println("Hello World!"); + cb.ice_response(); + } + else + { + _workQueue.add(cb, delay); + } } public void @@ -36,16 +36,16 @@ public class HelloI extends _HelloDisp { System.out.println("Shutting down..."); - _workQueue.destroy(); - try - { - _workQueue.join(); - } - catch(java.lang.InterruptedException ex) - { - } + _workQueue.destroy(); + try + { + _workQueue.join(); + } + catch(java.lang.InterruptedException ex) + { + } - current.adapter.getCommunicator().shutdown(); + current.adapter.getCommunicator().shutdown(); } private WorkQueue _workQueue; diff --git a/java/demo/Ice/async/Server.java b/java/demo/Ice/async/Server.java index 6077a8b9a34..25ba4e2baac 100644 --- a/java/demo/Ice/async/Server.java +++ b/java/demo/Ice/async/Server.java @@ -16,14 +16,14 @@ public class Server extends Ice.Application public void run() { - _workQueue.destroy(); - try - { - _workQueue.join(); - } - catch(java.lang.InterruptedException ex) - { - } + _workQueue.destroy(); + try + { + _workQueue.join(); + } + catch(java.lang.InterruptedException ex) + { + } try { @@ -39,13 +39,13 @@ public class Server extends Ice.Application public int run(String[] args) { - setInterruptHook(new ShutdownHook()); + setInterruptHook(new ShutdownHook()); Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); - _workQueue = new WorkQueue(); + _workQueue = new WorkQueue(); adapter.add(new HelloI(_workQueue), communicator().stringToIdentity("hello")); - _workQueue.start(); + _workQueue.start(); adapter.activate(); communicator().waitForShutdown(); diff --git a/java/demo/Ice/async/WorkQueue.java b/java/demo/Ice/async/WorkQueue.java index 036a1978b49..bc18061058a 100644 --- a/java/demo/Ice/async/WorkQueue.java +++ b/java/demo/Ice/async/WorkQueue.java @@ -14,100 +14,100 @@ public class WorkQueue extends Thread class CallbackEntry { AMD_Hello_sayHello cb; - int delay; + int delay; } public synchronized void run() { while(!_done) - { - if(_callbacks.size() == 0) - { - try - { - wait(); - } - catch(java.lang.InterruptedException ex) - { - } - } + { + if(_callbacks.size() == 0) + { + try + { + wait(); + } + catch(java.lang.InterruptedException ex) + { + } + } - if(_callbacks.size() != 0) - { - // - // Get next work item. - // - CallbackEntry entry = (CallbackEntry)_callbacks.getFirst(); + if(_callbacks.size() != 0) + { + // + // Get next work item. + // + CallbackEntry entry = (CallbackEntry)_callbacks.getFirst(); - // - // Wait for the amount of time indicated in delay to - // emulate a process that takes a significant period of - // time to complete. - // - try - { - wait(entry.delay); - } - catch(java.lang.InterruptedException ex) - { - } + // + // Wait for the amount of time indicated in delay to + // emulate a process that takes a significant period of + // time to complete. + // + try + { + wait(entry.delay); + } + catch(java.lang.InterruptedException ex) + { + } - if(!_done) - { - // - // Print greeting and send response. - // - _callbacks.removeFirst(); - System.err.println("Belated Hello World!"); - entry.cb.ice_response(); - } - } - } + if(!_done) + { + // + // Print greeting and send response. + // + _callbacks.removeFirst(); + System.err.println("Belated Hello World!"); + entry.cb.ice_response(); + } + } + } - // - // Throw exception for any outstanding requests. - // - java.util.Iterator p = _callbacks.iterator(); - while(p.hasNext()) - { - CallbackEntry entry = (CallbackEntry)p.next(); - entry.cb.ice_exception(new RequestCanceledException()); - } + // + // Throw exception for any outstanding requests. + // + java.util.Iterator p = _callbacks.iterator(); + while(p.hasNext()) + { + CallbackEntry entry = (CallbackEntry)p.next(); + entry.cb.ice_exception(new RequestCanceledException()); + } } public synchronized void add(AMD_Hello_sayHello cb, int delay) { if(!_done) - { - // - // Add the work item. - // - CallbackEntry entry = new CallbackEntry(); - entry.cb = cb; - entry.delay = delay; + { + // + // Add the work item. + // + CallbackEntry entry = new CallbackEntry(); + entry.cb = cb; + entry.delay = delay; - if(_callbacks.size() == 0) - { - notify(); - } - _callbacks.add(entry); - } - else - { - // - // Destroyed, throw exception. - // - cb.ice_exception(new RequestCanceledException()); - } + if(_callbacks.size() == 0) + { + notify(); + } + _callbacks.add(entry); + } + else + { + // + // Destroyed, throw exception. + // + cb.ice_exception(new RequestCanceledException()); + } } public synchronized void destroy() { _done = true; - notify(); + notify(); } private java.util.LinkedList _callbacks = new java.util.LinkedList(); |