diff options
author | Dwayne Boone <dwayne@zeroc.com> | 2007-01-17 18:11:11 +0000 |
---|---|---|
committer | Dwayne Boone <dwayne@zeroc.com> | 2007-01-17 18:11:11 +0000 |
commit | e124e693704faa56ecf32ce2a243d0c3fa3a5e6e (patch) | |
tree | 071dcaa6edc458f9371289976a4537880e5bb005 /java/demo/Ice/async/Server.java | |
parent | Changed async demo (diff) | |
download | ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.bz2 ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.tar.xz ice-e124e693704faa56ecf32ce2a243d0c3fa3a5e6e.zip |
Changed demo
Diffstat (limited to 'java/demo/Ice/async/Server.java')
-rw-r--r-- | java/demo/Ice/async/Server.java | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/java/demo/Ice/async/Server.java b/java/demo/Ice/async/Server.java index 48f9514c619..6077a8b9a34 100644 --- a/java/demo/Ice/async/Server.java +++ b/java/demo/Ice/async/Server.java @@ -11,12 +11,43 @@ import Demo.*; public class Server extends Ice.Application { + class ShutdownHook extends Thread + { + public void + run() + { + _workQueue.destroy(); + try + { + _workQueue.join(); + } + catch(java.lang.InterruptedException ex) + { + } + + try + { + communicator().destroy(); + } + catch(Ice.LocalException ex) + { + ex.printStackTrace(); + } + } + } + public int run(String[] args) { - Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Queue"); - adapter.add(new QueueI(), communicator().stringToIdentity("queue")); + setInterruptHook(new ShutdownHook()); + + Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Hello"); + _workQueue = new WorkQueue(); + adapter.add(new HelloI(_workQueue), communicator().stringToIdentity("hello")); + + _workQueue.start(); adapter.activate(); + communicator().waitForShutdown(); return 0; } @@ -28,4 +59,6 @@ public class Server extends Ice.Application int status = app.main("Server", args, "config.server"); System.exit(status); } + + private WorkQueue _workQueue; } |