From 2cbfd023fed12c0c0c1643854bd3c9975cb5cb2f Mon Sep 17 00:00:00 2001 From: David McKnight Date: Thu, 22 Feb 2007 21:04:29 +0000 Subject: [PATCH] [175142] added delegating connector service interface, abstract impl and concrete impl for shell processes --- .../IDelegatingConnectorService.java | 19 + ...elegatingShellProcessConnectorService.java | 42 ++ .../ShellProcessSubSystemConfiguration.java | 11 +- .../services/FactoryServiceElement.java | 33 +- .../AbstractDelegatingConnectorService.java | 568 ++++++++++++++++++ 5 files changed, 661 insertions(+), 12 deletions(-) create mode 100644 rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IDelegatingConnectorService.java create mode 100644 rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/DelegatingShellProcessConnectorService.java create mode 100644 rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IDelegatingConnectorService.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IDelegatingConnectorService.java new file mode 100644 index 00000000000..dece5bcc919 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/core/subsystems/IDelegatingConnectorService.java @@ -0,0 +1,19 @@ +/******************************************************************************** + * Copyright (c) 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. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ +package org.eclipse.rse.core.subsystems; + +public interface IDelegatingConnectorService extends IConnectorService +{ + public IConnectorService getRealConnectorService(); +} diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/DelegatingShellProcessConnectorService.java b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/DelegatingShellProcessConnectorService.java new file mode 100644 index 00000000000..0922d968b35 --- /dev/null +++ b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/DelegatingShellProcessConnectorService.java @@ -0,0 +1,42 @@ +/******************************************************************************** + * Copyright (c) 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. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ +package org.eclipse.rse.subsystems.processes.shell.linux; + +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.subsystems.AbstractDelegatingConnectorService; +import org.eclipse.rse.core.subsystems.IConnectorService; +import org.eclipse.rse.internal.subsystems.processes.shell.linux.Activator; +import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShellServiceSubSystem; + +public class DelegatingShellProcessConnectorService extends AbstractDelegatingConnectorService +{ + + public DelegatingShellProcessConnectorService(IHost host) { + super(host); + } + + public IConnectorService getRealConnectorService() + { + IShellServiceSubSystem ss = Activator.getShellServiceSubSystem(getHost()); + if (ss != null) + { + return ss.getConnectorService(); + } + else + { + return null; + } + } + +} diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/ShellProcessSubSystemConfiguration.java b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/ShellProcessSubSystemConfiguration.java index 0282985d7fd..85a03607ea7 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/ShellProcessSubSystemConfiguration.java +++ b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/subsystems/processes/shell/linux/ShellProcessSubSystemConfiguration.java @@ -54,12 +54,17 @@ public class ShellProcessSubSystemConfiguration extends return hostProcessAdapter; } - public IConnectorService getConnectorService(IHost host) { + public IConnectorService getConnectorService(IHost host) + { IShellServiceSubSystem ss = Activator.getShellServiceSubSystem(host); - if (ss!=null) { + if (ss!=null) + { return ss.getConnectorService(); } - return null; + else + { + return new DelegatingShellProcessConnectorService(host); + } } public Class getServiceImplType() { diff --git a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/services/FactoryServiceElement.java b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/services/FactoryServiceElement.java index 4e7ba03356d..8723d4d9fee 100644 --- a/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/services/FactoryServiceElement.java +++ b/rse/plugins/org.eclipse.rse.ui/UI/org/eclipse/rse/ui/widgets/services/FactoryServiceElement.java @@ -18,6 +18,7 @@ package org.eclipse.rse.ui.widgets.services; import org.eclipse.rse.core.model.IHost; import org.eclipse.rse.core.subsystems.IConnectorService; +import org.eclipse.rse.core.subsystems.IDelegatingConnectorService; import org.eclipse.rse.core.subsystems.IServerLauncherProperties; import org.eclipse.rse.core.subsystems.IServiceSubSystemConfiguration; import org.eclipse.rse.model.DummyHost; @@ -73,20 +74,30 @@ public class FactoryServiceElement extends ServiceElement if (_children == null) { IHost host = getHost(); - _children = new ServiceElement[2]; - _children[0] = new ServiceServiceElement(host, this, getService()); + + ServiceServiceElement serviceElement = new ServiceServiceElement(host, this, getService()); IConnectorService connectorService = getConnectorService(); - _children[1] = new ConnectorServiceElement(host, this, connectorService); - if (host instanceof DummyHost) + if (connectorService != null && !(connectorService instanceof IDelegatingConnectorService)) { - IServerLauncherProperties sl = connectorService.getRemoteServerLauncherProperties(); - if (sl == null) + _children = new ServiceElement[2]; + _children[0] = serviceElement; + _children[1] = new ConnectorServiceElement(host, this, connectorService); + if (host instanceof DummyHost) { - sl = _factory.createServerLauncher(connectorService); - connectorService.setRemoteServerLauncherProperties(sl); + IServerLauncherProperties sl = connectorService.getRemoteServerLauncherProperties(); + if (sl == null) + { + sl = _factory.createServerLauncher(connectorService); + connectorService.setRemoteServerLauncherProperties(sl); + } } } + else + { + _children = new ServiceElement[1]; + _children[0] = serviceElement; + } } return _children; @@ -119,10 +130,14 @@ public class FactoryServiceElement extends ServiceElement public void commit() { + if (_isSelected) + { ServiceElement[] children = getChildren(); for (int i = 0; i < children.length; i++) { - children[i].commit(); + //if (children[i].isSelected()) + children[i].commit(); + } } } diff --git a/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java new file mode 100644 index 00000000000..0028dafed6c --- /dev/null +++ b/rse/plugins/org.eclipse.rse.ui/subsystems/org/eclipse/rse/core/subsystems/AbstractDelegatingConnectorService.java @@ -0,0 +1,568 @@ +/******************************************************************************** + * Copyright (c) 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. + * + * Contributors: + * {Name} (company) - description of contribution. + ********************************************************************************/ +package org.eclipse.rse.core.subsystems; + +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.IPropertySet; +import org.eclipse.rse.core.subsystems.ICommunicationsListener; +import org.eclipse.rse.core.subsystems.IConnectorService; +import org.eclipse.rse.core.subsystems.IServerLauncherProperties; +import org.eclipse.rse.core.subsystems.ISubSystem; + +public abstract class AbstractDelegatingConnectorService implements IDelegatingConnectorService +{ + + protected IHost _host; + public AbstractDelegatingConnectorService(IHost host) + { + _host = host; + } + + + public abstract IConnectorService getRealConnectorService(); + + public void addCommunicationsListener(ICommunicationsListener listener) + { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.addCommunicationsListener(listener); + } + + } + + public void clearPasswordCache() + { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.clearPasswordCache(); + } + + } + + public void clearPasswordCache(boolean clearDiskCache) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.clearPasswordCache(clearDiskCache); + } + + } + + public void clearUserIdCache() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.clearUserIdCache(); + } + } + + public void connect(IProgressMonitor monitor) throws Exception { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.connect(monitor); + } + } + + public void deregisterSubSystem(ISubSystem ss) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.deregisterSubSystem(ss); + } + } + + public void disconnect(IProgressMonitor monitor) throws Exception { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.disconnect(monitor); + } + + } + + public String getHomeDirectory() + { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getHomeDirectory(); + } + return null; + } + + public IHost getHost() + { + return _host; + } + + public String getHostName() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getHostName(); + } + return null; + } + + public String getHostType() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getHostType(); + } + return null; + } + + public String getName() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getName(); + } + return null; + } + + public int getPort() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getPort(); + } + return 0; + } + + public ISubSystem getPrimarySubSystem() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getPrimarySubSystem(); + } + return null; + } + + public IServerLauncherProperties getRemoteServerLauncherProperties() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getRemoteServerLauncherProperties(); + } + return null; + } + + public ISubSystem[] getSubSystems() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getSubSystems(); + } + return null; + } + + public String getTempDirectory() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getTempDirectory(); + } + return null; + } + + public String getUserId() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getUserId(); + } + return null; + } + + public String getVersionReleaseModification() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getVersionReleaseModification(); + } + return null; + } + + public boolean hasRemoteServerLauncherProperties() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.hasRemoteServerLauncherProperties(); + } + return false; + } + + public boolean inheritConnectionUserPassword() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.inheritConnectionUserPassword(); + } + return false; + } + + public boolean isConnected() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.isConnected(); + } + return false; + } + + public boolean isPasswordCached() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.isPasswordCached(); + } + return false; + } + + public boolean isPasswordCached(boolean onDisk) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.isPasswordCached(onDisk); + } + return false; + } + + public boolean isSuppressSignonPrompt() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.isSuppressSignonPrompt(); + } + return false; + } + + public boolean isUsingSSL() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.isUsingSSL(); + } + return false; + } + + public void notifyConnection() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.notifyConnection(); + } + } + + public void notifyDisconnection() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.notifyDisconnection(); + } + } + + public void notifyError() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.notifyError(); + } + } + + public void promptForPassword(boolean forcePrompt) + throws InterruptedException { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.promptForPassword(forcePrompt); + } + } + + public void registerSubSystem(ISubSystem ss) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.registerSubSystem(ss); + } + } + + public void removeCommunicationsListener(ICommunicationsListener listener) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.removeCommunicationsListener(listener); + } + } + + public boolean requiresPassword() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.requiresPassword(); + } + return false; + } + + public boolean requiresUserId() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.requiresUserId(); + } + return false; + } + + public void reset() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.reset(); + } + } + + public void setHost(IHost host) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setHost(host); + } + } + + public void setIsUsingSSL(boolean flag) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setIsUsingSSL(flag); + } + } + + public void setPassword(String matchingUserId, String password) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setPassword(matchingUserId, password); + } + } + + public void setPassword(String matchingUserId, String password, + boolean persist) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setPassword(matchingUserId, password, persist); + } + } + + public void setPort(int port) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setPort(port); + } + } + + public void setRemoteServerLauncherProperties( + IServerLauncherProperties value) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setRemoteServerLauncherProperties(value); + } + } + + public void setSuppressSignonPrompt(boolean suppressSignonPrompt) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setSuppressSignonPrompt(suppressSignonPrompt); + } + } + + public void setUserId(String userId) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setUserId(userId); + } + } + + public boolean shareUserPasswordWithConnection() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.shareUserPasswordWithConnection(); + } + return false; + } + + public boolean supportsPassword() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.supportsPassword(); + } + return false; + } + + public boolean supportsRemoteServerLaunching() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.supportsRemoteServerLaunching(); + } + return false; + } + + public boolean supportsServerLaunchProperties() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.supportsServerLaunchProperties(); + } + return false; + } + + public boolean supportsUserId() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.supportsUserId(); + } + return false; + } + + public String getDescription() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getDescription(); + } + return null; + } + + public boolean addPropertySet(IPropertySet set) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.addPropertySet(set); + } + return false; + } + + public boolean addPropertySets(IPropertySet[] sets) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.addPropertySets(sets); + } + return false; + } + + public IPropertySet createPropertySet(String name) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.createPropertySet(name); + } + return null; + } + + public IPropertySet createPropertySet(String name, String description) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.createPropertySet(name, description); + } + return null; + } + + public IPropertySet getPropertySet(String name) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getPropertySet(name); + } + return null; + } + + public IPropertySet[] getPropertySets() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.getPropertySets(); + } + return null; + } + + public boolean removePropertySet(String name) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.removePropertySet(name); + } + return false; + } + + public boolean commit() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.commit(); + } + return false; + } + + public boolean isDirty() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.isDirty(); + } + return false; + } + + public void setDirty(boolean flag) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setDirty(flag); + } + } + + public void setWasRestored(boolean flag) { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + conServ.setWasRestored(flag); + } + } + + public boolean wasRestored() { + IConnectorService conServ = getRealConnectorService(); + if (conServ != null) + { + return conServ.wasRestored(); + } + return false; + } + +}