diff options
author | Bernard Normier <bernard@zeroc.com> | 2005-10-24 03:54:51 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2005-10-24 03:54:51 +0000 |
commit | 5b7fa81e49780378ad7608c05f274c03e397b578 (patch) | |
tree | 868d58db0ba8788ccd0bfbc463225d5c290933d1 /java/src | |
parent | Added comment for FriendlyName. (diff) | |
download | ice-5b7fa81e49780378ad7608c05f274c03e397b578.tar.bz2 ice-5b7fa81e49780378ad7608c05f274c03e397b578.tar.xz ice-5b7fa81e49780378ad7608c05f274c03e397b578.zip |
Improved shutdown
Diffstat (limited to 'java/src')
-rwxr-xr-x | java/src/IceGrid/AdminGUI.java | 39 | ||||
-rwxr-xr-x | java/src/IceGrid/Model.java | 41 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Application.java | 13 | ||||
-rwxr-xr-x | java/src/IceGrid/TreeNode/Server.java | 34 |
4 files changed, 109 insertions, 18 deletions
diff --git a/java/src/IceGrid/AdminGUI.java b/java/src/IceGrid/AdminGUI.java index cea67388c7c..564e29371e0 100755 --- a/java/src/IceGrid/AdminGUI.java +++ b/java/src/IceGrid/AdminGUI.java @@ -94,17 +94,48 @@ public class AdminGUI extends JFrame super("IceGrid Admin");
setIconImage(Utils.getIcon("/icons/grid.png").getImage());
- _model = new Model(this, args, Preferences.userNodeForPackage(getClass()),
- new StatusBarI());
-
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
- _model.exit(0);
+ if(_model != null)
+ {
+ _model.exit(0);
+ }
}
});
+
+ Thread shutdownHook = new Thread("Shutdown hook")
+ {
+ public void run()
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ if(_model != null)
+ {
+ _model.exit(0);
+ }
+ }
+ });
+ //
+ // Give 3 seconds to the GUI thread
+ //
+ try
+ {
+ Thread.sleep(3000);
+ }
+ catch(java.lang.InterruptedException e)
+ {}
+ System.err.println("End of shutdown hook");
+ }
+ };
+ Runtime.getRuntime().addShutdownHook(shutdownHook);
+
+ _model = new Model(this, args, Preferences.userNodeForPackage(getClass()),
+ new StatusBarI());
initComponents();
_model.showMainFrame();
diff --git a/java/src/IceGrid/Model.java b/java/src/IceGrid/Model.java index ee36b0d0f53..7a94e84443d 100755 --- a/java/src/IceGrid/Model.java +++ b/java/src/IceGrid/Model.java @@ -949,21 +949,32 @@ public class Model return _mainFrame;
}
-
- Model(JFrame mainFrame, String[] args, Preferences prefs, StatusBar statusBar)
- {
- _mainFrame = mainFrame;
- _prefs = prefs;
- _statusBar = statusBar;
-
+ static private Ice.Communicator createCommunicator(String[] args)
+ {
//
// TODO: work-around bug #542
//
+
Ice.Properties properties = Ice.Util.createProperties();
properties.setProperty("Ice.Override.ConnectTimeout", "5000");
properties.setProperty("IceGrid.AdminGUI.Endpoints", "tcp -t 10000");
+
+ //
+ // For Glacier
+ //
+ properties.setProperty("Ice.ACM.Client", "0");
+ properties.setProperty("Ice.MonitorConnections", "5");
+ properties.setProperty("Ice.RetryIntervals", "-1");
- _communicator = Ice.Util.initializeWithProperties(args, properties);
+ return Ice.Util.initializeWithProperties(args, properties);
+ }
+
+ Model(JFrame mainFrame, String[] args, Preferences prefs, StatusBar statusBar)
+ {
+ _mainFrame = mainFrame;
+ _prefs = prefs;
+ _statusBar = statusBar;
+ _communicator = createCommunicator(args);
_root = new Root(this);
_treeModel = new TreeModelI(_root);
@@ -1462,16 +1473,26 @@ public class Model void exit(int status)
{
+ System.err.println("Exiting from thread " + Thread.currentThread().getName());
+
storeWindowPrefs();
+ System.err.println("Destroying communicator");
try
{
- _communicator.destroy();
+ if(_communicator != null)
+ {
+ _communicator.destroy();
+ }
}
catch(Ice.LocalException e)
{
// TODO: log error
}
+
+ System.err.println("Dispose of main frame");
_mainFrame.dispose();
+
+ System.err.println("Calling Runtime.exit");
Runtime.getRuntime().exit(status);
}
@@ -1604,7 +1625,7 @@ public class Model }
- private Ice.Communicator _communicator;
+ private final Ice.Communicator _communicator;
private Preferences _prefs;
private StatusBar _statusBar;
private AdminPrx _admin;
diff --git a/java/src/IceGrid/TreeNode/Application.java b/java/src/IceGrid/TreeNode/Application.java index bfc79e2b5fb..d1919d7f084 100755 --- a/java/src/IceGrid/TreeNode/Application.java +++ b/java/src/IceGrid/TreeNode/Application.java @@ -8,6 +8,8 @@ // **********************************************************************
package IceGrid.TreeNode;
+import java.awt.Cursor;
+
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
@@ -191,6 +193,9 @@ public class Application extends EditableParent try
{
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
_model.getAdmin().patchApplication_async(cb, _id,
shutdown == JOptionPane.YES_OPTION);
}
@@ -198,7 +203,13 @@ public class Application extends EditableParent {
failure(prefix, "Failed to patch " + _id, e.toString());
}
-
+ finally
+ {
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+
+
//
// Recompute actions in case this comes from popup menu
//
diff --git a/java/src/IceGrid/TreeNode/Server.java b/java/src/IceGrid/TreeNode/Server.java index c8e453d4463..736fa88efd1 100755 --- a/java/src/IceGrid/TreeNode/Server.java +++ b/java/src/IceGrid/TreeNode/Server.java @@ -9,6 +9,8 @@ package IceGrid.TreeNode;
import java.awt.Component;
+import java.awt.Cursor;
+
import javax.swing.Icon;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
@@ -278,12 +280,19 @@ class Server extends EditableParent try
{
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
_model.getAdmin().startServer_async(cb, _id);
}
catch(Ice.LocalException e)
{
failure(prefix, "Failed to start " + _id, e.toString());
}
+ finally
+ {
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
//
// Recompute actions in case this comes from popup menu
@@ -319,13 +328,19 @@ class Server extends EditableParent try
{
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
_model.getAdmin().stopServer_async(cb, _id);
}
catch(Ice.LocalException e)
{
failure(prefix, "Failed to stop " + _id, e.toString());
}
-
+ finally
+ {
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
//
// Recompute actions in case this comes from popup menu
//
@@ -388,6 +403,8 @@ class Server extends EditableParent try
{
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
_model.getAdmin().patchServer_async(cb, _id,
shutdown == JOptionPane.YES_OPTION);
}
@@ -395,7 +412,12 @@ class Server extends EditableParent {
failure(prefix, "Failed to patch " + _id, e.toString());
}
-
+ finally
+ {
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+
//
// Recompute actions in case this comes from popup menu
//
@@ -496,13 +518,19 @@ class Server extends EditableParent try
{
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
_model.getAdmin().enableServer_async(cb, _id, enable);
}
catch(Ice.LocalException e)
{
failure(prefix, "Failed to " + action + " " + _id, e.toString());
}
-
+ finally
+ {
+ _model.getMainFrame().setCursor(
+ Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
//
// Recompute actions in case this comes from popup menu
//
|