diff options
Diffstat (limited to 'java/demo/Ice/async/Server.java')
-rw-r--r-- | java/demo/Ice/async/Server.java | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/java/demo/Ice/async/Server.java b/java/demo/Ice/async/Server.java new file mode 100644 index 00000000000..2c9da532fba --- /dev/null +++ b/java/demo/Ice/async/Server.java @@ -0,0 +1,63 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +import Demo.*; + +public class Server extends Ice.Application +{ + class ShutdownHook extends Thread + { + public void + run() + { + _workQueue._destroy(); + communicator().shutdown(); + } + } + + public int + run(String[] args) + { + if(args.length > 0) + { + System.err.println(appName() + ": too many arguments"); + return 1; + } + + 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(); + + try + { + _workQueue.join(); + } + catch(java.lang.InterruptedException ex) + { + } + + return 0; + } + + public static void + main(String[] args) + { + Server app = new Server(); + int status = app.main("Server", args, "config.server"); + System.exit(status); + } + + private WorkQueue _workQueue; +} |