diff options
author | Jose <jose@zeroc.com> | 2014-10-02 11:34:09 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2014-10-02 11:34:09 +0200 |
commit | d80eb3eb2f17f6af8a1eb4f1aa5787ddf9b5bea2 (patch) | |
tree | 2a538714119d07bb47f42d731a0885b464aed30d | |
parent | ICE-2400: new dialog to attach Remote Logger to Registry, Node, Server and Ic... (diff) | |
download | ice-d80eb3eb2f17f6af8a1eb4f1aa5787ddf9b5bea2.tar.bz2 ice-d80eb3eb2f17f6af8a1eb4f1aa5787ddf9b5bea2.tar.xz ice-d80eb3eb2f17f6af8a1eb4f1aa5787ddf9b5bea2.zip |
Fixed (ICE-4549) - IceGridGUI remote synchronous invocations in Swing thread
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/ObjectDialog.java | 5 | ||||
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/Root.java | 332 | ||||
-rw-r--r-- | java/src/IceGridGUI/LiveDeployment/Server.java | 286 |
3 files changed, 272 insertions, 351 deletions
diff --git a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java index 47516374d64..0725d3ba1cc 100644 --- a/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java +++ b/java/src/IceGridGUI/LiveDeployment/ObjectDialog.java @@ -102,10 +102,7 @@ class ObjectDialog extends JDialog type = _typeCombo.getSelectedItem().toString(); } - if(root.addObject(_proxy.getText(), type)) - { - setVisible(false); - } + root.addObject(_proxy.getText(), type, ObjectDialog.this); } else { diff --git a/java/src/IceGridGUI/LiveDeployment/Root.java b/java/src/IceGridGUI/LiveDeployment/Root.java index 1a2a9633b51..08858543029 100644 --- a/java/src/IceGridGUI/LiveDeployment/Root.java +++ b/java/src/IceGridGUI/LiveDeployment/Root.java @@ -13,6 +13,7 @@ import java.awt.Component; import java.awt.Cursor; import javax.swing.Icon; +import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JPopupMenu; import javax.swing.JTree; @@ -220,46 +221,34 @@ public class Root extends ListArrayTreeNode public void shutdownRegistry() { final String prefix = "Shutting down registry '" + _replicaName + "'..."; - getCoordinator().getStatusBar().setText(prefix); - - Callback_Admin_shutdownRegistry cb = new Callback_Admin_shutdownRegistry() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to shutdown " + _replicaName, e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to shutdown " + _replicaName, - e.toString()); - } - }; - + final String errorTitle = "Failed to shutdown " + _replicaName; + _coordinator.getStatusBar().setText(prefix); try { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - _coordinator.getAdmin().begin_shutdownRegistry(_replicaName, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to shutdown " + _replicaName, e.toString()); + _coordinator.getAdmin().begin_shutdownRegistry(_replicaName, new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + _coordinator.getAdmin().end_shutdownRegistry(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } } @@ -392,46 +381,36 @@ public class Root extends ListArrayTreeNode } final String prefix = "Patching application '" + applicationName + "'..."; + final String errorTitle = "Failed to patch '" + applicationName; _coordinator.getStatusBar().setText(prefix); - Callback_Admin_patchApplication cb = new Callback_Admin_patchApplication() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to patch '" - + applicationName + "'", e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to patch '" + - applicationName + "'", e.toString()); - } - }; - try { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - _coordinator.getAdmin().begin_patchApplication(applicationName, shutdown == JOptionPane.YES_OPTION, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to patch " + _id, e.toString()); + _coordinator.getAdmin().begin_patchApplication(applicationName, shutdown == JOptionPane.YES_OPTION, + new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + _coordinator.getAdmin().end_patchApplication(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } } @@ -864,7 +843,7 @@ public class Root extends ListArrayTreeNode return _info; } - boolean addObject(String strProxy, String type) + void addObject(String strProxy, final String type, final JDialog dialog) { Ice.ObjectPrx proxy = null; @@ -879,7 +858,6 @@ public class Root extends ListArrayTreeNode "Cannot parse proxy '" + strProxy + "'", "addObject failed", JOptionPane.ERROR_MESSAGE); - return false; } if(proxy == null) @@ -889,64 +867,71 @@ public class Root extends ListArrayTreeNode "You must provide a non-null proxy", "addObject failed", JOptionPane.ERROR_MESSAGE); - return false; } String strIdentity = Ice.Util.identityToString(proxy.ice_getIdentity()); - String prefix = "Adding well-known object '" + strIdentity + "'..."; - try + final String prefix = "Adding well-known object '" + strIdentity + "'..."; + final AdminPrx admin = _coordinator.getAdmin(); + Ice.Callback cb = new Ice.Callback() { - _coordinator.getStatusBar().setText(prefix); - _coordinator.getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + if(type == null) + { + admin.end_addObject(r); + } + else + { + admin.end_addObjectWithType(r); + } + + amiSuccess(prefix); + + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + dialog.setVisible(false); + } + }); + } + catch(ObjectExistsException e) + { + amiFailure(prefix, "addObject failed", + "An object with this identity is already registered as a well-known object"); + } + catch(DeploymentException ex) + { + amiFailure(prefix, "addObject failed", "Deployment exception: " + ex.reason); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, "addObject failed", ex.toString()); + } + } + }; + _coordinator.getStatusBar().setText(prefix); + try + { if(type == null) { - _coordinator.getAdmin().addObject(proxy); + admin.begin_addObject(proxy, cb); } else { - _coordinator.getAdmin().addObjectWithType(proxy, type); + admin.begin_addObjectWithType(proxy, type, cb); } } - catch(ObjectExistsException e) - { - _coordinator.getStatusBar().setText(prefix + "failed."); - JOptionPane.showMessageDialog( - _coordinator.getMainFrame(), - "An object with this identity is already registered as a well-known object", - "addObject failed", - JOptionPane.ERROR_MESSAGE); - return false; - } - catch(DeploymentException e) - { - _coordinator.getStatusBar().setText(prefix + "failed."); - JOptionPane.showMessageDialog( - _coordinator.getMainFrame(), - "Deployment exception: " + e.reason, - "addObject failed", - JOptionPane.ERROR_MESSAGE); - return false; - } - catch(Ice.LocalException e) - { - _coordinator.getStatusBar().setText(prefix + "failed."); - JOptionPane.showMessageDialog( - _coordinator.getMainFrame(), - e.toString(), - "addObject failed", - JOptionPane.ERROR_MESSAGE); - return false; - } - finally + catch(Ice.LocalException ex) { - _coordinator.getMainFrame().setCursor( - Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, "addObject failed", ex.toString()); } - _coordinator.getStatusBar().setText(prefix + "done."); - return true; } void removeObject(String strProxy) @@ -956,91 +941,72 @@ public class Root extends ListArrayTreeNode final String strIdentity = Ice.Util.identityToString(identity); final String prefix = "Removing well-known object '" + strIdentity + "'..."; - _coordinator.getStatusBar().setText(prefix); - - Callback_Admin_removeObject cb = new Callback_Admin_removeObject() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to remove object '" + strIdentity + "'", e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to remove object '" + strIdentity + "'", - e.toString()); - } - }; + final String errorTitle = "Failed to remove object '" + strIdentity + "'"; + _coordinator.getStatusBar().setText(prefix); try { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - _coordinator.getAdmin().begin_removeObject(identity, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to remove object '" + strIdentity + "'", e.toString()); + _coordinator.getAdmin().begin_removeObject(identity, + new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + _coordinator.getAdmin().end_removeObject(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } } void removeAdapter(final String adapterId) { final String prefix = "Removing adapter '" + adapterId + "'..."; + final String errorTitle = "Failed to remove adapter '" + adapterId + "'"; _coordinator.getStatusBar().setText(prefix); - - Callback_Admin_removeAdapter cb = new Callback_Admin_removeAdapter() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to remove adapter '" + adapterId + "'", e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to remove adapter '" + adapterId + "'", - e.toString()); - } - }; - try { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - _coordinator.getAdmin().begin_removeAdapter(adapterId, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to remove adapter '" + adapterId + "'", e.toString()); + _coordinator.getAdmin().begin_removeAdapter(adapterId, new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + _coordinator.getAdmin().end_removeAdapter(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - _coordinator.getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } + } @Override diff --git a/java/src/IceGridGUI/LiveDeployment/Server.java b/java/src/IceGridGUI/LiveDeployment/Server.java index aa1d7cfdaa8..9efdacdbcfa 100644 --- a/java/src/IceGridGUI/LiveDeployment/Server.java +++ b/java/src/IceGridGUI/LiveDeployment/Server.java @@ -71,44 +71,35 @@ public class Server extends ListArrayTreeNode public void start() { final String prefix = "Starting server '" + _id + "'..."; - getCoordinator().getStatusBar().setText(prefix); - - Callback_Admin_startServer cb = new Callback_Admin_startServer() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to start " + _id, e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to start " + _id, e.toString()); - } - }; + final String errorTitle = "Failed to start " + _id; + getCoordinator().getStatusBar().setText(prefix); try { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin().begin_startServer(_id, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to start " + _id, e.toString()); + getCoordinator().getAdmin().begin_startServer(_id, new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + getCoordinator().getAdmin().end_startServer(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } } @@ -116,45 +107,36 @@ public class Server extends ListArrayTreeNode public void stop() { final String prefix = "Stopping server '" + _id + "'..."; + final String errorTitle = "Failed to stop " + _id; getCoordinator().getStatusBar().setText(prefix); - - Callback_Admin_stopServer cb = new Callback_Admin_stopServer() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - rebuild(Server.this, false); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to stop " + _id, e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to stop " + _id, e.toString()); - } - }; - try { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin().begin_stopServer(_id, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to stop " + _id, e.toString()); + getCoordinator().getAdmin().begin_stopServer(_id, + new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + getCoordinator().getAdmin().end_stopServer(r); + amiSuccess(prefix); + rebuild(Server.this, false); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } } @@ -303,39 +285,35 @@ public class Server extends ListArrayTreeNode public void signal(final String s) { final String prefix = "Sending '" + s + "' to server '" + _id + "'..."; + final String errorTitle = "Failed to deliver signal " + s + " to " + _id; getCoordinator().getStatusBar().setText(prefix); - - Callback_Admin_sendSignal cb = new Callback_Admin_sendSignal() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString()); - } - }; - try { - getCoordinator().getAdmin().begin_sendSignal(_id, s, cb); + getCoordinator().getAdmin().begin_sendSignal(_id, s, + new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + getCoordinator().getAdmin().end_sendSignal(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - catch(Ice.LocalException e) + catch(Ice.LocalException ex) { - failure(prefix, "Failed to deliver signal " + s + " to " + _id, e.toString()); + failure(prefix, errorTitle, ex.toString()); } } @@ -361,91 +339,71 @@ public class Server extends ListArrayTreeNode } final String prefix = "Patching server '" + _id + "'..."; - getCoordinator().getStatusBar().setText(prefix); - - Callback_Admin_patchServer cb = new Callback_Admin_patchServer() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to patch " + _id, e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to patch " + _id, e.toString()); - } - }; + final String errorTitle = "Failed to patch " + _id; + getCoordinator().getStatusBar().setText(prefix); try { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin().begin_patchServer(_id, shutdown == JOptionPane.YES_OPTION, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to patch " + _id, e.toString()); + getCoordinator().getAdmin().begin_patchServer(_id, shutdown == JOptionPane.YES_OPTION, + new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + getCoordinator().getAdmin().end_patchServer(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } } private void enableServer(boolean enable) { final String prefix = (enable ? "Enabling" : "Disabling") + " server '" + _id + "'..."; - - final String action = enable ? "enable" : "disable"; - + final String errorTitle = "Failed to " + (enable ? "enable" : "disable") + " " + _id; getCoordinator().getStatusBar().setText(prefix); - - Callback_Admin_enableServer cb = new Callback_Admin_enableServer() - { - // - // Called by another thread! - // - @Override - public void response() - { - amiSuccess(prefix); - } - - @Override - public void exception(Ice.UserException e) - { - amiFailure(prefix, "Failed to " + action + " " + _id, e); - } - - @Override - public void exception(Ice.LocalException e) - { - amiFailure(prefix, "Failed to " + action + " " + _id, e.toString()); - } - }; - try { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - getCoordinator().getAdmin().begin_enableServer(_id, enable, cb); - } - catch(Ice.LocalException e) - { - failure(prefix, "Failed to " + action + " " + _id, e.toString()); + getCoordinator().getAdmin().begin_enableServer(_id, enable, + new Ice.Callback() + { + @Override + public void completed(final Ice.AsyncResult r) + { + try + { + getCoordinator().getAdmin().end_enableServer(r); + amiSuccess(prefix); + } + catch(Ice.UserException ex) + { + amiFailure(prefix, errorTitle, ex); + } + catch(Ice.LocalException ex) + { + amiFailure(prefix, errorTitle, ex.toString()); + } + } + }); } - finally + catch(Ice.LocalException ex) { - getCoordinator().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + failure(prefix, errorTitle, ex.toString()); } } |