diff options
author | Bernard Normier <bernard@zeroc.com> | 2006-03-29 21:21:02 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2006-03-29 21:21:02 +0000 |
commit | 20744ae1f1182d08e26b175f59d14041aabaf754 (patch) | |
tree | 937d125b80663966b3a61e13e744e28daf1f22da /java/src/IceGridGUI/RegistryObserverI.java | |
parent | Java metadata (diff) | |
download | ice-20744ae1f1182d08e26b175f59d14041aabaf754.tar.bz2 ice-20744ae1f1182d08e26b175f59d14041aabaf754.tar.xz ice-20744ae1f1182d08e26b175f59d14041aabaf754.zip |
IceGrid GUI refactoring
Diffstat (limited to 'java/src/IceGridGUI/RegistryObserverI.java')
-rwxr-xr-x | java/src/IceGridGUI/RegistryObserverI.java | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/java/src/IceGridGUI/RegistryObserverI.java b/java/src/IceGridGUI/RegistryObserverI.java new file mode 100755 index 00000000000..808cc306c9a --- /dev/null +++ b/java/src/IceGridGUI/RegistryObserverI.java @@ -0,0 +1,116 @@ +// **********************************************************************
+//
+// Copyright (c) 2003-2005 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.
+//
+// **********************************************************************
+package IceGridGUI;
+
+import javax.swing.SwingUtilities;
+import IceGrid.*;
+
+class RegistryObserverI extends _RegistryObserverDisp
+{
+
+ RegistryObserverI(Coordinator coordinator)
+ {
+ _coordinator = coordinator;
+ }
+
+ //
+ // Runs in the UI thread
+ //
+ synchronized void waitForInit()
+ {
+ //
+ // TODO: configurable timeout
+ //
+ long timeout = 10000;
+
+ long start = System.currentTimeMillis();
+
+ while(!_initialized)
+ {
+ try
+ {
+ wait(timeout);
+ }
+ catch(InterruptedException e)
+ {
+ }
+
+ if((start + timeout) < System.currentTimeMillis())
+ {
+ break;
+ }
+ }
+
+ if(_initialized)
+ {
+ _coordinator.registryInit(_serial, _applications);
+ }
+ else
+ {
+ throw new Ice.TimeoutException();
+ }
+ }
+
+
+ public synchronized void init(int serial, java.util.LinkedList applications,
+ Ice.Current current)
+ {
+ _initialized = true;
+ _serial = serial;
+ _applications = applications;
+ notify();
+ }
+
+ public void applicationAdded(final int serial, final ApplicationDescriptor desc,
+ Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.applicationAdded(serial, desc);
+ }
+ });
+ }
+
+ public void applicationRemoved(final int serial, final String name,
+ final Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.applicationRemoved(serial, name);
+ }
+ });
+ }
+
+ public void applicationUpdated(final int serial, final ApplicationUpdateDescriptor desc,
+ Ice.Current current)
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ _coordinator.applicationUpdated(serial, desc);
+ }
+ });
+ }
+
+
+ private Coordinator _coordinator;
+
+ private boolean _initialized = false;
+
+ //
+ // Values given to init
+ //
+ private int _serial;
+ private java.util.LinkedList _applications;
+};
|