diff --git a/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml b/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml index 296cfd8a6a0..013ac8185cc 100644 --- a/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml +++ b/rse/plugins/org.eclipse.rse.ui/HelpContexts.xml @@ -920,15 +920,6 @@ selected matches in that file will also be removed from the view. - - -This is the RSE communications preferences page. These preferences are not specific to any single RSE connection. The RSE communications daemon can be used by local Workbench functions to listen for incoming socket requests from remote systems. The daemon can be started and stopped from the pull down menu in the RSE's Remote Systems view. - -Use the start RSE communications daemon checkbox to automatically start the daemon when the Workbench is started. - -Use the port preference to change which local TCP/IP port the daemon uses to listen for incoming requests. A valid TCP/IP port number must be entered. If the port is changed and the daemon is currently running then the daemon will be stopped and restarted on the new port when the preference page is closed. - - This is the RSE file cache preference page. diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java index c7b9edeb52f..fee12e08a7d 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.java @@ -726,13 +726,7 @@ public class SystemResources extends NLS public static String RESID_PERCONNECTION_FILTERPOOL; - // RSE Communication Perferences - public static String RESID_PREF_COMMUNICATIONS_TITLE; - public static String RESID_PREF_DAEMON_PORT_LABEL; - public static String RESID_PREF_DAEMON_PORT_TOOLTIP; - public static String RESID_PREF_DAEMON_AUTOSTART_LABEL; - public static String RESID_PREF_DAEMON_AUTOSTART_TOOLTIP; - + // RSE Communication Preferences public static String RESID_PREF_IP_ADDRESS_LABEL; public static String RESID_PREF_IP_AUTO_LABEL; public static String RESID_PREF_IP_AUTO_TOOLTIP; diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties index 5020aa465dd..069b3ccef7c 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/SystemResources.properties @@ -89,12 +89,6 @@ RESID_PREF_SYSTYPE_COLHDG_USERID=Default User ID ############################################################## # Preference pages for general communications ############################################################## -RESID_PREF_COMMUNICATIONS_TITLE=RSE Communications Preferences -RESID_PREF_DAEMON_PORT_LABEL=RSE communications daemon port number (1 - 65536) -RESID_PREF_DAEMON_PORT_TOOLTIP=Enter the local port number for the daemon to listen on -RESID_PREF_DAEMON_AUTOSTART_LABEL=Start RSE communications daemon on Workbench startup -RESID_PREF_DAEMON_AUTOSTART_TOOLTIP=Select the checkbox to start daemon on startup - RESID_PREF_IP_ADDRESS_LABEL= Workstation network address RESID_PREF_IP_AUTO_LABEL= Automatically detect IP address of workstation RESID_PREF_IP_AUTO_TOOLTIP= Allow automatic detection of the IP address of your workstation. This setting should work in most cases @@ -1098,11 +1092,6 @@ ACTION_SELECT_INPUT_LABEL=Select Input... ACTION_SELECT_INPUT_DLG=Select Input ACTION_SELECT_INPUT_TOOLTIP=Select the input for the view -ACTION_DAEMON_START_LABEL=Start Communications Daemon -ACTION_DAEMON_START_TOOLTIP=Start the RSE communications daemon -ACTION_DAEMON_STOP_LABEL=Stop Communications Daemon -ACTION_DAEMON_STOP_TOOLTIP=Stop the RSE communications daemon - ACTION_SELECTCONNECTION_LABEL=Select Connection ACTION_SELECTCONNECTION_TOOLTIP=Bring up a dialog for selecting a connection diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemStartCommunicationsDaemonAction.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemStartCommunicationsDaemonAction.java deleted file mode 100644 index 06f89bb1fda..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/actions/SystemStartCommunicationsDaemonAction.java +++ /dev/null @@ -1,93 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.internal.ui.actions; - -import org.eclipse.jface.action.IAction; -import org.eclipse.rse.core.comm.SystemCommunicationsDaemon; -import org.eclipse.rse.internal.ui.SystemResources; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.SystemBaseAction; -import org.eclipse.swt.widgets.Shell; - - -/** - * Action to start and stop RSE communications daemon - */ -public class SystemStartCommunicationsDaemonAction extends SystemBaseAction implements IAction -{ - - /** - * Constructor - * - * @param shell - */ - public SystemStartCommunicationsDaemonAction(Shell shell) - { - super(SystemResources.ACTION_DAEMON_STOP_LABEL, - SystemResources.ACTION_DAEMON_STOP_TOOLTIP, - shell); - - setHelp(RSEUIPlugin.HELPPREFIX + "dmna0000"); //$NON-NLS-1$ - - if (!SystemCommunicationsDaemon.isAutoStart() || !SystemCommunicationsDaemon.getInstance().isRunning()) - { - setActionLabelToStart(); - } - - SystemCommunicationsDaemon.setAction(this); - } - - - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - SystemCommunicationsDaemon daemon = SystemCommunicationsDaemon.getInstance(); - if (daemon.isRunning()) - { - daemon.stopDaemon(); - - // Change the menu label for the action - setActionLabelToStart(); - } - else - { - daemon.startDaemon(); - // Change the menu label for the action - setActionLabelToStop(); - } - } - - /** - * Helper method for changing the action text and tooltip to start - */ - public void setActionLabelToStart() - { - setText(SystemResources.ACTION_DAEMON_START_LABEL); - setToolTipText(SystemResources.ACTION_DAEMON_START_TOOLTIP); - } - - /** - * Helper method for changing the action text and tooltip to stop - */ - public void setActionLabelToStop() - { - setText(SystemResources.ACTION_DAEMON_STOP_LABEL); - setToolTipText(SystemResources.ACTION_DAEMON_STOP_TOOLTIP); - } - -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/propertypages/SystemCommunicationsPreferencePage.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/propertypages/SystemCommunicationsPreferencePage.java deleted file mode 100644 index bb75f1bd1f2..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/propertypages/SystemCommunicationsPreferencePage.java +++ /dev/null @@ -1,123 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.internal.ui.propertypages; - -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IntegerFieldEditor; -import org.eclipse.rse.core.comm.SystemCommunicationsDaemon; -import org.eclipse.rse.internal.ui.SystemResources; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.ISystemPreferencesConstants; -import org.eclipse.rse.ui.Mnemonics; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.SystemWidgetHelpers; -import org.eclipse.rse.ui.propertypages.SystemBooleanFieldEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; -import org.eclipse.ui.PlatformUI; - - -/** - * Preference page for generic Remote System communication preferences - */ -public class SystemCommunicationsPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage -{ - - - private IntegerFieldEditor portEditor; - - /** - * Constructor - */ - public SystemCommunicationsPreferencePage() - { - super(GRID); - setPreferenceStore(RSEUIPlugin.getDefault().getPreferenceStore()); -// setDescription(SystemResources.RESID_PREF_COMMUNICATIONS_TITLE); dwd description is not readable by screen reader - } - - /** - * Configure the composite. We intercept to set the help. - */ - public void createControl(Composite parent) - { - super.createControl(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), RSEUIPlugin.HELPPREFIX + "cmmp0000"); //$NON-NLS-1$ - } - - - /** - * - */ - protected void createFieldEditors() - { - Composite parent= getFieldEditorParent(); - - // Auto-start the daemon preference - SystemBooleanFieldEditor autoStartEditor = new SystemBooleanFieldEditor( - ISystemPreferencesConstants.DAEMON_AUTOSTART, - SystemResources.RESID_PREF_DAEMON_AUTOSTART_LABEL, - parent - ); - autoStartEditor.setToolTipText(SystemResources.RESID_PREF_DAEMON_AUTOSTART_TOOLTIP); - addField(autoStartEditor); - - - // Daemon port preference - portEditor = new IntegerFieldEditor( - ISystemPreferencesConstants.DAEMON_PORT, - SystemResources.RESID_PREF_DAEMON_PORT_LABEL, - parent - ); - portEditor.setValidRange(1, 65536); - portEditor.setErrorMessage(RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_VALIDATE_PORT_NOTVALID).getLevelOneText()); - addField(portEditor); - portEditor.getTextControl(parent).setToolTipText(SystemResources.RESID_PREF_DAEMON_PORT_TOOLTIP); - - SystemWidgetHelpers.setHelp(portEditor.getTextControl(parent), RSEUIPlugin.HELPPREFIX + "cmmp0000"); //$NON-NLS-1$ - - - (new Mnemonics()).setOnPreferencePage(true).setMnemonics(parent); - } - - /** - * Inherited method. - */ - public void init(IWorkbench workbench) - { - } - - /** - * @see FieldEditorPreferencePage#performOk() - */ - public boolean performOk() { - // Restart the communications daemon if required - int port = portEditor.getIntValue(); - SystemCommunicationsDaemon daemon = SystemCommunicationsDaemon.getInstance(); - - // Restart communications daemon if it is already running and the - // port number has changed - if (daemon.isRunning() && port != daemon.getPort()) { - SystemCommunicationsDaemon.getInstance().stopDaemon(); - SystemCommunicationsDaemon.getInstance().startDaemon(); - } - - return super.performOk(); - - } -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java index afd5fe5a211..fb831a390bd 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/internal/ui/view/SystemViewPart.java @@ -63,7 +63,6 @@ import org.eclipse.rse.internal.ui.actions.SystemCollapseAllAction; import org.eclipse.rse.internal.ui.actions.SystemPreferenceQualifyConnectionNamesAction; import org.eclipse.rse.internal.ui.actions.SystemPreferenceRestoreStateAction; import org.eclipse.rse.internal.ui.actions.SystemPreferenceShowFilterPoolsAction; -import org.eclipse.rse.internal.ui.actions.SystemStartCommunicationsDaemonAction; import org.eclipse.rse.internal.ui.actions.SystemWorkWithProfilesAction; import org.eclipse.rse.model.ISystemResourceChangeEvents; import org.eclipse.rse.model.SystemRegistry; @@ -696,17 +695,6 @@ public class SystemViewPart SystemCascadingPreferencesAction preferencesAction = new SystemCascadingPreferencesAction(shell); menuMgr.add(preferencesAction.getSubMenu()); - menuMgr.add(new Separator()); - menuMgr.add(new SystemStartCommunicationsDaemonAction(shell)); - - if (viewPart != null) - { - /* - SystemCascadingTeamAction teamAction = new SystemCascadingTeamAction(shell, viewPart); - menuMgr.add(new Separator()); - menuMgr.add(teamAction.getSubMenu()); - */ - } SystemViewMenuListener menuListener = new SystemViewMenuListener(true); // true says this is a persistent menu if (viewPart instanceof ISystemMessageLine) menuListener.setShowToolTipText(true, (ISystemMessageLine) viewPart); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java index 68840d1757b..34f1b8c08d1 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/ISystemPreferencesConstants.java @@ -23,16 +23,6 @@ public interface ISystemPreferencesConstants { * root */ public static final String ROOT = "org.eclipse.rse.preferences."; //$NON-NLS-1$ - /* - * dstore preference keys - */ - public static final String DAEMON_AUTOSTART = ROOT + "daemon.autostart"; //$NON-NLS-1$ - public static final String DAEMON_PORT = ROOT + "daemon.port"; //$NON-NLS-1$ - /* - * dstore preference default values - */ - public static final boolean DEFAULT_DAEMON_AUTOSTART = false; - public static final int DEFAULT_DAEMON_PORT = 4300; /* * uda preference keys */ diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java index 8a2ba5f1285..69b758a570a 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/RSEUIPlugin.java @@ -38,7 +38,6 @@ import org.eclipse.rse.core.SystemBasePlugin; import org.eclipse.rse.core.SystemResourceListener; import org.eclipse.rse.core.SystemResourceManager; import org.eclipse.rse.core.comm.ISystemKeystoreProvider; -import org.eclipse.rse.core.comm.SystemCommunicationsDaemon; import org.eclipse.rse.core.comm.SystemKeystoreProviderManager; import org.eclipse.rse.core.model.ISystemProfile; import org.eclipse.rse.core.model.ISystemProfileManager; @@ -104,18 +103,9 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi IProject remoteSystemsProject = SystemResourceManager.getRemoteSystemsProject(); SystemResourceListener listener = SystemResourceListener.getListener(remoteSystemsProject); SystemResourceManager.startResourceEventListening(listener); - - // Auto-start RSE communications daemon if required - SystemCommunicationsDaemon daemon = SystemCommunicationsDaemon.getInstance(); - - if (SystemCommunicationsDaemon.isAutoStart()) { - daemon.startDaemon(false); - } registerDynamicPopupMenuExtensions(); registerKeystoreProviders(); - - // new support to allow products to not pre-create a local connection if (SystemResourceManager.isFirstTime() && SystemPreferencesManager.getShowLocalConnection()) { @@ -615,12 +605,6 @@ public class RSEUIPlugin extends SystemBasePlugin implements ISystemMessageProvi // remove workspace listener for our project SystemResourceManager.endResourceEventListening(); - - // Stop RSE communications daemon if required, the stopDaemon method checks if the daemon is running or not - SystemCommunicationsDaemon daemon = SystemCommunicationsDaemon.getInstance(); - daemon.stopDaemon(); - - // call this last super.stop(context); diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemPreferencesManager.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemPreferencesManager.java index 33f7290997e..969260fdd55 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemPreferencesManager.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/SystemPreferencesManager.java @@ -79,7 +79,6 @@ public class SystemPreferencesManager { public static void initDefaults() { migrateCorePreferences(); initDefaultsUI(); - initDefaultsComm(); savePreferences(); } @@ -105,17 +104,6 @@ public class SystemPreferencesManager { boolean value = (property == null) ? defaultValue : property.equals(Boolean.toString(true)); return value; } - - /** - * Set default communications preferences - */ - private static void initDefaultsComm() { - RSEUIPlugin ui = RSEUIPlugin.getDefault(); - Preferences store = ui.getPluginPreferences(); - store.setDefault(ISystemPreferencesConstants.DAEMON_AUTOSTART, ISystemPreferencesConstants.DEFAULT_DAEMON_AUTOSTART); - store.setDefault(ISystemPreferencesConstants.DAEMON_PORT, ISystemPreferencesConstants.DEFAULT_DAEMON_PORT); - ui.savePluginPreferences(); - } public static boolean getShowLocalConnection() { return showLocalConnection; diff --git a/rse/plugins/org.eclipse.rse.ui/plugin.properties b/rse/plugins/org.eclipse.rse.ui/plugin.properties index 012d4a2d500..81483e94054 100644 --- a/rse/plugins/org.eclipse.rse.ui/plugin.properties +++ b/rse/plugins/org.eclipse.rse.ui/plugin.properties @@ -73,7 +73,6 @@ Perspective.Explorer = Remote System Explorer PreferencePage.Logging = Logging PreferencePage.RemoteSystems = Remote Systems PreferencePage.Signon = Passwords -PreferencePage.Communications = Communications Nature.RemoteSystemsNature = Remote System Nature Nature.RemoteSystemsTempNature = Remote System Temp Nature diff --git a/rse/plugins/org.eclipse.rse.ui/plugin.xml b/rse/plugins/org.eclipse.rse.ui/plugin.xml index aec94eee1a7..87e5758a8d1 100644 --- a/rse/plugins/org.eclipse.rse.ui/plugin.xml +++ b/rse/plugins/org.eclipse.rse.ui/plugin.xml @@ -164,12 +164,6 @@ Contributors: class="org.eclipse.rse.ui.propertypages.SignonPreferencePage" id="org.eclipse.rse.ui.preferences.SignonPreferencePage"> - -
- * It is the implementors responsability to close the socket and clean - * up all associated resources (like the InputStream) when finished. - * - * @param socket The communications socket connected to the remote peer. The only - * thing read of the socket will have been the request key. - */ - public void handleRequest(Socket socket, int requestKey); - -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/ISystemCommunicationsDaemonListener.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/ISystemCommunicationsDaemonListener.java deleted file mode 100644 index 140ffe4b8bf..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/ISystemCommunicationsDaemonListener.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.core.comm; - -/** - * Listener interface for thoes that are interested in events from the SystemCommunicationsDaemon. - * - * @author yantzi - */ -public interface ISystemCommunicationsDaemonListener -{ - - /** - * This method is invoked whenever the state of the SystemCommunicationsDaemon changes. For example - * if the daemon is started, stopped or ends in error. - */ - public void daemonStateChanged(SystemCommunicationsDaemonEvent event); -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/SystemCommunicationsDaemon.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/SystemCommunicationsDaemon.java deleted file mode 100644 index 3ab288d55e4..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/SystemCommunicationsDaemon.java +++ /dev/null @@ -1,446 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.core.comm; - -import java.io.IOException; -import java.io.InputStream; -import java.net.ServerSocket; -import java.net.Socket; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import org.eclipse.rse.core.SystemBasePlugin; -import org.eclipse.rse.internal.ui.actions.SystemStartCommunicationsDaemonAction; -import org.eclipse.rse.services.clientserver.messages.SystemMessage; -import org.eclipse.rse.ui.ISystemMessages; -import org.eclipse.rse.ui.ISystemPreferencesConstants; -import org.eclipse.rse.ui.RSEUIPlugin; -import org.eclipse.rse.ui.actions.DisplaySystemMessageAction; -import org.eclipse.swt.widgets.Display; - - -/** - * Communications daemon that can be used by other functions for receiving incoming socket - * requests. Functions need to implement the ICommunicationsDaemonHandler interface and register - * a unique 4 byte id (as an integer) which the server sends across the socket to let the - * daemon know which local function to pass the socket off to. - */ -public class SystemCommunicationsDaemon extends Thread { - - - private static final String THREAD_NAME = "RSE daemon"; //$NON-NLS-1$ - - // Communication Daemon Request Handlers - private static Map handlers = new Hashtable(50); - private static List _listeners = new Vector(10); - - // Starting point for dynamically generated keys - private static int _nextKey = 0xD0000000; - - // Instance fields - private static SystemCommunicationsDaemon inst = null; - private boolean halt = false; - private ServerSocket serverSocket; - private boolean displayErrors = true; - - // We need to hold a reference to the _startAction in order to change the "Stop Daemon" label - // to "Start Daemon" if the daemon fails. - private static SystemStartCommunicationsDaemonAction _startAction; - - /** - * Inner class for running ICommunicationHandlers on a new thread. This is done - * for two main reasons: - * 1. Allow the communication daemon to continue handling requests while - * processing other requests (this is important because some requests - * like the program verifiers run long. - * 2. Keep the communications daemon safe from crashes (unhandled exceptions) - * in the communication handlers. - */ - protected class CommunicationHandlerThread extends Thread - { - private ISystemCommunicationsDaemonHandler _handler; - private Socket _socket; - private int _requestKey; - - protected CommunicationHandlerThread(ISystemCommunicationsDaemonHandler handler, Socket socket, int requestKey) - { - _handler = handler; - _socket = socket; - _requestKey = requestKey; - } - - public void run() - { - _handler.handleRequest(_socket, _requestKey); - } - } - - /** - * Singleton, so constructor is private. Use the getInstance method - * to retrieve and instance of this class. - */ - private SystemCommunicationsDaemon() { - } - - /** - * Returns the singleton instance of this class. If the an instance - * has already been created then it is returned, otherwise a new - * instance is created and returned. - */ - public static synchronized SystemCommunicationsDaemon getInstance() - { - if (inst == null) - { - inst = new SystemCommunicationsDaemon(); - } - return inst; - } - - /* - * Stop the communications daemon - */ - private void halt() { - halt = true; - if (serverSocket != null) { - try { - serverSocket.close(); - - // yantzi:2.1.2 (defect 49812) wait for RSE daemon thread to finish (wait at most 5 seconds) - if (inst != null) - { - inst.join(5000); - } - - } - catch (IOException e) - { - SystemBasePlugin.logError("RSE Communications daemon: Unable to close socket", e); //$NON-NLS-1$ - } - catch (InterruptedException e) - { - // some other thread interrupted this one (which should not happen - SystemBasePlugin.logError("SystemCommunicationsDaemon.halt", e); //$NON-NLS-1$ - } - } - } - - /** - * @see Thread#run() - */ - public void run() { - byte[] buffer; - Socket socket = null; - InputStream in = null; - - setName(THREAD_NAME); - - // Create server socket and start listening - int port = RSEUIPlugin.getDefault().getPreferenceStore().getInt(ISystemPreferencesConstants.DAEMON_PORT); - - try { - serverSocket = new ServerSocket(port); - - fireStateChangeEvent(SystemCommunicationsDaemonEvent.STARTED); - - // Process incoming socket connections - while (!halt) { - socket = serverSocket.accept(); - - // Pass incoming socket off to the appropriate handler, - // the first four bytes (integer) determines the handler. - in = socket.getInputStream(); - buffer = new byte[4]; - in.read(buffer); - - // RequestKey (integer) must be sent as Big Endian (high order bits first) - // convert first four bytes to Java integer - int requestKey = 0 | (buffer[0] << 24); - - requestKey = requestKey | ((buffer[1] << 24) >>> 8); - requestKey = requestKey | ((buffer[2] << 24) >>> 16); - requestKey = requestKey | ((buffer[3] << 24) >>> 24); - - - // yantzi: 5.0.1: changed from asking hanlder for request key to requiring - // handler to provide key when they are registered. - ISystemCommunicationsDaemonHandler handler = (ISystemCommunicationsDaemonHandler) handlers.get(new Integer(requestKey)); - - if (handler != null) - { - new CommunicationHandlerThread(handler, socket, requestKey).start(); - } - else - { - // handler not found - SystemBasePlugin.logWarning("SystemCommunicationsDaemon: Handler not found for key " + requestKey); //$NON-NLS-1$ - socket.close(); - } - } - } catch (IOException e) { - if (!halt) - { - SystemBasePlugin.logError("CommunicationsDaemon, IOException occured during communications daemon request",e); //$NON-NLS-1$ - - fireStateChangeEvent(SystemCommunicationsDaemonEvent.STOPPED_IN_ERROR); - - // yantzi:2.1.2 (defect 51016) Suppress error messages when workbench is first starting up - if (displayErrors) - { - SystemMessage msg = RSEUIPlugin.getPluginMessage(ISystemMessages.MSG_COMM_DAEMON_NOTSTARTED); - msg.makeSubstitution(new Integer(port)); - Display.getDefault().asyncExec(new DisplaySystemMessageAction(msg)); - } - - // Reset label of action - if (_startAction != null) - { - _startAction.setActionLabelToStart(); - } - } - else - { - fireStateChangeEvent(SystemCommunicationsDaemonEvent.STOPPED); - } - } finally { - serverSocket = null; - //dy need to get a new thread next time in order to re-run - inst = null; - } - } - - /** - * Start the communications daemon if it is not already running - */ - public synchronized void startDaemon() - { - startDaemon(true); - } - - /** - * Start the communications daemon if it is not already running - * - * @param displayErrors true if error messages should be displayed, false - * if they should be not be displayed. - */ - public synchronized void startDaemon(boolean displayErrors) { - if (!isRunning()) - { - SystemBasePlugin.logDebugMessage("CommunicationsDaemon.startDaemon()", "Starting iSeries Communications Daemon"); //$NON-NLS-1$ //$NON-NLS-2$ - - //yantzi:2.1.2 added boolean to suppress error messages when workbench is first being started - - if (_startAction != null) - { - _startAction.setActionLabelToStop(); - } - - // Just in case someone cached an old copy of the daemon ... - SystemCommunicationsDaemon daemon = getInstance(); - daemon.displayErrors = displayErrors; - daemon.start(); - } - else - { - SystemBasePlugin.logDebugMessage("CommunicationsDaemon.startDaemon()", "Daemon already started"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Stops the communications daemon if it is running - */ - public synchronized void stopDaemon() { - if (isRunning()) - { - - if (_startAction != null) - { - _startAction.setActionLabelToStart(); - } - - SystemBasePlugin.logDebugMessage("RSE CommunicationsDaemon.stopDaemon()", "Stopping iSeries Communications Daemon"); //$NON-NLS-1$ //$NON-NLS-2$ - getInstance().halt(); - - // Need to get rid of the old Thread object and create a new - // one next time (calling start on the same thread object twice - // does not seem to work. DY - inst = null; - - } - else - { - SystemBasePlugin.logDebugMessage("RSE CommunicationsDaemon.stopDaemon()", "Daemon already stopped"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - /** - * Returns the port the daemon is currently running on, or zero if the - * daemon is not running. - */ - public synchronized int getPort() { - if (isRunning()) - { - return serverSocket.getLocalPort(); - } - - return 0; - } - - /** - * Check to see if the iSeries communications daemon is running - * - * @return true if the communications daemon is running, false if it - * is not running - */ - public synchronized boolean isRunning() { - return serverSocket != null; - } - - // - // Helper methods - // - - /** - * Returns the user preference for auto-starting the communications daemon - * when the Workbench starts. - */ - public static boolean isAutoStart() { - return RSEUIPlugin.getDefault().getPreferenceStore().getBoolean(ISystemPreferencesConstants.DAEMON_AUTOSTART); - } - - /** - * Add a new CommunicationsDaemonHandler - * - * @see ISystemCommunicationsDaemonHandler - * - * @param requestKey - * - * The request key must be four byte integer key used by this handler. This - * is the first thing that much be sent over the socket from the corresponding - * client / server when connecting to the RSE communications daemon. The daemon - * when then compare this integer against all registered handlers and pass off the - * socket connection (via the handleRequest method) to the first match. - * - * Use the SystemCommunicationsDaemon.getInstance().addCommunicationsDaemonHandler(...) - * method to register with the daemon. There is also a corresponding remove method. - * - * Known handlers: - * RSEInteractiveJobHandler 0x67DF7A14 - * CODECommIntegrationHandler 0xA387E2CD - * iSeries DebugEngine - * - * The range of integers from 0xD0000000 to 0xFFFFFFFF is reserved for dyanmically - * generated kes. - * - * @return true if the handler was registered, false it the handler was not registered because - * the requestKey is already being used - */ - public boolean addCommunicationsDaemonHandler(ISystemCommunicationsDaemonHandler handler, int requestKey) - { - Integer key = new Integer(requestKey); - - if (!handlers.containsKey(key)) - { - handlers.put(key, handler); - return true; - } - - return false; - } - - /** - * Remove a CommunicationsDaemonHandler - * - * @see ISystemCommunicationsDaemonHandler - */ - public void removeCommunicationsDaemonHandler(int requestKey) - { - handlers.remove(new Integer(requestKey)); - } - - /** - * Sets the SystemStartCommunicationsDaemon action. This is used to change the - * label of the action if the daemon fails to start or fails during regular - * operation. - */ - public static void setAction(SystemStartCommunicationsDaemonAction action) - { - _startAction = action; - } - - /** - * getNextKey() can be called to generated a dynamic key used by any communications - * handler. They generated key is guaranteed to be unique. Callers still need to - * call the addCommunicationsDaemonHandler() method to register their handler. - */ - public static int getNextKey() - { - int key; - - synchronized (handlers) - { - key = _nextKey; - - if (_nextKey == 0xFFFFFFFF) - { - _nextKey = 0xD0000000; - } - else - { - _nextKey++; - } - } - - return key; - } - - /** - * Add an ISystemCommunicationsDaemonListener listener to receive state change events from the SystemCommunicationsDaemon. - */ - public static void addDaemonListener(ISystemCommunicationsDaemonListener listener) - { - if (!_listeners.contains(listener)) - { - _listeners.add(listener); - } - } - - /** - * Remove the ISystemCommunicationsDaemonListener listener. - */ - public static void removeDaemonListener(ISystemCommunicationsDaemonListener listener) - { - _listeners.remove(listener); - } - - /** - * Fire a state change event for the daemon - */ - private static void fireStateChangeEvent(int newstate) - { - if (_listeners.size() > 0) - { - SystemCommunicationsDaemonEvent event = new SystemCommunicationsDaemonEvent(newstate); - for (int i = 0; i < _listeners.size(); i++) - { - ((ISystemCommunicationsDaemonListener) _listeners.get(i)).daemonStateChanged(event); - } - } - } - -} \ No newline at end of file diff --git a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/SystemCommunicationsDaemonEvent.java b/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/SystemCommunicationsDaemonEvent.java deleted file mode 100644 index 1bbfc099e41..00000000000 --- a/rse/plugins/org.eclipse.rse.ui/systems/org/eclipse/rse/core/comm/SystemCommunicationsDaemonEvent.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2002, 2006 IBM Corporation. All rights reserved. - * This program and the accompanying materials are made available under the terms - * of the Eclipse Public License v1.0 which accompanies this distribution, and is - * available at http://www.eclipse.org/legal/epl-v10.html - * - * Initial Contributors: - * The following IBM employees contributed to the Remote System Explorer - * component that contains this file: David McKnight, Kushal Munir, - * Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson, - * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. - * - * Contributors: - * {Name} (company) - description of contribution. - ********************************************************************************/ - -package org.eclipse.rse.core.comm; - -/** - * Event data for the SystemCommunicationsDaemon. - * - * @author yantzi - */ -public class SystemCommunicationsDaemonEvent -{ - // Communications daemon event types - public static final int STARTED = 1; - public static final int STOPPED = 2; - public static final int STOPPED_IN_ERROR = 3; - - private int state; - - /** - * Constructor for SystemCommunicationsDaemonEvent - * - * @state The new state for the daemon. - */ - public SystemCommunicationsDaemonEvent(int state) - { - this.state = state; - } - - /** - * Get the new state for the communications daemon. - */ - public int getState() - { - return state; - } -} \ No newline at end of file