diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-09-04 19:42:16 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-09-04 19:42:16 +0000 |
commit | e4eba4680b2058554bfc74d2983ba06f0b8c379e (patch) | |
tree | 0c0c09209cc0786df6546eb605abd7a0b6adade3 /java/src | |
parent | Improved observers, refactored topic manager and initialization Added (diff) | |
download | ice-e4eba4680b2058554bfc74d2983ba06f0b8c379e.tar.bz2 ice-e4eba4680b2058554bfc74d2983ba06f0b8c379e.tar.xz ice-e4eba4680b2058554bfc74d2983ba06f0b8c379e.zip |
Added application/adapter/object observers
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/IceGridGUI/AdapterObserverI.java | 67 | ||||
-rw-r--r-- | java/src/IceGridGUI/ApplicationObserverI.java | 123 | ||||
-rwxr-xr-x | java/src/IceGridGUI/Coordinator.java | 44 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Node.java | 2 | ||||
-rwxr-xr-x | java/src/IceGridGUI/LiveDeployment/Root.java | 40 | ||||
-rwxr-xr-x | java/src/IceGridGUI/NodeObserverI.java | 2 | ||||
-rw-r--r-- | java/src/IceGridGUI/ObjectObserverI.java | 67 | ||||
-rwxr-xr-x | java/src/IceGridGUI/RegistryObserverI.java | 185 | ||||
-rwxr-xr-x | java/src/IceGridGUI/SessionKeeper.java | 78 |
9 files changed, 400 insertions, 208 deletions
diff --git a/java/src/IceGridGUI/AdapterObserverI.java b/java/src/IceGridGUI/AdapterObserverI.java new file mode 100644 index 00000000000..85c429eea37 --- /dev/null +++ b/java/src/IceGridGUI/AdapterObserverI.java @@ -0,0 +1,67 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 AdapterObserverI extends _AdapterObserverDisp +{ + + AdapterObserverI(Coordinator coordinator) + { + _coordinator = coordinator; + } + + public synchronized void adapterInit(final AdapterInfo[] adapters, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.adapterInit(adapters); + } + }); + } + + public void adapterAdded(final AdapterInfo info, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.adapterAdded(info); + } + }); + } + + public void adapterUpdated(final AdapterInfo info, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.adapterUpdated(info); + } + }); + } + + public void adapterRemoved(final String id, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.adapterRemoved(id); + } + }); + } + + private final Coordinator _coordinator; +}; diff --git a/java/src/IceGridGUI/ApplicationObserverI.java b/java/src/IceGridGUI/ApplicationObserverI.java new file mode 100644 index 00000000000..fc612e1ab39 --- /dev/null +++ b/java/src/IceGridGUI/ApplicationObserverI.java @@ -0,0 +1,123 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 ApplicationObserverI extends _ApplicationObserverDisp +{ + + ApplicationObserverI(String instanceName, Coordinator coordinator) + { + _instanceName = instanceName; + _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.applicationInit(_instanceName, _serial, _applications); + } + else + { + throw new Ice.TimeoutException(); + } + } + + + public synchronized void applicationInit(int serial, java.util.List applications, Ice.Current current) + { + _initialized = true; + _serial = serial; + + _applications = new java.util.LinkedList(); + java.util.Iterator p = applications.iterator(); + while(p.hasNext()) + { + _applications.add(((ApplicationInfo)p.next()).descriptor); // TODO: XXX: Use ApplicationInfo directly. + } + + notify(); + } + + public void applicationAdded(final int serial, final ApplicationInfo info, + Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.applicationAdded(serial, info.descriptor); // TODO: XXX: Use ApplicationInfo directly. + } + }); + } + + 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 ApplicationUpdateInfo info, + Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.applicationUpdated(serial, info.descriptor); // TODO: XXX: Use ApplicationUpdateInfo + } + }); + } + + private final Coordinator _coordinator; + + private boolean _initialized = false; + + // + // Values given to init + // + private final String _instanceName; + private int _serial; + private java.util.List _applications; +}; diff --git a/java/src/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/Coordinator.java index b50ab366931..50db4f5c4f1 100755 --- a/java/src/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/Coordinator.java @@ -466,15 +466,14 @@ public class Coordinator //
- // From the Registry observer:
+ // From the Application observer:
//
- void registryInit(String instanceName, int serial, java.util.List applications,
- AdapterInfo[] adapters, ObjectInfo[] objects)
+ void applicationInit(String instanceName, int serial, java.util.List applications)
{
assert _latestSerial == -1;
_latestSerial = serial;
- _liveDeploymentRoot.init(instanceName, applications, adapters, objects);
+ _liveDeploymentRoot.applicationInit(instanceName, applications);
//
// When we get this init, we can't have any live Application yet.
//
@@ -528,46 +527,58 @@ public class Coordinator updateSerial(serial);
}
- void adapterAdded(int serial, AdapterInfo info)
+ //
+ // From the Adapter observer:
+ //
+ void adapterInit(AdapterInfo[] adapters)
+ {
+ _liveDeploymentRoot.adapterInit(adapters);
+ // _liveDeploymentPane.refresh(); // TODO: XXX: Is is it necessary to call refresh()?
+ }
+
+ void adapterAdded(AdapterInfo info)
{
_liveDeploymentRoot.adapterAdded(info);
_liveDeploymentPane.refresh();
- updateSerial(serial);
}
- void adapterUpdated(int serial, AdapterInfo info)
+ void adapterUpdated(AdapterInfo info)
{
_liveDeploymentRoot.adapterUpdated(info);
_liveDeploymentPane.refresh();
- updateSerial(serial);
}
- void adapterRemoved(int serial, String id)
+ void adapterRemoved(String id)
{
_liveDeploymentRoot.adapterRemoved(id);
_liveDeploymentPane.refresh();
- updateSerial(serial);
}
- void objectAdded(int serial, ObjectInfo info)
+ //
+ // From the Object observer:
+ //
+ void objectInit(ObjectInfo[] objects)
+ {
+ _liveDeploymentRoot.objectInit(objects);
+ // _liveDeploymentPane.refresh(); // TODO: XXX: Is is it necessary to call refresh()?
+ }
+
+ void objectAdded(ObjectInfo info)
{
_liveDeploymentRoot.objectAdded(info);
_liveDeploymentPane.refresh();
- updateSerial(serial);
}
- void objectUpdated(int serial, ObjectInfo info)
+ void objectUpdated(ObjectInfo info)
{
_liveDeploymentRoot.objectUpdated(info);
_liveDeploymentPane.refresh();
- updateSerial(serial);
}
- void objectRemoved(int serial, Ice.Identity id)
+ void objectRemoved(Ice.Identity id)
{
_liveDeploymentRoot.objectRemoved(id);
_liveDeploymentPane.refresh();
- updateSerial(serial);
}
public void accessDenied(AccessDeniedException e)
@@ -1193,7 +1204,6 @@ public class Coordinator // Set various default values
//
properties.setProperty("Ice.Override.ConnectTimeout", "5000");
- properties.setProperty("IceGrid.AdminGUI.Endpoints", "tcp -t 10000");
//
// For SSL with JDK 1.4
diff --git a/java/src/IceGridGUI/LiveDeployment/Node.java b/java/src/IceGridGUI/LiveDeployment/Node.java index 7ec19533761..db8b03b4426 100755 --- a/java/src/IceGridGUI/LiveDeployment/Node.java +++ b/java/src/IceGridGUI/LiveDeployment/Node.java @@ -159,7 +159,7 @@ class Node extends ListTreeNode Node(Root parent, NodeDynamicInfo info)
{
- super(parent, info.name);
+ super(parent, info.info.name);
up(info, false);
}
diff --git a/java/src/IceGridGUI/LiveDeployment/Root.java b/java/src/IceGridGUI/LiveDeployment/Root.java index 005cd2857e5..6c75bdd90dd 100755 --- a/java/src/IceGridGUI/LiveDeployment/Root.java +++ b/java/src/IceGridGUI/LiveDeployment/Root.java @@ -112,22 +112,10 @@ public class Root extends ListTreeNode }
- public void init(String instanceName, java.util.List applications,
- AdapterInfo[] adapters, ObjectInfo[] objects)
+ public void applicationInit(String instanceName, java.util.List applications)
{
_label = instanceName;
- _tree.setRootVisible(true);
-
- for(int i = 0; i < adapters.length; ++i)
- {
- _adapters.put(adapters[i].id, adapters[i]);
- }
-
- for(int i = 0; i < objects.length; ++i)
- {
- _objects.put(Ice.Util.identityToString(objects[i].proxy.ice_getIdentity()),
- objects[i]);
- }
+ _tree.setRootVisible(true);
java.util.Iterator p = applications.iterator();
while(p.hasNext())
@@ -393,6 +381,17 @@ public class Root extends ListTreeNode }
}
+ public void adapterInit(AdapterInfo[] adapters)
+ {
+ //
+ // TODO: XXX: REVIEW
+ //
+ for(int i = 0; i < adapters.length; ++i)
+ {
+ _adapters.put(adapters[i].id, adapters[i]);
+ }
+ }
+
public void adapterAdded(AdapterInfo info)
{
_adapters.put(info.id, info);
@@ -408,6 +407,17 @@ public class Root extends ListTreeNode _adapters.remove(id);
}
+ public void objectInit(ObjectInfo[] objects)
+ {
+ //
+ // TODO: XXX: REVIEW
+ //
+ for(int i = 0; i < objects.length; ++i)
+ {
+ _objects.put(Ice.Util.identityToString(objects[i].proxy.ice_getIdentity()), objects[i]);
+ }
+ }
+
public void objectAdded(ObjectInfo info)
{
_objects.put(Ice.Util.identityToString(info.proxy.ice_getIdentity()), info);
@@ -429,7 +439,7 @@ public class Root extends ListTreeNode //
public void nodeUp(NodeDynamicInfo updatedInfo)
{
- Node node = findNode(updatedInfo.name);
+ Node node = findNode(updatedInfo.info.name);
if(node != null)
{
node.up(updatedInfo, true);
diff --git a/java/src/IceGridGUI/NodeObserverI.java b/java/src/IceGridGUI/NodeObserverI.java index e15edb30860..98c16e66e38 100755 --- a/java/src/IceGridGUI/NodeObserverI.java +++ b/java/src/IceGridGUI/NodeObserverI.java @@ -18,7 +18,7 @@ class NodeObserverI extends _NodeObserverDisp _coordinator = coordinator;
}
- public void init(final NodeDynamicInfo[] nodes, Ice.Current current)
+ public void nodeInit(final NodeDynamicInfo[] nodes, Ice.Current current)
{
SwingUtilities.invokeLater(new Runnable()
{
diff --git a/java/src/IceGridGUI/ObjectObserverI.java b/java/src/IceGridGUI/ObjectObserverI.java new file mode 100644 index 00000000000..84a6bddf08a --- /dev/null +++ b/java/src/IceGridGUI/ObjectObserverI.java @@ -0,0 +1,67 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2006 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 ObjectObserverI extends _ObjectObserverDisp +{ + + ObjectObserverI(Coordinator coordinator) + { + _coordinator = coordinator; + } + + public synchronized void objectInit(final ObjectInfo[] objects, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.objectInit(objects); + } + }); + } + + public void objectAdded(final ObjectInfo info, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.objectAdded(info); + } + }); + } + + public void objectUpdated(final ObjectInfo info, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.objectUpdated(info); + } + }); + } + + public void objectRemoved(final Ice.Identity id, Ice.Current current) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + _coordinator.objectRemoved(id); + } + }); + } + + private final Coordinator _coordinator; +}; diff --git a/java/src/IceGridGUI/RegistryObserverI.java b/java/src/IceGridGUI/RegistryObserverI.java index 5918ae5dcfe..e8634fee905 100755 --- a/java/src/IceGridGUI/RegistryObserverI.java +++ b/java/src/IceGridGUI/RegistryObserverI.java @@ -14,182 +14,39 @@ import IceGrid.*; class RegistryObserverI extends _RegistryObserverDisp
{
- RegistryObserverI(String instanceName, Coordinator coordinator)
+ RegistryObserverI(Coordinator coordinator)
{
- _instanceName = instanceName;
_coordinator = coordinator;
}
- //
- // Runs in the UI thread
- //
- synchronized void waitForInit()
+ public void registryInit(final RegistryInfo[] registries, Ice.Current current)
{
- //
- // 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(_instanceName,
- _serial, _applications, _adapters, _objects);
- }
- else
- {
- throw new Ice.TimeoutException();
- }
- }
-
-
- public synchronized void init(int serial, java.util.List applications, AdapterInfo[] adapters,
- ObjectInfo[] objects, Ice.Current current)
- {
- _initialized = true;
- _serial = serial;
-
- _applications = new java.util.LinkedList();
- java.util.Iterator p = applications.iterator();
- while(p.hasNext())
- {
- _applications.add(((ApplicationInfo)p.next()).descriptor); // TODO: Use ApplicationInfo directly.
- }
-
- _adapters = adapters;
- _objects = objects;
- notify();
- }
-
- public void applicationAdded(final int serial, final ApplicationInfo info,
- Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.applicationAdded(serial, info.descriptor); // TODO: Use ApplicationInfo directly.
- }
- });
+ // TODO: XXX
}
- public void applicationRemoved(final int serial, final String name,
- final Ice.Current current)
+ public void registryUp(final RegistryInfo registryInfo, Ice.Current current)
{
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.applicationRemoved(serial, name);
- }
- });
+ // TODO: XXX
+// SwingUtilities.invokeLater(new Runnable()
+// {
+// public void run()
+// {
+// _coordinator.registryUp(registryInfo);
+// }
+// });
}
- public void applicationUpdated(final int serial, final ApplicationUpdateInfo info,
- Ice.Current current)
+ public void registryDown(final String registryName, Ice.Current current)
{
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.applicationUpdated(serial, info.descriptor); // TODO: Use ApplicationUpdateInfo
- }
- });
+ // TODO: XXX
+// SwingUtilities.invokeLater(new Runnable()
+// {
+// public void run()
+// {
+// _coordinator.registryDown(registryName);
+// }
+// });
}
- public void adapterAdded(final int serial, final AdapterInfo info, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.adapterAdded(serial, info);
- }
- });
- }
-
- public void adapterUpdated(final int serial, final AdapterInfo info, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.adapterUpdated(serial, info);
- }
- });
- }
-
- public void adapterRemoved(final int serial, final String id, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.adapterRemoved(serial, id);
- }
- });
- }
-
- public void objectAdded(final int serial, final ObjectInfo info, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.objectAdded(serial, info);
- }
- });
- }
-
- public void objectUpdated(final int serial, final ObjectInfo info, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.objectUpdated(serial, info);
- }
- });
- }
-
- public void objectRemoved(final int serial, final Ice.Identity id, Ice.Current current)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- _coordinator.objectRemoved(serial, id);
- }
- });
- }
-
private final Coordinator _coordinator;
-
- private boolean _initialized = false;
-
- //
- // Values given to init
- //
- private final String _instanceName;
- private int _serial;
- private java.util.List _applications;
- private AdapterInfo[] _adapters;
- private ObjectInfo[] _objects;
};
diff --git a/java/src/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/SessionKeeper.java index 5d578b4e9f7..6ca8324c9f0 100755 --- a/java/src/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/SessionKeeper.java @@ -161,7 +161,23 @@ class SessionKeeper {
try
{
- _adapter.remove(_registryObserverIdentity);
+ _adapter.remove(_applicationObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+
+ try
+ {
+ _adapter.remove(_adapterObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+
+ try
+ {
+ _adapter.remove(_objectObserverIdentity);
}
catch(Ice.NotRegisteredException e)
{
@@ -169,6 +185,14 @@ class SessionKeeper try
{
+ _adapter.remove(_registryObserverIdentity);
+ }
+ catch(Ice.NotRegisteredException e)
+ {
+ }
+
+ try
+ {
_adapter.remove(_nodeObserverIdentity);
}
catch(Ice.NotRegisteredException e)
@@ -213,36 +237,64 @@ class SessionKeeper //
// Create servants and proxies
//
+ _applicationObserverIdentity.name = "application";
+ _applicationObserverIdentity.category = category;
+ _adapterObserverIdentity.name = "adapter";
+ _adapterObserverIdentity.category = category;
+ _objectObserverIdentity.name = "object";
+ _objectObserverIdentity.category = category;
_registryObserverIdentity.name = "registry";
_registryObserverIdentity.category = category;
_nodeObserverIdentity.name = "node";
_nodeObserverIdentity.category = category;
- RegistryObserverI registryObserverServant = new RegistryObserverI(
+ ApplicationObserverI applicationObserverServant = new ApplicationObserverI(
_admin.ice_getIdentity().category, _coordinator);
- RegistryObserverPrx registryObserver =
+ ApplicationObserverPrx applicationObserver =
+ ApplicationObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ applicationObserverServant, _applicationObserverIdentity));
+
+ AdapterObserverPrx adapterObserver =
+ AdapterObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ new AdapterObserverI(_coordinator), _adapterObserverIdentity));
+
+ ObjectObserverPrx objectObserver =
+ ObjectObserverPrxHelper.uncheckedCast(
+ _adapter.add(
+ new ObjectObserverI(_coordinator), _objectObserverIdentity));
+
+ RegistryObserverPrx registryObserver =
RegistryObserverPrxHelper.uncheckedCast(
_adapter.add(
- registryObserverServant, _registryObserverIdentity));
+ new RegistryObserverI(_coordinator), _registryObserverIdentity));
NodeObserverPrx nodeObserver =
NodeObserverPrxHelper.uncheckedCast(
_adapter.add(
new NodeObserverI(_coordinator), _nodeObserverIdentity));
- if(router == null)
+ if(router != null)
{
- _session.setObservers(registryObserver, nodeObserver);
+ _session.setObservers(registryObserver,
+ nodeObserver,
+ applicationObserver,
+ adapterObserver,
+ objectObserver);
}
else
{
_session.setObserversByIdentity(
- _registryObserverIdentity,
- _registryObserverIdentity);
+ _registryObserverIdentity,
+ _nodeObserverIdentity,
+ _applicationObserverIdentity,
+ _adapterObserverIdentity,
+ _objectObserverIdentity);
}
- registryObserverServant.waitForInit();
+ applicationObserverServant.waitForInit();
}
@@ -252,6 +304,9 @@ class SessionKeeper private Ice.ObjectAdapter _adapter;
private AdminPrx _admin;
private AdminPrx _routedAdmin;
+ private Ice.Identity _applicationObserverIdentity = new Ice.Identity();
+ private Ice.Identity _adapterObserverIdentity = new Ice.Identity();
+ private Ice.Identity _objectObserverIdentity = new Ice.Identity();
private Ice.Identity _registryObserverIdentity = new Ice.Identity();
private Ice.Identity _nodeObserverIdentity = new Ice.Identity();
}
@@ -1055,7 +1110,10 @@ class SessionKeeper void logout(boolean destroySession)
{
- _session.close(destroySession);
+ if(_session != null) // TODO: XXX: Review: The Session constructor might throw
+ {
+ _session.close(destroySession);
+ }
_coordinator.sessionLost();
_session = null;
}
|