summaryrefslogtreecommitdiff
path: root/java/demo/Ice/properties/Server.java
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2012-08-30 14:43:15 +0200
committerBenoit Foucher <benoit@zeroc.com>2012-08-30 14:43:15 +0200
commitaab12cf1719b425b5a2c571b8938d47cdd71d151 (patch)
tree876561b05764721306eb8629883e7b0b9cbbc99a /java/demo/Ice/properties/Server.java
parentminor g++ warning (diff)
downloadice-aab12cf1719b425b5a2c571b8938d47cdd71d151.tar.bz2
ice-aab12cf1719b425b5a2c571b8938d47cdd71d151.tar.xz
ice-aab12cf1719b425b5a2c571b8938d47cdd71d151.zip
ICE-4774: Merged skype_props enhancement
Diffstat (limited to 'java/demo/Ice/properties/Server.java')
-rw-r--r--java/demo/Ice/properties/Server.java94
1 files changed, 94 insertions, 0 deletions
diff --git a/java/demo/Ice/properties/Server.java b/java/demo/Ice/properties/Server.java
new file mode 100644
index 00000000000..527498edc88
--- /dev/null
+++ b/java/demo/Ice/properties/Server.java
@@ -0,0 +1,94 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2010 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
+{
+ //
+ // The servant implements the Slice interface Demo::Props as well as the
+ // native callback interface Ice.PropertiesAdminUpdateCallback.
+ //
+ static class PropsI extends Demo._PropsDisp implements Ice.PropertiesAdminUpdateCallback
+ {
+ PropsI()
+ {
+ _called = false;
+ }
+
+ public synchronized java.util.Map<String, String> getChanges(Ice.Current current)
+ {
+ //
+ // Make sure that we have received the property updates before we
+ // return the results.
+ //
+ while(!_called)
+ {
+ try
+ {
+ wait();
+ }
+ catch(InterruptedException ex)
+ {
+ }
+ }
+
+ _called = false;
+ return _changes;
+ }
+
+ public void shutdown(Ice.Current current)
+ {
+ current.adapter.getCommunicator().shutdown();
+ }
+
+ public synchronized void updated(java.util.Map<String, String> changes)
+ {
+ _changes = changes;
+ _called = true;
+ notify();
+ }
+
+ java.util.Map<String, String> _changes;
+ private boolean _called;
+ }
+
+ public int
+ run(String[] args)
+ {
+ if(args.length > 0)
+ {
+ System.err.println(appName() + ": too many arguments");
+ return 1;
+ }
+
+ PropsI props = new PropsI();
+
+ //
+ // Retrieve the PropertiesAdmin facet and register the servant as the update callback.
+ //
+ Ice.Object obj = communicator().findAdminFacet("Properties");
+ Ice.NativePropertiesAdmin admin = (Ice.NativePropertiesAdmin)obj;
+ admin.setUpdateCallback(props);
+
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Props");
+ adapter.add(props, communicator().stringToIdentity("props"));
+ adapter.activate();
+ communicator().waitForShutdown();
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Server app = new Server();
+ int status = app.main("Server", args, "config.server");
+ System.exit(status);
+ }
+}