diff --git a/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF
index ad46d7bfdaf..908862dc222 100644
--- a/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.remote.core/META-INF/MANIFEST.MF
@@ -2,20 +2,20 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.remote.core;singleton:=true
-Bundle-Version: 1.0.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.remote.internal.core.RemoteCorePlugin
Bundle-Vendor: %pluginProvider
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.filesystem,
org.eclipse.core.resources,
- org.eclipse.core.variables
+ org.eclipse.core.variables,
+ org.eclipse.debug.core
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.remote.core,
org.eclipse.remote.core.exception,
+ org.eclipse.remote.core.launch,
org.eclipse.remote.internal.core;x-friends:="org.eclipse.remote.ui,org.eclipse.remote.jsch.core",
- org.eclipse.remote.internal.core.messages;x-internal:=true,
- org.eclipse.remote.internal.core.preferences;x-friends:="org.eclipse.remote.ui",
- org.eclipse.remote.internal.core.services.local;x-internal:=true
+ org.eclipse.remote.internal.core.preferences;x-friends:="org.eclipse.remote.ui"
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Import-Package: org.eclipse.equinox.security.storage
diff --git a/bundles/org.eclipse.remote.core/plugin.xml b/bundles/org.eclipse.remote.core/plugin.xml
index 649790aaebd..9ed983dc93f 100644
--- a/bundles/org.eclipse.remote.core/plugin.xml
+++ b/bundles/org.eclipse.remote.core/plugin.xml
@@ -7,12 +7,22 @@
-
-
+
+
+
+
+
diff --git a/bundles/org.eclipse.remote.core/pom.xml b/bundles/org.eclipse.remote.core/pom.xml
index beb3dbd84f9..542bfe6e278 100644
--- a/bundles/org.eclipse.remote.core/pom.xml
+++ b/bundles/org.eclipse.remote.core/pom.xml
@@ -11,6 +11,6 @@
org.eclipse.remote.core
- 1.0.0-SNAPSHOT
+ 2.0.0-SNAPSHOTeclipse-plugin
diff --git a/bundles/org.eclipse.remote.core/schema/remoteServices.exsd b/bundles/org.eclipse.remote.core/schema/remoteServices.exsd
index 598fca3e0d2..ad5a5424dd4 100644
--- a/bundles/org.eclipse.remote.core/schema/remoteServices.exsd
+++ b/bundles/org.eclipse.remote.core/schema/remoteServices.exsd
@@ -17,8 +17,10 @@
-
-
+
+
+
+
@@ -47,11 +49,14 @@
-
+
+
+ A connection type.
+
@@ -71,35 +76,103 @@
-
+
An EFS scheme name for this service
-
+
- The fully qualified name of the Java class implementing <samp>org.eclipse.remote.core.IRemoteServicesFactory</samp>.
+ The capabilities of this connection. This an integer created by ORing the applicable capabilities as listed in IRemoteServices.
+
+
+
+
+
+
+
+
+
+ This is a service that implements the given service interface for a given connection type.
+
+
+
+
+
+
+ The remote services that this service applies to.
-
+
+
+
+
+
+
+
+ The interface class that this service implements. The service is found by calling the getService() method on the IRemoteServices object with this interface class as the parameter.
+
+
+
+
+
+
+
+
+
+ The factory class used to instantiate the service.
+
+
+
+
+
+
+ This is a service that implements the given service interface for connections of a given connection type.
+
+
+
+
+
+
+ The connection type for the connections that this service applies to.
+
+
+
+
+
+
+
+
+
+ The interface class that this service implements. The service is found by calling the getService() method on the IRemoteConnection object with this interface class as the parameter.
+
+
+
+
+
+
+
+
+
+ The factory class used to instantiate the service.
+
+
+
+
+
+
+
+
-
-
-
-
-
- The value of the class attribute must implement <samp>org.eclipse.remote.core.IRemoteServicesFactory</samp>.
-
-
@@ -120,6 +193,15 @@
+
+
+
+
+
+ The value of the class attribute must implement <samp>org.eclipse.remote.core.IRemoteServicesFactory</samp>.
+
+
+
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/AbstractRemoteConnectionManager.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/AbstractRemoteConnectionManager.java
deleted file mode 100644
index e3f9a63f6c2..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/AbstractRemoteConnectionManager.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.core;
-
-import java.lang.reflect.Constructor;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.remote.internal.core.RemoteCorePlugin;
-
-/**
- * Abstract base class for remote connection managers.
- *
- * @since 8.0
- */
-public abstract class AbstractRemoteConnectionManager implements IRemoteConnectionManager {
- private static final String AUTHENTICATOR_EXTENSION_POINT_ID = "authenticator"; //$NON-NLS-1$
- private static final String ID_ATTR = "id"; //$NON-NLS-1$
- private static final String CLASS_ATTR = "class"; //$NON-NLS-1$
- private static final String PRIORITY_ATTR = "priority"; //$NON-NLS-1$
-
- private final IRemoteServices fRemoteServices;
- private boolean fLoaded;
- private Constructor> fUserAuthenticatorConstructor;
-
- public AbstractRemoteConnectionManager(IRemoteServices services) {
- fRemoteServices = services;
- }
-
- protected IRemoteServices getRemoteServices() {
- return fRemoteServices;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionManager#getUserAuthenticator()
- */
- @Override
- public IUserAuthenticator getUserAuthenticator(IRemoteConnection connection) {
- if (!fLoaded) {
- int currPriority = -1;
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(),
- AUTHENTICATOR_EXTENSION_POINT_ID);
- final IExtension[] extensions = extensionPoint.getExtensions();
-
- for (IExtension ext : extensions) {
- final IConfigurationElement[] elements = ext.getConfigurationElements();
-
- for (IConfigurationElement ce : elements) {
- String id = ce.getAttribute(ID_ATTR);
- if (id.equals(getRemoteServices().getId())) {
- int priority = 0;
- String priorityAttr = ce.getAttribute(PRIORITY_ATTR);
- if (priorityAttr != null) {
- try {
- priority = Integer.parseInt(priorityAttr);
- } catch (NumberFormatException e) {
- // Assume default
- }
- }
- if (priority > currPriority) {
- try {
- String widgetClass = ce.getAttribute(CLASS_ATTR);
- Class> cls = Platform.getBundle(ce.getDeclaringExtension().getContributor().getName()).loadClass(
- widgetClass);
- if (cls != null) {
- fUserAuthenticatorConstructor = cls.getConstructor(IRemoteConnection.class);
- currPriority = priority;
- }
- } catch (ClassNotFoundException | NoSuchMethodException e) {
- RemoteCorePlugin.log(e);
- }
- }
- }
- }
- }
- fLoaded = true;
- }
- if (fUserAuthenticatorConstructor != null) {
- try {
- return (IUserAuthenticator) fUserAuthenticatorConstructor.newInstance(connection);
- } catch (Exception e) {
- RemoteCorePlugin.log(e);
- }
- }
- return null;
- }
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/AbstractRemoteServices.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/AbstractRemoteServices.java
deleted file mode 100644
index da4adc4704e..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/AbstractRemoteServices.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.core;
-
-/**
- * Abstract base class for remote services. Implementors can use this class to provide a default implementation of a remote
- * services provider.
- *
- * @since 5.0
- */
-public abstract class AbstractRemoteServices implements IRemoteServices {
-
- protected final IRemoteServicesDescriptor fDescriptor;
-
- public AbstractRemoteServices(IRemoteServicesDescriptor descriptor) {
- fDescriptor = descriptor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(IRemoteServicesDescriptor o) {
- return fDescriptor.compareTo(o);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServicesDescriptor#getId()
- */
- @Override
- public String getId() {
- return fDescriptor.getId();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServicesDescriptor#getName()
- */
- @Override
- public String getName() {
- return fDescriptor.getName();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServicesDescriptor#getScheme()
- */
- @Override
- public String getScheme() {
- return fDescriptor.getScheme();
- }
-}
\ No newline at end of file
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteCommandShellService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteCommandShellService.java
new file mode 100644
index 00000000000..1f85e18a5e7
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteCommandShellService.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core;
+
+import java.io.IOException;
+
+/**
+ * A service that provides a command shell on a remote. This is mainly used by
+ * Terminal views.
+ *
+ * @since 2.0
+ */
+public interface IRemoteCommandShellService extends IRemoteConnection.Service {
+
+ /**
+ * Get a remote process that runs a command shell on the remote system. The shell will be the user's default shell on the remote
+ * system. The flags may be used to modify behavior of the remote process. These flags may only be supported by specific types
+ * of remote service providers. Clients can use {@link IRemoteProcessBuilder#getSupportedFlags()} to find out the flags
+ * supported by the service provider.
+ *
+ *
+ * Current flags are:
+ * {@link IRemoteProcessBuilder#NONE} - disable any flags
+ * {@link IRemoteProcessBuilder#ALLOCATE_PTY} - allocate a pseudo-terminal for the process (RFC-4254 Sec. 6.2)
+ * {@link IRemoteProcessBuilder#FORWARD_X11} - enable X11 forwarding (RFC-4254 Sec. 6.3)
+ *
+ *
+ * @param flags
+ * bitwise-or of flags
+ * @return remote process object
+ * @throws IOException
+ * @since 7.0
+ */
+ public IRemoteProcess getCommandShell(int flags) throws IOException;
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnection.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnection.java
index 5a86677268c..f8373156598 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnection.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnection.java
@@ -10,177 +10,48 @@
*******************************************************************************/
package org.eclipse.remote.core;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.remote.core.exception.RemoteConnectionException;
/**
- * Abstraction of a connection to a remote system. Clients should use the set methods to provide information on the remote system,
- * then call the {{@link #open(IProgressMonitor)} method. Once the connection is completed, call the {@link #close()} method to
- * terminate the connection.
+ * Represents a connection to a remote system. Use the getService method to get at connection
+ * specific services. Connections have state, open or closed. Some connection types are always
+ * open in which case the close does nothing. Connections have properties which are values that
+ * describe the connection and are discovered. Connections also have attributes which are
+ * client specified values that control the connection.
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
*/
-public interface IRemoteConnection extends Comparable {
- public final static String OS_NAME_PROPERTY = "os.name"; //$NON-NLS-1$
- public final static String OS_VERSION_PROPERTY = "os.version"; //$NON-NLS-1$
- public final static String OS_ARCH_PROPERTY = "os.arch"; //$NON-NLS-1$
+public interface IRemoteConnection {
/**
- * @since 6.0
+ * The interface that is extend by services provided for this remote connection.
+ * @since 2.0
*/
- public final static String FILE_SEPARATOR_PROPERTY = "file.separator"; //$NON-NLS-1$
- /**
- * @since 6.0
- */
- public final static String PATH_SEPARATOR_PROPERTY = "path.separator"; //$NON-NLS-1$
- /**
- * @since 6.0
- */
- public final static String LINE_SEPARATOR_PROPERTY = "line.separator"; //$NON-NLS-1$
- /**
- * @since 4.0
- */
- public final static String USER_HOME_PROPERTY = "user.home"; //$NON-NLS-1$
+ interface Service {
+ IRemoteConnection getRemoteConnection();
+
+ interface Factory {
+ T getService(IRemoteConnection remoteConnection, Class service);
+ }
+ }
+
+ // Common properties
+ final static String OS_NAME_PROPERTY = "os.name"; //$NON-NLS-1$
+ final static String OS_VERSION_PROPERTY = "os.version"; //$NON-NLS-1$
+ final static String OS_ARCH_PROPERTY = "os.arch"; //$NON-NLS-1$
+ final static String FILE_SEPARATOR_PROPERTY = "file.separator"; //$NON-NLS-1$
+ final static String PATH_SEPARATOR_PROPERTY = "path.separator"; //$NON-NLS-1$
+ final static String LINE_SEPARATOR_PROPERTY = "line.separator"; //$NON-NLS-1$
+ final static String USER_HOME_PROPERTY = "user.home"; //$NON-NLS-1$
/**
- * Register a listener that will be notified when this connection's status changes.
+ * Get the connection type of this connection
*
- * @param listener
+ * @return connection type
+ * @since 2.0
*/
- public void addConnectionChangeListener(IRemoteConnectionChangeListener listener);
-
- /**
- * Close the connection. Must be called to terminate the connection.
- */
- public void close();
-
- /**
- * Notify all listeners when this connection's status changes. See {{@link IRemoteConnectionChangeEvent} for a list of event
- * types.
- *
- * @param event
- * event type indicating the nature of the event
- */
- public void fireConnectionChangeEvent(int type);
-
- /**
- * Forward local port localPort to remote port fwdPort on remote machine fwdAddress. If this IRemoteConnection is not to
- * fwdAddress, the port will be routed via the connection machine to fwdAddress.
- *
- * @param localPort
- * local port to forward
- * @param fwdAddress
- * address of remote machine
- * @param fwdPort
- * remote port on remote machine
- * @throws RemoteConnectionException
- */
- public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
-
- /**
- * Forward a local port to remote port fwdPort on remote machine fwdAddress. The local port is chosen dynamically and returned
- * by the method. If this IRemoteConnection is not to fwdAddress, the port will be routed via the connection machine to
- * fwdAddress.
- *
- * @param fwdAddress
- * @param fwdPort
- * @param monitor
- * @return local port number
- * @throws RemoteConnectionException
- */
- public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
-
- /**
- * Forward remote port remotePort to port fwdPort on machine fwdAddress. When a connection is made to remotePort on the remote
- * machine, it is forwarded via this IRemoteConnection to fwdPort on machine fwdAddress.
- *
- * @param remotePort
- * remote port to forward
- * @param fwdAddress
- * address of recipient machine
- * @param fwdPort
- * port on recipient machine
- * @throws RemoteConnectionException
- */
- public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
-
- /**
- * Forward a remote port to port fwdPort on remote machine fwdAddress. The remote port is chosen dynamically and returned by the
- * method. When a connection is made to this port on the remote machine, it is forwarded via this IRemoteConnection to fwdPort
- * on machine fwdAddress.
- *
- * If fwdAddress is the empty string ("") then the fwdPort will be bound to any address on all interfaces. Note that this
- * requires enabling the GatewayPort sshd option on some systems.
- *
- * @param fwdAddress
- * @param fwdPort
- * @param monitor
- * @return remote port number
- * @throws RemoteConnectionException
- */
- public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
-
- /**
- * Gets the implementation dependent address for this connection
- *
- * return address
- */
- public String getAddress();
-
- /**
- * Get the implementation specific attributes for the connection.
- *
- * NOTE: the attributes do not include any security related information (e.g. passwords, keys, etc.)
- *
- * @return a map containing the connection attribute keys and values
- */
- public Map getAttributes();
-
- /**
- * Get a remote process that runs a command shell on the remote system. The shell will be the user's default shell on the remote
- * system. The flags may be used to modify behavior of the remote process. These flags may only be supported by specific types
- * of remote service providers. Clients can use {@link IRemoteProcessBuilder#getSupportedFlags()} to find out the flags
- * supported by the service provider.
- *
- *
- * Current flags are:
- * {@link IRemoteProcessBuilder#NONE} - disable any flags
- * {@link IRemoteProcessBuilder#ALLOCATE_PTY} - allocate a pseudo-terminal for the process (RFC-4254 Sec. 6.2)
- * {@link IRemoteProcessBuilder#FORWARD_X11} - enable X11 forwarding (RFC-4254 Sec. 6.3)
- *
- *
- * @param flags
- * bitwise-or of flags
- * @return remote process object
- * @throws IOException
- * @since 7.0
- */
- public IRemoteProcess getCommandShell(int flags) throws IOException;
-
- /**
- * Returns an unmodifiable string map view of the remote environment. The connection must be open prior to calling this method.
- *
- * @return the remote environment
- * @since 5.0
- */
- public Map getEnv();
-
- /**
- * Returns the value of an environment variable. The connection must be open prior to calling this method.
- *
- * @param name
- * name of the environment variable
- * @return value of the environment variable or null if the variable is not defined
- */
- public String getEnv(String name);
-
- /**
- * Get a file manager for managing remote files
- *
- * @return file manager or null if connection is not open
- */
- public IRemoteFileManager getFileManager();
+ public IRemoteConnectionType getConnectionType();
/**
* Get unique name for this connection.
@@ -190,83 +61,23 @@ public interface IRemoteConnection extends Comparable {
public String getName();
/**
- * Gets the port for this connection. Only valid if supported by the service provider.
+ * Get the service for this remote connection that implements the given interface.
*
- * return port number
- *
- * @since 5.0
+ * @param service the interface the required service must implements
+ * @return the desired service or null if there is no such service available
+ * @throws CoreException
+ * @since 2.0
*/
- public int getPort();
+ T getService(Class service);
/**
- * Get a process builder for creating remote processes
+ * Does this connection support the given service.
*
- * @return process builder or null if connection is not open
+ * @param service The service to be tested
+ * @return true if this connection supports the service
+ * @since 2.0
*/
- public IRemoteProcessBuilder getProcessBuilder(List command);
-
- /**
- * Get a process builder for creating remote processes
- *
- * @return process builder or null if connection is not open
- */
- public IRemoteProcessBuilder getProcessBuilder(String... command);
-
- /**
- * Gets the remote system property indicated by the specified key. The connection must be open prior to calling this method.
- *
- * The following keys are supported:
- *
- *
- * os.name Operating system name
- * os.arch Operating system architecture
- * os.version Operating system version
- * file.separator File separator ("/" on UNIX)
- * path.separator Path separator (":" on UNIX)
- * line.separator Line separator ("\n" on UNIX)
- * user.home Home directory
- *
- *
- * @param key
- * the name of the property
- * @return the string value of the property, or null if no property has that key
- */
- public String getProperty(String key);
-
- /**
- * Get the remote services provider for this connection.
- *
- * @return remote services provider
- * @since 4.0
- */
- public IRemoteServices getRemoteServices();
-
- /**
- * Gets the username for this connection
- *
- * return username
- */
- public String getUsername();
-
- public IRemoteConnectionWorkingCopy getWorkingCopy();
-
- /**
- * Get the working directory. Relative paths will be resolved using this path.
- *
- * The remote connection does not need to be open to use this method, however a default directory path, rather than the actual
- * working directory, may be returned in this case.
- *
- * @return String representing the current working directory
- * @since 4.0
- */
- public String getWorkingDirectory();
-
- /**
- * Test if the connection is open.
- *
- * @return true if connection is open.
- */
- public boolean isOpen();
+ boolean hasService(Class service);
/**
* Open the connection. Must be called before the connection can be used.
@@ -279,6 +90,61 @@ public interface IRemoteConnection extends Comparable {
*/
public void open(IProgressMonitor monitor) throws RemoteConnectionException;
+ /**
+ * Close the connection. Must be called to terminate the connection.
+ */
+ public void close();
+
+ /**
+ * Test if the connection is open.
+ *
+ * @return true if connection is open.
+ */
+ public boolean isOpen();
+
+ /**
+ * Gets the remote system property indicated by the specified key. The connection must be open prior to calling this method.
+ *
+ * @param key
+ * the name of the property
+ * @return the string value of the property, or null if no property has that key
+ */
+ public String getProperty(String key);
+
+ /**
+ * Get an attribute for a connection.
+ *
+ * NOTE: the attributes do not include any security related information (e.g. passwords, keys, etc.)
+ *
+ * @param key
+ * @return the attribute value, or empty string if not defined.
+ * @since 2.0
+ */
+ public String getAttribute(String key);
+
+ /**
+ * Get an attribute that is stored in secure storage, such as passwords.
+ *
+ * @param key
+ * @return the attribute value, or empty string if not defined.
+ * @since 2.0
+ */
+ public String getSecureAttribute(String key);
+
+ /**
+ * Return a working copy to allow setting and changing of attributes.
+ *
+ * @return working copy of remote
+ */
+ public IRemoteConnectionWorkingCopy getWorkingCopy();
+
+ /**
+ * Register a listener that will be notified when this connection's status changes.
+ *
+ * @param listener
+ */
+ public void addConnectionChangeListener(IRemoteConnectionChangeListener listener);
+
/**
* Remove a listener that will be notified when this connection's status changes.
*
@@ -287,41 +153,12 @@ public interface IRemoteConnection extends Comparable {
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener);
/**
- * Remove the local port forwarding associated with the given port.
+ * Notify all listeners when this connection's status changes. See {{@link RemoteConnectionChangeEvent} for a list of event
+ * types.
*
- * @param port
- * forwarded port
- * @throws RemoteConnectionException
- * @since 7.0
+ * @param event
+ * event type indicating the nature of the event
*/
- public void removeLocalPortForwarding(int port) throws RemoteConnectionException;
+ public void fireConnectionChangeEvent(int type);
- /**
- * Remove the remote port forwarding associated with the given port.
- *
- * @param port
- * forwarded port
- * @throws RemoteConnectionException
- * @since 7.0
- */
- public void removeRemotePortForwarding(int port) throws RemoteConnectionException;
-
- /**
- * Set the working directory while the connection is open. The working directory will revert to the default when the connection
- * is closed then subsequently reopened.
- *
- * Relative paths will be resolved using this path. The path must be valid and absolute for any changes to be made.
- *
- * @param path
- * String representing the current working directory
- * @since 4.0
- */
- public void setWorkingDirectory(String path);
-
- /**
- * Test if this connection supports forwarding of TCP connections
- *
- * @return true if TCP port forwarding is supported
- */
- public boolean supportsTCPPortForwarding();
}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionChangeListener.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionChangeListener.java
index 28ef2db7fe7..30c340b942f 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionChangeListener.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionChangeListener.java
@@ -13,8 +13,11 @@ package org.eclipse.remote.core;
import java.util.EventListener;
/**
- * Listener used to register for notification of connection status changes. Clients should register a listener using the
- * {@link IRemoteConnection#addConnectionChangeListener(IRemoteConnectionChangeListener)} method.
+ * Listener used to register for notification of connection status changes.
+ * Listeners can be registered on individual connections using
+ * {@link IRemoteConnection#addConnectionChangeListener(IRemoteConnectionChangeListener)},
+ * or globally for all connections using
+ * {@link IRemoteServicesManager#addRemoteConnectionChangeListener(IRemoteConnectionChangeListener)}.
*/
public interface IRemoteConnectionChangeListener extends EventListener {
@@ -23,7 +26,9 @@ public interface IRemoteConnectionChangeListener extends EventListener {
*
* @param event
* the connection change event
+ * @since 2.0
*/
- public void connectionChanged(IRemoteConnectionChangeEvent event);
+ public void connectionChanged(RemoteConnectionChangeEvent event);
+
}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionControlService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionControlService.java
new file mode 100644
index 00000000000..14d74c4818a
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionControlService.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+
+/**
+ * A service to control and report on the state of a connection, open or closed.
+ * Connections that do not provide this service are always assumed to be opened.
+ *
+ * @since 2.0
+ */
+public interface IRemoteConnectionControlService extends IRemoteConnection.Service {
+
+ /**
+ * Open the connection. Must be called before the connection can be used.
+ *
+ * @param monitor
+ * the progress monitor to use for reporting progress to the user. It is the caller's responsibility to call done()
+ * on the given monitor. Accepts null, indicating that no progress should be reported and that the operation cannot
+ * be cancelled.
+ * @throws RemoteConnectionException
+ */
+ public void open(IProgressMonitor monitor) throws RemoteConnectionException;
+
+ /**
+ * Close the connection. Must be called to terminate the connection.
+ */
+ public void close();
+
+ /**
+ * Test if the connection is open.
+ *
+ * @return true if connection is open.
+ */
+ public boolean isOpen();
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionPropertyService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionPropertyService.java
new file mode 100644
index 00000000000..062178fa712
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionPropertyService.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core;
+
+/**
+ * A connection property is some descriptive information that's discovered about the connection.
+ * This service provides property values for a connection.
+ *
+ * Examples include:
+ *
+ * os.name Operating system name
+ * os.arch Operating system architecture
+ * os.version Operating system version
+ * file.separator File separator ("/" on UNIX)
+ * path.separator Path separator (":" on UNIX)
+ * line.separator Line separator ("\n" on UNIX)
+ * user.home Home directory
+ *
+ *
+ * @since 2.0
+ */
+public interface IRemoteConnectionPropertyService extends IRemoteConnection.Service {
+
+ /**
+ * Gets the remote system property indicated by the specified key. The connection must be open prior to calling this method.
+ *
+ * @param key
+ * the name of the property
+ * @return the string value of the property, or null if no property has that key
+ */
+ public String getProperty(String key);
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionProviderService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionProviderService.java
new file mode 100644
index 00000000000..5fc0d66c8ff
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionProviderService.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core;
+
+/**
+ * A connection type service for connectiont types that have automatic means of adding
+ * and removing services. For example, the Local connection type needs to be able
+ * to ensure the Local connection is created, or adapters to other target management
+ * systems may prefer to let those systems manage the connections.
+ *
+ * @since 2.0
+ */
+public interface IRemoteConnectionProviderService extends IRemoteConnectionType.Service {
+
+ /**
+ * Initialize the service. Called after all existing connections are loaded.
+ * This method typically will add the initial connections or start up a job to do it.
+ * This method is called on startup, it's important that it be fast.
+ */
+ void init();
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionManager.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionType.java
similarity index 50%
rename from bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionManager.java
rename to bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionType.java
index 8eeb68a4b86..3e4117d0815 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionManager.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionType.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2013 IBM Corporation and others.
* 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
@@ -13,18 +13,91 @@ package org.eclipse.remote.core;
import java.net.URI;
import java.util.List;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.remote.core.exception.RemoteConnectionException;
+
/**
- * Interface for managing connections to remote systems.
+ * A remote connection type manages a list of connections that implement the same services.
+ * Services may be registered on the individual connections, or at the connection type level
+ * for service that apply to all connections of this type.
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 2.0
*/
-public interface IRemoteConnectionManager {
+public interface IRemoteConnectionType {
/**
- * The name of the connection for local services. There is only one connection for local services.
- *
- * @since 7.0
+ * The interface that is extend by services provided for this remote services implementation.
+ * @since 2.0
*/
- public static String LOCAL_CONNECTION_NAME = "Local"; //$NON-NLS-1$
+ interface Service {
+ IRemoteConnectionType getConnectionType();
+
+ interface Factory {
+ T getService(IRemoteConnectionType connectionType, Class service);
+ }
+ }
+
+ // Capabilities
+ static final int CAPABILITY_ADD_CONNECTIONS = 0x01;
+ static final int CAPABILITY_EDIT_CONNECTIONS = 0x02;
+ static final int CAPABILITY_REMOVE_CONNECTIONS = 0x04;
+ static final int CAPABILITY_SUPPORTS_TCP_PORT_FORWARDING = 0x08;
+ static final int CAPABILITY_SUPPORTS_X11_FORWARDING = 0x10;
+
+ /**
+ * Get the remote services manager. This is a convenient way to get back
+ * to the root.
+ *
+ * @return remote services manager
+ */
+ IRemoteServicesManager getRemoteServicesManager();
+
+ /**
+ * Get unique ID of this service. Can be used as a lookup key.
+ *
+ * @return unique ID
+ */
+ String getId();
+
+ /**
+ * Get display name of this service.
+ *
+ * @return display name
+ */
+ String getName();
+
+ /**
+ * Get the EFS scheme provided by this service.
+ *
+ * @return display name
+ */
+ String getScheme();
+
+ /**
+ * Gets the capabilities of the remote service.
+ *
+ * @return bit-wise or of capability flag constants
+ */
+ int getCapabilities();
+
+ /**
+ * Get the service for this remote services implementation that implements the given interface.
+ *
+ * @param service the interface the required service must implements
+ * @return the desired service or null if there is no such service available
+ * @throws CoreException
+ * @since 2.0
+ */
+ T getService(Class service);
+
+ /**
+ * Does this connection type support the given service.
+ *
+ * @param service the service to be tested
+ * @return true if this connection type supports this service
+ */
+ boolean hasService(Class service);
/**
* Gets the remote connection corresponding to the supplied name.
@@ -53,16 +126,6 @@ public interface IRemoteConnectionManager {
*/
public List getConnections();
- /**
- * Get the user authenticator that will be used when opening connections. The user authenticator is specified using the
- * org.eclipse.remote.core.authenticator extension point.
- *
- * @param connection
- * connection that will use this authenticator
- * @return user authenticator
- */
- public IUserAuthenticator getUserAuthenticator(IRemoteConnection connection);
-
/**
* Creates a new remote connection named with supplied name. The connection attributes will be the default for the
* implementation.
@@ -88,4 +151,5 @@ public interface IRemoteConnectionManager {
* if the connection could not be removed
*/
public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException;
+
}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionWorkingCopy.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionWorkingCopy.java
index 3f16adfc4b4..ad4e269c4db 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionWorkingCopy.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionWorkingCopy.java
@@ -10,9 +10,18 @@
*******************************************************************************/
package org.eclipse.remote.core;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+
+/**
+ * A working copy of a remote connection used to change the name and/or
+ * attributes of the connection. It is also used when creating a new
+ * connection
+ */
public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
+
/**
* Returns the original connection this working copy was created from.
+ * Returns null if this is a new connection.
*
* @return original connection
*/
@@ -30,27 +39,9 @@ public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
* connection does not need saving.
*
* @return saved connection
+ * @throws RemoteConnectionException
*/
- public IRemoteConnection save();
-
- /**
- * Set the address for this connection
- *
- * @param address
- */
- public void setAddress(String address);
-
- /**
- * Set an implementation dependent attribute for the connection. Attributes keys supported by the connection can be obtained
- * using {@link #getAttributes()}. Attributes are persisted along with connection information.
- *
- * @param key
- * attribute key
- * @param value
- * attribute value
- * @since 5.0
- */
- public void setAttribute(String key, String value);
+ public IRemoteConnection save() throws RemoteConnectionException;
/**
* Set the name for this connection
@@ -60,26 +51,23 @@ public interface IRemoteConnectionWorkingCopy extends IRemoteConnection {
public void setName(String name);
/**
- * Set the password for this connection
+ * Set an implementation dependent attribute for the connection. Attributes keys supported by the connection can be obtained
+ * using {@link #getAttributes()}. Attributes are persisted along with connection information.
*
- * @param password
- * @since 5.0
+ * @param key
+ * attribute key
+ * @param value
+ * attribute value
*/
- public void setPassword(String password);
+ public void setAttribute(String key, String value);
/**
- * Set the port used for this connection. Only valid if supported by the underlying service provider.
+ * Set an attribute such as a password that's stored in secure storage.
*
- * @param port
- * port number for the connection
- * @since 5.0
+ * @param key
+ * @param value
+ * @since 2.0
*/
- public void setPort(int port);
+ public void setSecureAttribute(String key, String value);
- /**
- * Set the username for this connection
- *
- * @param username
- */
- public void setUsername(String username);
}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteFileManager.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteFileService.java
similarity index 79%
rename from bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteFileManager.java
rename to bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteFileService.java
index 370f9cd1934..33ad6512794 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteFileManager.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteFileService.java
@@ -16,9 +16,12 @@ import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.IPath;
/**
- * Interface for managing resources on a remote system.
+ * Interface for managing files on a remote system.
+ *
+ * @since 2.0
*/
-public interface IRemoteFileManager {
+public interface IRemoteFileService extends IRemoteConnection.Service {
+
/**
* Get the resource associated with path. IFileStore can then be used to
* perform operations on the file.
@@ -31,15 +34,28 @@ public interface IRemoteFileManager {
* path to resource
* @return the file store representing the remote path
*/
- public IFileStore getResource(String path);
+ IFileStore getResource(String path);
+
+ /**
+ * Get the base directory to be used for relative paths.
+ *
+ * @return base directory
+ */
+ String getBaseDirectory();
+
+ /**
+ * Set the base directory to be used for relative paths..
+ *
+ * @param path new base directory
+ */
+ void setBaseDirectory(String path);
/**
* Gets the directory separator on the target system.
*
* @return String
- * @since 4.0
*/
- public String getDirectorySeparator();
+ String getDirectorySeparator();
/**
* Convert URI to a remote path. This path is suitable for direct file
@@ -49,7 +65,7 @@ public interface IRemoteFileManager {
*
* @return IPath representing the remote path
*/
- public String toPath(URI uri);
+ String toPath(URI uri);
/**
* Convert remote path to equivalent URI. This URI is suitable for EFS
@@ -62,7 +78,7 @@ public interface IRemoteFileManager {
* @return URI representing path on remote system, or null if the path is
* invalid
*/
- public URI toURI(IPath path);
+ URI toURI(IPath path);
/**
* Convert string representation of a remote path to equivalent URI. This
@@ -75,5 +91,6 @@ public interface IRemoteFileManager {
* @return URI representing path on remote system, or null if the path is
* invalid
*/
- public URI toURI(String path);
+ URI toURI(String path);
+
}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemotePortForwardingService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemotePortForwardingService.java
new file mode 100644
index 00000000000..fb436b230b9
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemotePortForwardingService.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+
+/**
+ * A connection service for setting up port forwarding between the host and the remote.
+ * This is a feature provided by SSH.
+ *
+ * @since 2.0
+ */
+public interface IRemotePortForwardingService extends IRemoteConnection.Service {
+
+ /**
+ * Forward local port localPort to remote port fwdPort on remote machine fwdAddress. If this IRemoteConnection is not to
+ * fwdAddress, the port will be routed via the connection machine to fwdAddress.
+ *
+ * @param localPort
+ * local port to forward
+ * @param fwdAddress
+ * address of remote machine
+ * @param fwdPort
+ * remote port on remote machine
+ * @throws RemoteConnectionException
+ */
+ public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
+
+ /**
+ * Forward a local port to remote port fwdPort on remote machine fwdAddress. The local port is chosen dynamically and returned
+ * by the method. If this IRemoteConnection is not to fwdAddress, the port will be routed via the connection machine to
+ * fwdAddress.
+ *
+ * @param fwdAddress
+ * @param fwdPort
+ * @param monitor
+ * @return local port number
+ * @throws RemoteConnectionException
+ */
+ public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
+
+ /**
+ * Forward remote port remotePort to port fwdPort on machine fwdAddress. When a connection is made to remotePort on the remote
+ * machine, it is forwarded via this IRemoteConnection to fwdPort on machine fwdAddress.
+ *
+ * @param remotePort
+ * remote port to forward
+ * @param fwdAddress
+ * address of recipient machine
+ * @param fwdPort
+ * port on recipient machine
+ * @throws RemoteConnectionException
+ */
+ public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException;
+
+ /**
+ * Forward a remote port to port fwdPort on remote machine fwdAddress. The remote port is chosen dynamically and returned by the
+ * method. When a connection is made to this port on the remote machine, it is forwarded via this IRemoteConnection to fwdPort
+ * on machine fwdAddress.
+ *
+ * If fwdAddress is the empty string ("") then the fwdPort will be bound to any address on all interfaces. Note that this
+ * requires enabling the GatewayPort sshd option on some systems.
+ *
+ * @param fwdAddress
+ * @param fwdPort
+ * @param monitor
+ * @return remote port number
+ * @throws RemoteConnectionException
+ */
+ public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException;
+
+ /**
+ * Remove the local port forwarding associated with the given port.
+ *
+ * @param port
+ * forwarded port
+ * @throws RemoteConnectionException
+ * @since 7.0
+ */
+ public void removeLocalPortForwarding(int port) throws RemoteConnectionException;
+
+ /**
+ * Remove the remote port forwarding associated with the given port.
+ *
+ * @param port
+ * forwarded port
+ * @throws RemoteConnectionException
+ * @since 7.0
+ */
+ public void removeRemotePortForwarding(int port) throws RemoteConnectionException;
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteProcessService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteProcessService.java
new file mode 100644
index 00000000000..9647c948a2e
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteProcessService.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A connection service for starting up processes on a remote.
+ *
+ * @since 2.0
+ */
+public interface IRemoteProcessService extends IRemoteConnection.Service {
+
+ /**
+ * Returns an unmodifiable string map view of the remote environment. The connection must be open prior to calling this method.
+ *
+ * @return the remote environment
+ */
+ public Map getEnv();
+
+ /**
+ * Returns the value of an environment variable. The connection must be open prior to calling this method.
+ *
+ * @param name
+ * name of the environment variable
+ * @return value of the environment variable or null if the variable is not defined
+ */
+ public String getEnv(String name);
+
+ /**
+ * Get a process builder for creating remote processes
+ *
+ * @return process builder or null if connection is not open
+ */
+ public IRemoteProcessBuilder getProcessBuilder(List command);
+
+ /**
+ * Get a process builder for creating remote processes
+ *
+ * @return process builder or null if connection is not open
+ */
+ public IRemoteProcessBuilder getProcessBuilder(String... command);
+
+ /**
+ * Get the working directory. Relative paths will be resolved using this path.
+ *
+ * The remote connection does not need to be open to use this method, however a default directory path, rather than the actual
+ * working directory, may be returned in this case.
+ *
+ * @return String representing the current working directory
+ */
+ public String getWorkingDirectory();
+
+ /**
+ * Set the working directory while the connection is open. The working directory will revert to the default when the connection
+ * is closed then subsequently reopened.
+ *
+ * Relative paths will be resolved using this path. The path must be valid and absolute for any changes to be made.
+ *
+ * @param path
+ * String representing the current working directory
+ * @since 4.0
+ */
+ public void setWorkingDirectory(String path);
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServices.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServices.java
deleted file mode 100644
index 7a2343bd9c2..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServices.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.core;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Abstraction of a remote services provider. Clients obtain this interface using one of the static methods in
- * {@link RemoteServices}. The methods on this interface can then be used to access the full range of remote services provided.
- */
-public interface IRemoteServices extends IRemoteServicesDescriptor {
- public static final int CAPABILITY_ADD_CONNECTIONS = 0x01;
- public static final int CAPABILITY_EDIT_CONNECTIONS = 0x02;
- public static final int CAPABILITY_REMOVE_CONNECTIONS = 0x04;
- public static final int CAPABILITY_SUPPORTS_TCP_PORT_FORWARDING = 0x08;
- public static final int CAPABILITY_SUPPORTS_X11_FORWARDING = 0x10;
- public static final int CAPABILITY_SUPPORTS_COMMAND_SHELL = 0x20;
-
- /**
- * Get a connection manager for managing remote connections.
- *
- * @return connection manager or null if services are not initialized
- */
- public IRemoteConnectionManager getConnectionManager();
-
- /**
- * Initialize the remote service. Clients should not call this method (it is called internally.)
- *
- * @return true if the initialization was successful, false otherwise
- * @since 7.0
- */
- public boolean initialize(IProgressMonitor monitor);
-
- /**
- * Gets the capabilities of the remote service.
- *
- * @return bit-wise or of capability flag constants
- */
- public int getCapabilities();
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesDescriptor.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesDescriptor.java
deleted file mode 100644
index 970fed1bbcc..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesDescriptor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.core;
-
-/**
- * Interface representing a remote services provider extension. Clients can use this to find out information about the extension
- * without loading it.
- */
-public interface IRemoteServicesDescriptor extends Comparable {
- /**
- * Get unique ID of this service. Can be used as a lookup key.
- *
- * @return unique ID
- */
- public String getId();
-
- /**
- * Get display name of this service.
- *
- * @return display name
- */
- public String getName();
-
- /**
- * Get the EFS scheme provided by this service.
- *
- * @return display name
- */
- public String getScheme();
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesFactory.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesFactory.java
deleted file mode 100644
index 7376e7cd765..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.core;
-
-/**
- * Factory for creating instances of a remote service provider. Implementors must provide a class implementing this interface when
- * supplying a new remote services provider extension.
- */
-public interface IRemoteServicesFactory {
- /**
- * Return the remote services implementation for the given descriptor
- *
- * @param descriptor
- * descriptor for the remote services
- * @return the remote services implementation, or null if initialization failed
- */
- public IRemoteServices getServices(IRemoteServicesDescriptor descriptor);
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesManager.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesManager.java
new file mode 100644
index 00000000000..a80986fa8dc
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteServicesManager.java
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core;
+
+import java.net.URI;
+import java.util.List;
+
+/**
+ * The main entry point into the remote services system. The remote services manager
+ * is an OSGi service. It provides a list of connection types and the global
+ * list of all connections.
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 2.0
+ */
+public interface IRemoteServicesManager {
+
+ /**
+ * Get the connection type identified by the id
+ *
+ * @param id id of the connection type
+ * @return connection type or null if the service can not be found
+ */
+ IRemoteConnectionType getConnectionType(String id);
+
+ /**
+ * Get the connection type that provides connections to locations identified by
+ * the URI.
+ *
+ * @param uri uri of locations to be accessed
+ * @return the connection type that can be used to access the locations
+ * or null if no connection type is available for the uri.
+ */
+ IRemoteConnectionType getConnectionType(URI uri);
+
+ /**
+ * Return the connection type used to access local resources.
+ *
+ * @return the local services
+ */
+ IRemoteConnectionType getLocalConnectionType();
+
+ /**
+ * Returns the list of all connection type including the local services.
+ *
+ * @return all remote services
+ */
+ List getAllConnectionTypes();
+
+ /**
+ * Returns the list of connection types except for the local services.
+ *
+ * @return all remote services that are really remote
+ */
+ List getRemoteConnectionTypes();
+
+ /**
+ * Returns the list of all known remote connections.
+ *
+ * @return all remote connections
+ */
+ List getAllRemoteConnections();
+
+ /**
+ * Add a global connection change listener that receives events for all connections.
+ *
+ * @param listener global connection change listener to be added
+ */
+ void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener);
+
+ /**
+ * Remove the global connection change listener.
+ *
+ * @param listener global connection change listener to be removed
+ */
+ void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener);
+
+ /**
+ * Used by connections and other components to notify the global connection
+ * change listeners of events.
+ *
+ * @param event connection change event
+ */
+ void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event);
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IUserAuthenticator.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IUserAuthenticatorService.java
similarity index 97%
rename from bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IUserAuthenticator.java
rename to bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IUserAuthenticatorService.java
index 94e393e547d..75cf3935439 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IUserAuthenticator.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IUserAuthenticatorService.java
@@ -18,9 +18,9 @@ import java.net.PasswordAuthentication;
/**
* Allow clients to provide their own user interface for connection authentication.
*
- * @since 7.0
+ * @since 2.0
*/
-public interface IUserAuthenticator {
+public interface IUserAuthenticatorService extends IRemoteConnection.Service {
/**
* ID for an "Ok" response (value 0).
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionChangeEvent.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionChangeEvent.java
similarity index 71%
rename from bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionChangeEvent.java
rename to bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionChangeEvent.java
index b0d164bccea..333e152c083 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/IRemoteConnectionChangeEvent.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteConnectionChangeEvent.java
@@ -13,8 +13,11 @@ package org.eclipse.remote.core;
/**
* Event representing a change in connection status. The {@link #getType()} method can be used to obtain information about the type
* of event that occurred.
+ *
+ * @since 2.0
*/
-public interface IRemoteConnectionChangeEvent {
+public class RemoteConnectionChangeEvent {
+
/**
* Event indicating that the connection was closed.
*/
@@ -35,12 +38,34 @@ public interface IRemoteConnectionChangeEvent {
*/
public static final int CONNECTION_RENAMED = 1 << 3;
+ /**
+ * Event indicating the connection was added.
+ * @since 2.0
+ */
+ public static final int CONNECTION_ADDED = 1 << 4;
+
+ /**
+ * Event indicating the connection is about to be removed.
+ * @since 2.0
+ */
+ public static final int CONNECTION_REMOVED = 1 << 5;
+
+ private final IRemoteConnection connection;
+ private final int type;
+
+ public RemoteConnectionChangeEvent(IRemoteConnection connection, int type) {
+ this.connection = connection;
+ this.type = type;
+ }
+
/**
* Get the connection that has changed.
*
* @return IRemoteConnection
*/
- public IRemoteConnection getConnection();
+ public IRemoteConnection getConnection() {
+ return connection;
+ }
/**
* Returns the type of event being reported. This type
@@ -50,5 +75,8 @@ public interface IRemoteConnectionChangeEvent {
*
* @return a bitwise OR of event type constants
*/
- public int getType();
+ public int getType() {
+ return type;
+ }
+
}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteServices.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteServices.java
deleted file mode 100644
index 609ced0dd6f..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteServices.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.core;
-
-import java.net.URI;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
-import org.eclipse.remote.internal.core.RemoteServicesImpl;
-import org.eclipse.remote.internal.core.services.local.LocalServices;
-
-/**
- * Main entry point for accessing remote services.
- *
- * @since 7.0
- */
-public class RemoteServices {
- /**
- * Retrieve the local services provider. Guaranteed to exist and be initialized.
- *
- * @return local services provider
- */
- public static IRemoteServices getLocalServices() {
- return getRemoteServices(LocalServices.LocalServicesId);
- }
-
- /**
- * Get the remote service implementation identified by id and ensure that it is initialized.
- *
- * @param id
- * id of the remote service
- * @return remote service or null if the service cannot be found or failed to initialized
- */
- public static IRemoteServices getRemoteServices(String id) {
- return getRemoteServices(id, null);
- }
-
- /**
- * Get the remote service implementation identified by id and ensure that it is initialized. This method will present the user
- * with a dialog box that can be canceled.
- *
- * @param id
- * id of remote service to retrieve
- * @param monitor
- * progress monitor to allow user to cancel operation
- * @return remote service, or null if the service cannot be found or failed to initialized
- * @since 5.0
- */
- public static IRemoteServices getRemoteServices(String id, IProgressMonitor monitor) {
- RemoteServicesDescriptor proxy = RemoteServicesImpl.getRemoteServiceDescriptorById(id);
- if (proxy != null) {
- IRemoteServices service = proxy.getServices();
- if (service.initialize(monitor)) {
- return service;
- }
- }
- return null;
- }
-
- /**
- * Get the remote services identified by a URI.
- *
- * @param uri
- * URI of remote services to retrieve
- * @return remote service, or null if the service cannot be found or failed to initialized
- */
- public static IRemoteServices getRemoteServices(URI uri) {
- return getRemoteServices(uri, null);
- }
-
- /**
- * Get the remote services implementation identified by URI. This method will present the user
- * with a dialog box that can be canceled.
- *
- * @param uri
- * URI of remote services to retrieve
- * @param monitor
- * progress monitor to allow user to cancel operation
- * @return remote service, or null if the service cannot be found or failed to initialized
- * @since 5.0
- */
- public static IRemoteServices getRemoteServices(URI uri, IProgressMonitor monitor) {
- RemoteServicesDescriptor proxy = RemoteServicesImpl.getRemoteServiceDescriptorByURI(uri);
- if (proxy != null) {
- IRemoteServices service = proxy.getServices();
- if (service.initialize(monitor)) {
- return service;
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteServicesUtils.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteServicesUtils.java
index fd92c6ac083..9cd758f579d 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteServicesUtils.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/RemoteServicesUtils.java
@@ -13,76 +13,14 @@ package org.eclipse.remote.core;
import java.net.URI;
import java.net.URISyntaxException;
-import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
-import org.eclipse.remote.internal.core.RemoteServicesImpl;
+import org.eclipse.remote.internal.core.RemoteCorePlugin;
import org.eclipse.remote.internal.core.preferences.Preferences;
/**
* Remote services utility methods.
- *
- * @since 7.0
*/
public class RemoteServicesUtils {
- /**
- * Utility method to get a remote connection given a remote services ID and a connection name.
- *
- * @param remoteServicesId
- * ID of remote services providing the connection
- * @param connectionName
- * name of the connection to find
- * @param monitor
- * progress monitor
- * @return remote connection or null if the ID or connection name are invalid
- */
- public static IRemoteConnection getConnectionWithProgress(String remoteServicesId, String connectionName,
- IProgressMonitor monitor) {
- SubMonitor progress = SubMonitor.convert(monitor, 10);
- IRemoteServices remoteServices = RemoteServices.getRemoteServices(remoteServicesId, progress.newChild(1));
- if (remoteServices != null) {
- IRemoteConnectionManager remoteConnectionManager = remoteServices.getConnectionManager();
- if (remoteConnectionManager != null) {
- return remoteConnectionManager.getConnection(connectionName);
- }
- }
- return null;
- }
-
- /**
- * Utility method to get a file store corresponding to the given path.
- *
- * @param remoteServicesId
- * ID of remote services providing the connection
- * @param connectionName
- * name of the remote connection to use
- * @param path
- * path of file on remote system
- * @param monitor
- * progress monitor
- * @return file store corresponding to the remote file or null if the ID or connection name are invalid
- */
- public static IFileStore getRemoteFileWithProgress(String remoteServicesId, String connectionName, String path,
- IProgressMonitor monitor) {
- SubMonitor progress = SubMonitor.convert(monitor, 10);
- IRemoteServices remoteServices = RemoteServices.getRemoteServices(remoteServicesId, progress.newChild(10));
- if (remoteServices != null) {
- IRemoteConnectionManager remoteConnectionManager = remoteServices.getConnectionManager();
- if (remoteConnectionManager != null) {
- IRemoteConnection remoteConnection = remoteConnectionManager.getConnection(connectionName);
- if (remoteConnection != null) {
- IRemoteFileManager remoteFileManager = remoteConnection.getFileManager();
- if (remoteFileManager != null) {
- return remoteFileManager.getResource(path);
- }
- }
- }
- }
- return null;
- }
-
/**
* Convert a UNC path to a URI
*
@@ -97,19 +35,20 @@ public class RemoteServicesUtils {
*/
public static URI toURI(IPath path) {
if (path.isUNC()) {
+ IRemoteServicesManager manager = RemoteCorePlugin.getService(IRemoteServicesManager.class);
/*
* Split the server component if possible.
*/
String[] parts = path.segment(0).split(":"); //$NON-NLS-1$
- IRemoteServices services = null;
+ IRemoteConnectionType services = null;
String connName = null;
if (parts.length == 2) {
- services = RemoteServices.getRemoteServices(parts[0]);
+ services = manager.getConnectionType(parts[0]);
connName = parts[1];
} else if (parts.length == 1) {
String id = Preferences.getString(IRemotePreferenceConstants.PREF_REMOTE_SERVICES_ID);
if (id != null) {
- services = RemoteServices.getRemoteServices(id);
+ services = manager.getConnectionType(id);
}
connName = parts[0];
}
@@ -120,17 +59,13 @@ public class RemoteServicesUtils {
*/
IRemoteConnection conn = null;
if (services != null) {
- conn = services.getConnectionManager().getConnection(connName);
+ conn = services.getConnection(connName);
} else if (connName != null) {
- for (RemoteServicesDescriptor proxy : RemoteServicesImpl.getRemoteServiceDescriptors()) {
- services = proxy.getServices();
- if (services != null) {
- IRemoteConnectionManager connMgr = services.getConnectionManager();
- if (connMgr != null) {
- conn = connMgr.getConnection(connName);
- if (conn != null) {
- break;
- }
+ for (IRemoteConnectionType s : manager.getAllConnectionTypes()) {
+ if (s != null) {
+ conn = s.getConnection(connName);
+ if (conn != null) {
+ break;
}
}
}
@@ -140,7 +75,7 @@ public class RemoteServicesUtils {
* If a connection was found then convert it to a URI.
*/
if (conn != null) {
- String scheme = conn.getRemoteServices().getScheme();
+ String scheme = conn.getConnectionType().getScheme();
String filePath = path.removeFirstSegments(1).makeAbsolute().toString();
try {
return new URI(scheme, connName, filePath, null, null);
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/exception/ConnectionExistsException.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/exception/ConnectionExistsException.java
new file mode 100644
index 00000000000..6bf3fb1255c
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/exception/ConnectionExistsException.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core.exception;
+
+/**
+ * Thrown when trying to add a connection with the same name as an existing
+ * connection, or when trying to rename a connection to the same name as an
+ * existing connection.
+ *
+ * @since 2.0
+ */
+public class ConnectionExistsException extends RemoteConnectionException {
+
+ private static final long serialVersionUID = -1591235868439783613L;
+
+ public ConnectionExistsException(String message) {
+ super(message);
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/launch/IRemoteLaunchConfigService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/launch/IRemoteLaunchConfigService.java
new file mode 100644
index 00000000000..db4592a3223
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/core/launch/IRemoteLaunchConfigService.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.core.launch;
+
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.remote.core.IRemoteConnection;
+
+/**
+ * Manages and persists the mapping between launch configurations and
+ * remote connections that they run on. Each launch configuration has an
+ * active remote connection.
+ *
+ * @since 2.0
+ */
+public interface IRemoteLaunchConfigService {
+
+ /**
+ * Sets the active remote connection for the given launch configuration.
+ *
+ * @param launchConfig launch configuration
+ * @param connection active remote connection
+ */
+ void setActiveConnection(ILaunchConfiguration launchConfig, IRemoteConnection connection);
+
+ /**
+ * Gets the active remote connection for the given launch configuration
+ * @param launchConfig launch configuration
+ * @return active remote connection
+ */
+ IRemoteConnection getActiveConnection(ILaunchConfiguration launchConfig);
+
+ /**
+ * For a given launch configuration type, get the remote connection that was last
+ * used by a launch configuration of that type.
+ *
+ * This is used for new launch configurations with the assumption that the user
+ * will want to use the same remote connection.
+ *
+ * @param launchConfigType launch configuration type
+ * @return last active remote configuration
+ */
+ IRemoteConnection getLastActiveConnection(ILaunchConfigurationType launchConfigType);
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnection.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnection.java
new file mode 100644
index 00000000000..3a417a16a4c
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnection.java
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.internal.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.StorageException;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionChangeListener;
+import org.eclipse.remote.core.IRemoteConnectionControlService;
+import org.eclipse.remote.core.IRemoteConnectionPropertyService;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
+import org.eclipse.remote.core.RemoteConnectionChangeEvent;
+import org.eclipse.remote.core.exception.ConnectionExistsException;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * The standard root class for remote connections. Implements common hook up
+ * with the remote services and the remote services manager as well as handling
+ * for services.
+ */
+public class RemoteConnection implements IRemoteConnection {
+
+ private final RemoteConnectionType connectionType;
+ private String name;
+
+ private Map servicesMap = new HashMap<>();
+
+ private final List fListeners = new ArrayList<>();
+
+ final static String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ public RemoteConnection(RemoteConnectionType connectionType, String name) {
+ this.connectionType = connectionType;
+ this.name = name;
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType() {
+ return connectionType;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(Class service) {
+ String serviceName = service.getName();
+ Object obj = servicesMap.get(serviceName);
+ if (obj == null) {
+ obj = connectionType.getConnectionService(this, service);
+ if (obj != null) {
+ servicesMap.put(serviceName, obj);
+ }
+ }
+
+ return (T) obj;
+ }
+
+ @Override
+ public boolean hasService(Class service) {
+ return servicesMap.get(service.getName()) != null || connectionType.hasConnectionService(this, service);
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Called from working copy when name has changed.
+ *
+ * @param name the new name
+ */
+ void rename(String newName) throws ConnectionExistsException {
+ try {
+ // Copy the old preferences over and remove the old node
+ if (connectionType.getPreferenceNode().nodeExists(newName)) {
+ throw new ConnectionExistsException(newName);
+ }
+
+ Preferences newPrefs = connectionType.getPreferenceNode().node(newName);
+ Preferences oldPrefs = getPreferences();
+ for (String key : oldPrefs.keys()) {
+ newPrefs.put(key, oldPrefs.get(key, null));
+ }
+
+ oldPrefs.removeNode();
+ } catch (BackingStoreException e) {
+ RemoteCorePlugin.log(e);
+ }
+
+ this.name = newName;
+ }
+
+ Preferences getPreferences() {
+ return connectionType.getPreferenceNode().node(name);
+ }
+
+ ISecurePreferences getSecurePreferences() {
+ return connectionType.getSecurePreferencesNode().node(name);
+ }
+
+ @Override
+ public String getAttribute(String key) {
+ return getPreferences().get(key, EMPTY_STRING);
+ }
+
+ @Override
+ public String getSecureAttribute(String key) {
+ try {
+ return getSecurePreferences().get(key, EMPTY_STRING);
+ } catch (StorageException e) {
+ RemoteCorePlugin.log(e);
+ return EMPTY_STRING;
+ }
+ }
+
+ @Override
+ public IRemoteConnectionWorkingCopy getWorkingCopy() {
+ return new RemoteConnectionWorkingCopy(this);
+ }
+
+ @Override
+ public String getProperty(String key) {
+ IRemoteConnectionPropertyService propertyService = getService(IRemoteConnectionPropertyService.class);
+ if (propertyService != null) {
+ return propertyService.getProperty(key);
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void open(IProgressMonitor monitor) throws RemoteConnectionException {
+ IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
+ if (controlService != null) {
+ controlService.open(monitor);
+ }
+ }
+
+ @Override
+ public void close() {
+ IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
+ if (controlService != null) {
+ controlService.close();
+ }
+ }
+
+ @Override
+ public boolean isOpen() {
+ IRemoteConnectionControlService controlService = getService(IRemoteConnectionControlService.class);
+ if (controlService != null) {
+ return controlService.isOpen();
+ } else {
+ // default is always open
+ return true;
+ }
+ }
+
+ @Override
+ public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
+ fListeners.add(listener);
+ }
+
+ @Override
+ public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
+ fListeners.remove(listener);
+ }
+
+ @Override
+ public void fireConnectionChangeEvent(final int type) {
+ RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(this, type);
+ for (IRemoteConnectionChangeListener listener : fListeners) {
+ listener.connectionChanged(event);
+ }
+ // fire to the global listeners too
+ connectionType.getRemoteServicesManager().fireRemoteConnectionChangeEvent(event);
+ }
+
+ @Override
+ public String toString() {
+ return name + " - " + connectionType.getName(); //$NON-NLS-1$
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionType.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionType.java
new file mode 100644
index 00000000000..cfe95677390
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionType.java
@@ -0,0 +1,241 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.internal.core;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
+import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.remote.core.RemoteConnectionChangeEvent;
+import org.eclipse.remote.core.exception.ConnectionExistsException;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * The implementation for a given remote services collection.n
+ */
+public class RemoteConnectionType implements IRemoteConnectionType {
+
+ private final RemoteServicesManager remoteServicesManager;
+ private final String id;
+ private final String name;
+ private final String scheme;
+ private final int capabilities;
+
+ private final Map serviceMap = new HashMap<>();
+ private final Map serviceDefinitionMap = new HashMap<>();
+
+ private final Map connections = new HashMap<>();
+
+ public RemoteConnectionType(IConfigurationElement ce, RemoteServicesManager manager) {
+ this.remoteServicesManager = manager;
+ id = ce.getAttribute("id"); //$NON-NLS-1$
+ name = ce.getAttribute("name"); //$NON-NLS-1$
+ scheme = ce.getAttribute("scheme"); //$NON-NLS-1$
+
+ String caps = ce.getAttribute("capabilities"); //$NON-NLS-1$
+ if (caps != null) {
+ capabilities = Integer.parseInt(caps);
+ } else {
+ capabilities = 0;
+ }
+
+ // load up existing connections
+ try {
+ for (String connectionName : getPreferenceNode().childrenNames()) {
+ connections.put(connectionName, new RemoteConnection(this, connectionName));
+ }
+ } catch (BackingStoreException e) {
+ RemoteCorePlugin.log(e);
+ }
+ }
+
+ Preferences getPreferenceNode() {
+ return remoteServicesManager.getPreferenceNode().node(id);
+ }
+
+ ISecurePreferences getSecurePreferencesNode() {
+ return remoteServicesManager.getSecurePreferenceNode().node(id);
+ }
+
+ @Override
+ public IRemoteServicesManager getRemoteServicesManager() {
+ return remoteServicesManager;
+ }
+
+ @Override
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getScheme() {
+ return scheme;
+ }
+
+ @Override
+ public int getCapabilities() {
+ return capabilities;
+ }
+
+ @Override
+ public T getService(Class service) {
+ String serviceName = service.getName();
+ @SuppressWarnings("unchecked")
+ T obj = (T) serviceMap.get(serviceName);
+ if (obj == null) {
+ IConfigurationElement ce = serviceDefinitionMap.get(serviceName);
+ if (ce != null) {
+ try {
+ Service.Factory factory = (Service.Factory) ce.createExecutableExtension("factory"); //$NON-NLS-1$
+ if (factory != null) {
+ obj = factory.getService(this, service);
+ serviceMap.put(serviceName, obj);
+ serviceDefinitionMap.remove(serviceName);
+ }
+ } catch (CoreException e) {
+ RemoteCorePlugin.log(e.getStatus());
+ }
+ }
+ }
+ return obj;
+ }
+
+ @Override
+ public boolean hasService(Class service) {
+ String serviceName = service.getName();
+ return serviceMap.get(serviceName) != null || serviceDefinitionMap.get(service) != null;
+ }
+
+ /**
+ * Called from the connection to get a service object for that connection.
+ *
+ * @param connection the connection to which the service applies
+ * @param service the interface the service must implement
+ * @return the service object
+ * @throws CoreException
+ */
+ public T getConnectionService(IRemoteConnection connection, Class service) {
+ // Both top level and connection services are stored in the serviceDefinitionMap.
+ // In theory the two sets of interfaces can't collide.
+ IConfigurationElement ce = serviceDefinitionMap.get(service.getName());
+ if (ce != null) {
+ try {
+ IRemoteConnection.Service.Factory factory = (IRemoteConnection.Service.Factory) ce.createExecutableExtension("factory"); //$NON-NLS-1$
+ if (factory != null) {
+ return factory.getService(connection, service);
+ }
+ } catch (CoreException e) {
+ RemoteCorePlugin.log(e.getStatus());
+ }
+ }
+
+ return null;
+ }
+
+ public boolean hasConnectionService(IRemoteConnection connection, Class service) {
+ return serviceDefinitionMap.get(service.getName()) != null;
+ }
+
+ /**
+ * Called from the remote service manager to register a service extension for
+ * this remote services implementation
+ *
+ * @param ce the extension element defining the service
+ */
+ public void addService(IConfigurationElement ce) {
+ String service = ce.getAttribute("service"); //$NON-NLS-1$
+ serviceDefinitionMap.put(service, ce);
+ }
+
+ /**
+ * Signal connection has been added.
+ * @since 2.0
+ */
+ protected void connectionAdded(final IRemoteConnection connection) {
+ RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection, RemoteConnectionChangeEvent.CONNECTION_ADDED);
+ remoteServicesManager.fireRemoteConnectionChangeEvent(event);
+ }
+
+ /**
+ * Signal a connnection is about to be removed.
+ * @since 2.0
+ */
+ protected void connectionRemoved(final IRemoteConnection connection) {
+ RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(connection, RemoteConnectionChangeEvent.CONNECTION_ADDED);
+ remoteServicesManager.fireRemoteConnectionChangeEvent(event);
+ }
+
+ @Override
+ public IRemoteConnection getConnection(String name) {
+ return connections.get(name);
+ }
+
+ @Override
+ public IRemoteConnection getConnection(URI uri) {
+ return connections.get(uri.getAuthority());
+ }
+
+ @Override
+ public List getConnections() {
+ return new ArrayList(connections.values());
+ }
+
+ @Override
+ public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
+ if (connections.containsKey(name)) {
+ throw new ConnectionExistsException(name);
+ }
+ return new RemoteConnectionWorkingCopy(this, name);
+ }
+
+ void addConnection(RemoteConnection remoteConnection) {
+ connections.put(remoteConnection.getName(), remoteConnection);
+ }
+
+ void removeConnection(String name) {
+ connections.remove(name);
+ }
+
+ @Override
+ public void removeConnection(IRemoteConnection connection) throws RemoteConnectionException {
+ if (connection instanceof RemoteConnection) {
+ connection.close();
+ RemoteConnection conn = (RemoteConnection) connection;
+ try {
+ conn.getPreferences().removeNode();
+ } catch (BackingStoreException e) {
+ throw new RemoteConnectionException(e);
+ }
+ conn.getSecurePreferences().removeNode();
+ connections.remove(conn.getName());
+ connection.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_REMOVED);
+ } else {
+ RemoteCorePlugin.log("Wrong class for " + connection.getName() + ", was " + connection.getClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionWorkingCopy.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionWorkingCopy.java
new file mode 100644
index 00000000000..31e7d20b422
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteConnectionWorkingCopy.java
@@ -0,0 +1,303 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.internal.core;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.StorageException;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionChangeListener;
+import org.eclipse.remote.core.IRemoteConnectionControlService;
+import org.eclipse.remote.core.IRemoteConnectionPropertyService;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
+import org.eclipse.remote.core.RemoteConnectionChangeEvent;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+public class RemoteConnectionWorkingCopy implements IRemoteConnectionWorkingCopy {
+
+ private RemoteConnection original;
+ private RemoteConnectionType connectionType;
+ private String newName;
+ private Map newAttributes = new HashMap<>();
+ private Map newSecureAttributes = new HashMap<>();
+ private List newListeners = new ArrayList<>();
+
+ /**
+ * New Connection.
+ */
+ public RemoteConnectionWorkingCopy(RemoteConnectionType connectionType, String name) {
+ this.connectionType = connectionType;
+ this.newName = name;
+ }
+
+ /**
+ * Edit Connection
+ */
+ public RemoteConnectionWorkingCopy(RemoteConnection original) {
+ this.original = original;
+ }
+
+ @Override
+ public String getName() {
+ if (newName != null) {
+ return newName;
+ } else if (original != null) {
+ return original.getName();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setName(String name) {
+ // set if only if it's changed
+ if (original == null || !name.equals(original.getName())) {
+ newName = name;
+ }
+ }
+
+ @Override
+ public String getAttribute(String key) {
+ String value = newAttributes.get(key);
+ if (value != null) {
+ return value;
+ }
+
+ if (original != null) {
+ return original.getAttribute(key);
+ }
+
+ return RemoteConnection.EMPTY_STRING;
+ }
+
+ @Override
+ public void setAttribute(String key, String value) {
+ // set only if it's changed or value is null
+ if (original == null || value == null || !value.equals(original.getAttribute(key))) {
+ newAttributes.put(key, value);
+ }
+ }
+
+ @Override
+ public String getSecureAttribute(String key) {
+ String value = newSecureAttributes.get(key);
+ if (value != null) {
+ return value;
+ }
+
+ if (original != null) {
+ return original.getSecureAttribute(key);
+ }
+
+ return RemoteConnection.EMPTY_STRING;
+ }
+
+ @Override
+ public void setSecureAttribute(String key, String value) {
+ // set only if it's changed or value is null
+ if (original == null || value == null || !value.equals(original.getSecureAttribute(key))) {
+ newSecureAttributes.put(key, value);
+ }
+ }
+
+ @Override
+ public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
+ if (original != null) {
+ original.addConnectionChangeListener(listener);
+ } else {
+ newListeners.add(listener);
+ }
+ }
+
+ @Override
+ public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
+ if (original != null) {
+ original.removeConnectionChangeListener(listener);
+ } else {
+ newListeners.remove(listener);
+ }
+ }
+
+ @Override
+ public void fireConnectionChangeEvent(int type) {
+ if (original != null) {
+ original.fireConnectionChangeEvent(type);
+ } else {
+ RemoteConnectionChangeEvent event = new RemoteConnectionChangeEvent(this, type);
+ for (IRemoteConnectionChangeListener listener : newListeners) {
+ listener.connectionChanged(event);
+ }
+ connectionType.getRemoteServicesManager().fireRemoteConnectionChangeEvent(event);
+ }
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType() {
+ return connectionType;
+ }
+
+ @Override
+ public IRemoteConnectionWorkingCopy getWorkingCopy() {
+ return this;
+ }
+
+ @Override
+ public T getService(Class service) {
+ if (original != null) {
+ return original.getService(service);
+ } else {
+ return connectionType.getConnectionService(this, service);
+ }
+ }
+
+ @Override
+ public boolean hasService(Class service) {
+ if (original != null) {
+ return original.hasService(service);
+ } else {
+ return connectionType.hasConnectionService(this, service);
+ }
+ }
+
+ @Override
+ public IRemoteConnection getOriginal() {
+ return original;
+ }
+
+ @Override
+ public boolean isDirty() {
+ return newName != null || !newAttributes.isEmpty() || !newSecureAttributes.isEmpty();
+ }
+
+ @Override
+ public IRemoteConnection save() throws RemoteConnectionException {
+ if (newName != null && original != null) {
+ // rename, delete the old one
+ original.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_RENAMED);
+ connectionType.removeConnection(original.getName());
+ original.rename(newName);
+ }
+
+ boolean added = false;
+ if (original == null) {
+ original = new RemoteConnection(connectionType, newName);
+ added = true;
+ }
+
+ Preferences prefs = original.getPreferences();
+ for (Map.Entry entry : newAttributes.entrySet()) {
+ String value = entry.getValue();
+ if (value != null && !value.isEmpty()) {
+ prefs.put(entry.getKey(), value);
+ } else {
+ prefs.remove(entry.getKey());
+ }
+ }
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e1) {
+ throw new RemoteConnectionException(e1);
+ }
+ newAttributes.clear();
+
+ ISecurePreferences securePrefs = original.getSecurePreferences();
+ for (Map.Entry entry : newSecureAttributes.entrySet()) {
+ String value = entry.getValue();
+ if (value != null && !value.isEmpty()) {
+ try {
+ securePrefs.put(entry.getKey(), value, true);
+ } catch (StorageException e) {
+ throw new RemoteConnectionException(e);
+ }
+ } else {
+ securePrefs.remove(entry.getKey());
+ }
+ }
+ try {
+ securePrefs.flush();
+ } catch (IOException e) {
+ throw new RemoteConnectionException(e);
+ }
+ newSecureAttributes.clear();
+
+ connectionType.addConnection(original);
+ if (added) {
+ original.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_ADDED);
+ }
+ return original;
+ }
+
+ @Override
+ public void open(IProgressMonitor monitor) throws RemoteConnectionException {
+ if (original != null) {
+ original.open(monitor);
+ } else {
+ IRemoteConnectionControlService controlService =
+ connectionType.getConnectionService(this, IRemoteConnectionControlService.class);
+ if (controlService != null) {
+ controlService.open(monitor);
+ }
+ }
+ }
+
+ @Override
+ public void close() {
+ if (original != null) {
+ original.close();
+ } else {
+ IRemoteConnectionControlService controlService =
+ connectionType.getConnectionService(this, IRemoteConnectionControlService.class);
+ if (controlService != null) {
+ controlService.close();
+ }
+ }
+ }
+
+ @Override
+ public boolean isOpen() {
+ if (original != null) {
+ return original.isOpen();
+ } else {
+ IRemoteConnectionControlService controlService =
+ connectionType.getConnectionService(this, IRemoteConnectionControlService.class);
+ if (controlService != null) {
+ return controlService.isOpen();
+ } else {
+ return true;
+ }
+ }
+ }
+
+ @Override
+ public String getProperty(String key) {
+ if (original != null) {
+ return original.getProperty(key);
+ } else {
+ IRemoteConnectionPropertyService propertyService =
+ connectionType.getConnectionService(this, IRemoteConnectionPropertyService.class);
+ if (propertyService != null) {
+ return propertyService.getProperty(key);
+ } else {
+ return null;
+ }
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteCorePlugin.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteCorePlugin.java
index e125fa7606a..bc564fabee1 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteCorePlugin.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteCorePlugin.java
@@ -17,8 +17,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
+import org.eclipse.remote.internal.core.launch.RemoteLaunchConfigService;
import org.eclipse.remote.internal.core.preferences.Preferences;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle
@@ -78,6 +82,18 @@ public class RemoteCorePlugin extends Plugin {
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, e.getMessage(), e));
}
+ /**
+ * Return the OSGi service with the given service interface.
+ *
+ * @param service service interface
+ * @return the specified service or null if it's not registered
+ */
+ public static T getService(Class service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
/**
* The constructor
*/
@@ -93,6 +109,8 @@ public class RemoteCorePlugin extends Plugin {
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
+ context.registerService(IRemoteServicesManager.class, new RemoteServicesManager(), null);
+ context.registerService(IRemoteLaunchConfigService.class, new RemoteLaunchConfigService(), null);
RemoteDebugOptions.configure(context);
ResourcesPlugin.getWorkspace().addSaveParticipant(getUniqueIdentifier(), new ISaveParticipant() {
@Override
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesDescriptor.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesDescriptor.java
deleted file mode 100644
index d5c72f84a32..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesDescriptor.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.core;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.IRemoteServicesDescriptor;
-import org.eclipse.remote.core.IRemoteServicesFactory;
-import org.eclipse.remote.internal.core.messages.Messages;
-
-public class RemoteServicesDescriptor implements IRemoteServicesDescriptor {
- private static final String ATTR_ID = "id"; //$NON-NLS-1$
- private static final String ATTR_NAME = "name"; //$NON-NLS-1$
- private static final String ATTR_SCHEME = "scheme"; //$NON-NLS-1$
- private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
-
- private static String getAttribute(IConfigurationElement configElement, String name, String defaultValue) {
- String value = configElement.getAttribute(name);
- if (value != null) {
- return value;
- }
- if (defaultValue != null) {
- return defaultValue;
- }
- throw new IllegalArgumentException(NLS.bind(Messages.RemoteServicesProxy_0, name));
- }
-
- private final IConfigurationElement fConfigElement;
-
- private final String fId;
- private final String fName;
- private final String fScheme;
- private IRemoteServicesFactory fFactory;
- private IRemoteServices fDelegate = null;
-
- public RemoteServicesDescriptor(IConfigurationElement configElement) {
- fConfigElement = configElement;
- fId = getAttribute(configElement, ATTR_ID, null);
- fName = getAttribute(configElement, ATTR_NAME, fId);
- fScheme = getAttribute(configElement, ATTR_SCHEME, null);
- getAttribute(configElement, ATTR_CLASS, null);
- fFactory = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(IRemoteServicesDescriptor arg0) {
- return getName().compareTo(arg0.getName());
- }
-
- /**
- * Get the factory from the plugin
- *
- * @return instance of the factory
- */
- public IRemoteServicesFactory getFactory() {
- if (fFactory != null) {
- return fFactory;
- }
- try {
- fFactory = (IRemoteServicesFactory) fConfigElement.createExecutableExtension(ATTR_CLASS);
- } catch (Exception e) {
- RemoteCorePlugin.log(NLS.bind(Messages.RemoteServicesProxy_1, new Object[] { fConfigElement.getAttribute(ATTR_CLASS),
- fId, fConfigElement.getDeclaringExtension().getNamespaceIdentifier() }));
- }
- return fFactory;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getId()
- */
- @Override
- public String getId() {
- return fId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getName()
- */
- @Override
- public String getName() {
- return fName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getScheme()
- */
- @Override
- public String getScheme() {
- return fScheme;
- }
-
- /**
- * Get the remote services implementation for this descriptor. The service has not been initialized.
- *
- * @return the remote services implementation
- */
- public IRemoteServices getServices() {
- loadServices();
- return fDelegate;
- }
-
- /**
- * Create the remote services factory. Note that the services will not be
- * initialized.
- */
- private void loadServices() {
- if (fDelegate == null) {
- IRemoteServicesFactory factory = getFactory();
- if (factory != null) {
- fDelegate = factory.getServices(this);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesImpl.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesImpl.java
deleted file mode 100644
index 4fb7616033a..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.core;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.remote.core.RemoteServices;
-import org.eclipse.remote.internal.core.services.local.LocalServices;
-
-/**
- * Main entry point for remote services
- *
- * @since 7.0
- */
-public class RemoteServicesImpl {
- public static final String REMOTE_SERVICES_EXTENSION_POINT_ID = "remoteServices"; //$NON-NLS-1$
-
- // Active remote services plugins (not necessarily loaded)
- private static final Map fRemoteServicesById = Collections
- .synchronizedMap(new HashMap());
- private static final Map fRemoteServicesByScheme = Collections
- .synchronizedMap(new HashMap());
-
- private RemoteServicesImpl() {
- // Hide constructor
- }
-
- public static RemoteServicesDescriptor getRemoteServiceDescriptorById(String id) {
- retrieveRemoteServices();
- return fRemoteServicesById.get(id);
- }
-
- public static RemoteServicesDescriptor getRemoteServiceDescriptorByURI(URI uri) {
- String scheme = uri.getScheme();
- if (scheme != null) {
- retrieveRemoteServices();
- return fRemoteServicesByScheme.get(scheme);
- }
- return null;
- }
-
- /**
- * Retrieve a sorted list of remote service descriptors. Does not return the local service provider. This must be obtained
- * using the {@link RemoteServices#getLocalServices()} method.
- *
- * @return remote service descriptors
- */
- public static List getRemoteServiceDescriptors() {
- retrieveRemoteServices();
- List descriptors = new ArrayList();
- for (RemoteServicesDescriptor descriptor : fRemoteServicesById.values()) {
- if (!descriptor.getId().equals(LocalServices.LocalServicesId)) {
- descriptors.add(descriptor);
- }
- }
- Collections.sort(descriptors);
- return descriptors;
- }
-
- /**
- * Find and load all remoteServices plugins.
- */
- private static void retrieveRemoteServices() {
- if (fRemoteServicesById.isEmpty()) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extensionPoint = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(),
- REMOTE_SERVICES_EXTENSION_POINT_ID);
- final IExtension[] extensions = extensionPoint.getExtensions();
-
- for (IExtension ext : extensions) {
- final IConfigurationElement[] elements = ext.getConfigurationElements();
-
- for (IConfigurationElement ce : elements) {
- RemoteServicesDescriptor proxy = new RemoteServicesDescriptor(ce);
- fRemoteServicesById.put(proxy.getId(), proxy);
- fRemoteServicesByScheme.put(proxy.getScheme(), proxy);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesManager.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesManager.java
new file mode 100644
index 00000000000..7195f99265a
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/RemoteServicesManager.java
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.internal.core;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionChangeListener;
+import org.eclipse.remote.core.IRemoteConnectionProviderService;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.remote.core.RemoteConnectionChangeEvent;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * The implementation for the remote services manager service.
+ */
+public class RemoteServicesManager implements IRemoteServicesManager {
+
+ private static final String LOCAL_SERVICES_ID = "org.eclipse.remote.LocalServices"; //$NON-NLS-1$
+
+ // Map from id to remote services
+ private final Map connectionTypeMap = new HashMap<>();
+
+ // Map from URI scheme to remote services
+ private final Map schemeMap = new HashMap<>();
+
+ private final List listeners = new LinkedList<>();
+ private boolean inited;
+
+ /**
+ * Loads up the services extensions and then loads up the persisted connections.
+ * This stuff can't be done from the constructor for the manager since that's done
+ * in the bundle activator which is way too early. It also gives us the ability
+ * to override the initialization in tests
+ */
+ protected void init() {
+ if (inited) {
+ return;
+ }
+ inited = true;
+
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint point = registry.getExtensionPoint(RemoteCorePlugin.getUniqueIdentifier(), "remoteServices"); //$NON-NLS-1$
+
+ // Load up the connection types
+ for (IExtension ext : point.getExtensions()) {
+ for (IConfigurationElement ce : ext.getConfigurationElements()) {
+ if (ce.getName().equals("connectionType")) { //$NON-NLS-1$
+ RemoteConnectionType services = new RemoteConnectionType(ce, this);
+ connectionTypeMap.put(services.getId(), services);
+ String scheme = services.getScheme();
+ if (scheme != null) {
+ schemeMap.put(scheme, services);
+ }
+ }
+ }
+ }
+
+ // Load up the services
+ for (IExtension ext : point.getExtensions()) {
+ for (IConfigurationElement ce : ext.getConfigurationElements()) {
+ String name = ce.getName();
+ if (name.equals("connectionTypeService") || name.equals("connectionService")) { //$NON-NLS-1$ //$NON-NLS-2$
+ String id = ce.getAttribute("connectionTypeId"); //$NON-NLS-1$
+ RemoteConnectionType services = connectionTypeMap.get(id);
+ if (services != null) {
+ services.addService(ce);
+ }
+ }
+ }
+ }
+
+ // Init connection providers
+ for (IRemoteConnectionType connectionType : connectionTypeMap.values()) {
+ IRemoteConnectionProviderService providerService = connectionType.getService(IRemoteConnectionProviderService.class);
+ if (providerService != null) {
+ providerService.init();
+ }
+ }
+ }
+
+ public Preferences getPreferenceNode() {
+ return InstanceScope.INSTANCE.getNode(RemoteCorePlugin.getUniqueIdentifier()).node("connections"); //$NON-NLS-1$
+ }
+
+ public ISecurePreferences getSecurePreferenceNode() {
+ return SecurePreferencesFactory.getDefault().node(RemoteCorePlugin.getUniqueIdentifier()).node("connections"); //$NON-NLS-1$
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType(String id) {
+ init();
+ return connectionTypeMap.get(id);
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType(URI uri) {
+ init();
+ return schemeMap.get(uri.getScheme());
+ }
+
+ @Override
+ public IRemoteConnectionType getLocalConnectionType() {
+ return getConnectionType(LOCAL_SERVICES_ID);
+ }
+
+ @Override
+ public List getAllConnectionTypes() {
+ init();
+ return new ArrayList(connectionTypeMap.values());
+ }
+
+ @Override
+ public List getRemoteConnectionTypes() {
+ init();
+ List services = new ArrayList<>(connectionTypeMap.values().size() - 1);
+ IRemoteConnectionType localServices = getLocalConnectionType();
+ for (IRemoteConnectionType s : connectionTypeMap.values()) {
+ if (!s.equals(localServices)) {
+ services.add(s);
+ }
+ }
+ return services;
+ }
+
+ @Override
+ public List getAllRemoteConnections() {
+ // TODO do this without getting the connection managers and force loading the plugins
+ List connections = new ArrayList<>();
+ for (IRemoteConnectionType services : getAllConnectionTypes()) {
+ connections.addAll(services.getConnections());
+ }
+ return connections;
+ }
+
+ @Override
+ public void addRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) {
+ synchronized (listeners) {
+ listeners.add(listener);
+ }
+ }
+
+ @Override
+ public void removeRemoteConnectionChangeListener(IRemoteConnectionChangeListener listener) {
+ synchronized (listeners) {
+ listeners.remove(listener);
+ }
+ }
+
+ @Override
+ public void fireRemoteConnectionChangeEvent(RemoteConnectionChangeEvent event) {
+ List iListeners;
+ synchronized (listeners) {
+ iListeners = new ArrayList<>(listeners);
+ }
+ for (IRemoteConnectionChangeListener listener : iListeners) {
+ listener.connectionChanged(event);
+ }
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/launch/RemoteLaunchConfigService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/launch/RemoteLaunchConfigService.java
new file mode 100644
index 00000000000..5b2ce2316a2
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/launch/RemoteLaunchConfigService.java
@@ -0,0 +1,65 @@
+package org.eclipse.remote.internal.core.launch;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.remote.core.launch.IRemoteLaunchConfigService;
+import org.eclipse.remote.internal.core.RemoteCorePlugin;
+import org.osgi.service.prefs.Preferences;
+
+public class RemoteLaunchConfigService implements IRemoteLaunchConfigService {
+
+ private static final String REMOTE_LAUNCH_CONFIG = "remoteLaunchConfig"; //$NON-NLS-1$
+ private static final String REMOTE_LAUNCH_TYPE = "remoteLaunchType"; //$NON-NLS-1$
+
+ private Preferences getPreferences(String node) {
+ return InstanceScope.INSTANCE.getNode(RemoteCorePlugin.getUniqueIdentifier()).node(node);
+ }
+
+ private IRemoteConnection getRemoteConnection(String remoteId) {
+ if (remoteId == null) {
+ return null;
+ }
+
+ String[] ids = remoteId.split(":"); //$NON-NLS-1$
+ if (ids.length < 2) {
+ return null;
+ }
+
+ IRemoteServicesManager manager = RemoteCorePlugin.getService(IRemoteServicesManager.class);
+ IRemoteConnectionType connectionType = manager.getConnectionType(ids[0]);
+ if (connectionType == null) {
+ return null;
+ }
+
+ return connectionType.getConnection(ids[1]);
+ }
+
+ @Override
+ public void setActiveConnection(ILaunchConfiguration launchConfig, IRemoteConnection connection) {
+ String remoteId = connection.getConnectionType().getId() + ":" + connection.getName(); //$NON-NLS-1$
+ getPreferences(REMOTE_LAUNCH_CONFIG).put(launchConfig.getName(), remoteId);
+ try {
+ getPreferences(REMOTE_LAUNCH_TYPE).put(launchConfig.getType().getIdentifier(), remoteId);
+ } catch (CoreException e) {
+ RemoteCorePlugin.log(e.getStatus());
+ }
+ }
+
+ @Override
+ public IRemoteConnection getActiveConnection(ILaunchConfiguration launchConfig) {
+ String remoteId = getPreferences(REMOTE_LAUNCH_CONFIG).get(launchConfig.getName(), null);
+ return getRemoteConnection(remoteId);
+ }
+
+ @Override
+ public IRemoteConnection getLastActiveConnection(ILaunchConfigurationType launchConfigType) {
+ String remoteId = getPreferences(REMOTE_LAUNCH_TYPE).get(launchConfigType.getIdentifier(), null);
+ return getRemoteConnection(remoteId);
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnection.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnection.java
deleted file mode 100644
index 18b112be9c7..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnection.java
+++ /dev/null
@@ -1,413 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.core.services.local;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ListenerList;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
-import org.eclipse.remote.core.IRemoteConnectionChangeListener;
-import org.eclipse.remote.core.IRemoteConnectionManager;
-import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-import org.eclipse.remote.core.IRemoteFileManager;
-import org.eclipse.remote.core.IRemoteProcess;
-import org.eclipse.remote.core.IRemoteProcessBuilder;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.exception.RemoteConnectionException;
-import org.eclipse.remote.core.exception.UnableToForwardPortException;
-import org.eclipse.remote.internal.core.RemoteCorePlugin;
-import org.eclipse.remote.internal.core.messages.Messages;
-
-public class LocalConnection implements IRemoteConnection {
- private final String fName = IRemoteConnectionManager.LOCAL_CONNECTION_NAME;
- private final String fAddress = Messages.LocalConnection_1;
- private final String fUsername = System.getProperty("user.name"); //$NON-NLS-1$
- private boolean fConnected = true;
- private IPath fWorkingDir = null;
-
- private final IRemoteFileManager fFileMgr = new LocalFileManager();
- private final IRemoteConnection fConnection = this;
- private final IRemoteServices fRemoteServices;
- private final ListenerList fListeners = new ListenerList();
-
- public LocalConnection(IRemoteServices services) {
- fRemoteServices = services;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#addConnectionChangeListener
- * (org.eclipse.remote.core.IRemoteConnectionChangeListener)
- */
- @Override
- public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
- fListeners.add(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#close()
- */
- @Override
- public void close() {
- if (fConnected) {
- fConnected = false;
- fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(IRemoteConnection connection) {
- return getName().compareTo(connection.getName());
- }
-
- /**
- * Notify all listeners when this connection's status changes.
- *
- * @param event
- */
- @Override
- public void fireConnectionChangeEvent(final int type) {
- IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
- @Override
- public IRemoteConnection getConnection() {
- return fConnection;
- }
-
- @Override
- public int getType() {
- return type;
- }
- };
- for (Object listener : fListeners.getListeners()) {
- ((IRemoteConnectionChangeListener) listener).connectionChanged(event);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(int,
- * java.lang.String, int)
- */
- @Override
- public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
- throw new UnableToForwardPortException(Messages.LocalConnection_2);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(java.lang
- * .String, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
- throw new UnableToForwardPortException(Messages.LocalConnection_2);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(int,
- * java.lang.String, int)
- */
- @Override
- public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
- throw new UnableToForwardPortException(Messages.LocalConnection_2);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(java.
- * lang.String, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
- throw new UnableToForwardPortException(Messages.LocalConnection_2);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getAddress()
- */
- @Override
- public String getAddress() {
- return fAddress;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
- */
- @Override
- public Map getAttributes() {
- return new HashMap();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getCommandShell(int)
- */
- @Override
- public IRemoteProcess getCommandShell(int flags) throws IOException {
- throw new IOException("Not currently implemented"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getEnv()
- */
- @Override
- public Map getEnv() {
- return System.getenv();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#getEnv(java.lang.String)
- */
- @Override
- public String getEnv(String name) {
- return System.getenv(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getFileManager(j)
- */
- @Override
- public IRemoteFileManager getFileManager() {
- return fFileMgr;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getName()
- */
- @Override
- public String getName() {
- return fName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getPort()
- */
- @Override
- public int getPort() {
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.util.List)
- */
- @Override
- public IRemoteProcessBuilder getProcessBuilder(List command) {
- return new LocalProcessBuilder(command);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.lang.String[])
- */
- @Override
- public IRemoteProcessBuilder getProcessBuilder(String... command) {
- return new LocalProcessBuilder(command);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#getProperty(java.lang.String
- * )
- */
- @Override
- public String getProperty(String key) {
- /*
- * Convert os.name and os.arch to framework properties so they make more sense
- */
- switch (key) {
- case IRemoteConnection.OS_NAME_PROPERTY:
- return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.os"); //$NON-NLS-1$
- case IRemoteConnection.OS_ARCH_PROPERTY:
- return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.arch"); //$NON-NLS-1$
- }
- return System.getProperty(key);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getRemoteServices()
- */
- @Override
- public IRemoteServices getRemoteServices() {
- return fRemoteServices;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getUsername()
- */
- @Override
- public String getUsername() {
- return fUsername;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
- */
- @Override
- public IRemoteConnectionWorkingCopy getWorkingCopy() {
- return new LocalConnectionWorkingCopy(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteFileManager#getWorkingDirectory(org
- * .eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public String getWorkingDirectory() {
- if (fWorkingDir == null) {
- String cwd = System.getProperty("user.home"); //$NON-NLS-1$
- if (cwd == null) {
- cwd = System.getProperty("user.dir"); //$NON-NLS-1$;
- }
- if (cwd == null) {
- fWorkingDir = Path.ROOT;
- } else {
- fWorkingDir = new Path(cwd);
- }
- }
- return fWorkingDir.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#isOpen()
- */
- @Override
- public boolean isOpen() {
- return fConnected;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#open()
- */
- @Override
- public void open(IProgressMonitor monitor) throws RemoteConnectionException {
- if (!fConnected) {
- fConnected = true;
- fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#removeConnectionChangeListener
- * (org.eclipse.remote.core.IRemoteConnectionChangeListener)
- */
- @Override
- public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
- fListeners.remove(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#removeLocalPortForwarding(int)
- */
- @Override
- public void removeLocalPortForwarding(int port) throws RemoteConnectionException {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#removeRemotePortForwarding(int)
- */
- @Override
- public void removeRemotePortForwarding(int port) throws RemoteConnectionException {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteFileManager#setWorkingDirectory(java
- * .lang.String)
- */
- @Override
- public void setWorkingDirectory(String pathStr) {
- IPath path = new Path(pathStr);
- if (path.isAbsolute()) {
- fWorkingDir = path;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnection#supportsTCPPortForwarding()
- */
- @Override
- public boolean supportsTCPPortForwarding() {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionManager.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionManager.java
deleted file mode 100644
index 23468927c16..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionManager.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.core.services.local;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.filesystem.EFS;
-import org.eclipse.remote.core.AbstractRemoteConnectionManager;
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.exception.RemoteConnectionException;
-import org.eclipse.remote.internal.core.messages.Messages;
-
-public class LocalConnectionManager extends AbstractRemoteConnectionManager {
- private final IRemoteConnection fLocalConnection;
-
- public LocalConnectionManager(IRemoteServices services) {
- super(services);
- fLocalConnection = new LocalConnection(services);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
- * .lang.String)
- */
- @Override
- public IRemoteConnection getConnection(String name) {
- if (name.equals(fLocalConnection.getName())) {
- return fLocalConnection;
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
- * .net.URI)
- */
- @Override
- public IRemoteConnection getConnection(URI uri) {
- if (uri.getScheme().equals(EFS.getLocalFileSystem().getScheme())) {
- return fLocalConnection;
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
- */
- @Override
- public List getConnections() {
- List list = new ArrayList();
- list.add(fLocalConnection);
- return list;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#newConnection(java
- * .lang.String)
- */
- @Override
- public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
- throw new RemoteConnectionException(Messages.Unable_to_create_new_local_connections);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#removeConnection
- * (org.eclipse.remote.core.IRemoteConnection)
- */
- @Override
- public void removeConnection(IRemoteConnection connection) {
- // Nothing
- }
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionPropertyService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionPropertyService.java
new file mode 100644
index 00000000000..2ed4089a60a
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionPropertyService.java
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.internal.core.services.local;
+
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnection.Service;
+import org.eclipse.remote.core.IRemoteConnectionPropertyService;
+import org.eclipse.remote.internal.core.RemoteCorePlugin;
+
+public class LocalConnectionPropertyService implements IRemoteConnectionPropertyService {
+
+ private final IRemoteConnection connection;
+
+ public LocalConnectionPropertyService(IRemoteConnection connection) {
+ this.connection = connection;
+ }
+
+ public static class Factory implements IRemoteConnectionPropertyService.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(IRemoteConnection remoteConnection, Class service) {
+ if (service.equals(IRemoteConnectionPropertyService.class)) {
+ return (T) new LocalConnectionPropertyService(remoteConnection);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public IRemoteConnection getRemoteConnection() {
+ return connection;
+ }
+
+ @Override
+ public String getProperty(String key) {
+ switch (key) {
+ case IRemoteConnection.OS_NAME_PROPERTY:
+ return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.os"); //$NON-NLS-1$
+ case IRemoteConnection.OS_ARCH_PROPERTY:
+ return RemoteCorePlugin.getDefault().getBundle().getBundleContext().getProperty("osgi.arch"); //$NON-NLS-1$
+ }
+ return System.getProperty(key);
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionProviderService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionProviderService.java
new file mode 100644
index 00000000000..71128b744fb
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionProviderService.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.internal.core.services.local;
+
+import org.eclipse.remote.core.IRemoteConnectionProviderService;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionType.Service;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+import org.eclipse.remote.internal.core.RemoteCorePlugin;
+
+public class LocalConnectionProviderService implements IRemoteConnectionProviderService {
+
+ private static final String localConnectionName = Messages.LocalConnectionProviderService_LocalConnectionName;
+
+ private IRemoteConnectionType connectionType;
+
+ public static class Factory implements IRemoteConnectionType.Service.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(IRemoteConnectionType connectionType, Class service) {
+ if (service.equals(IRemoteConnectionProviderService.class)) {
+ return (T) new LocalConnectionProviderService(connectionType);
+ }
+ return null;
+ }
+ }
+
+ public LocalConnectionProviderService(IRemoteConnectionType connectionType) {
+ this.connectionType = connectionType;
+ }
+
+ @Override
+ public void init() {
+ if (connectionType.getConnections().isEmpty()) {
+ try {
+ connectionType.newConnection(localConnectionName).save();
+ } catch (RemoteConnectionException e) {
+ RemoteCorePlugin.log(e.getStatus());
+ }
+ }
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType() {
+ return connectionType;
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionWorkingCopy.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionWorkingCopy.java
deleted file mode 100644
index a9c0073104d..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalConnectionWorkingCopy.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.core.services.local;
-
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-
-public class LocalConnectionWorkingCopy extends LocalConnection implements IRemoteConnectionWorkingCopy {
-
- private final LocalConnection fOriginal;
-
- public LocalConnectionWorkingCopy(LocalConnection connection) {
- super(connection.getRemoteServices());
- fOriginal = connection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#getOriginal()
- */
- @Override
- public IRemoteConnection getOriginal() {
- return fOriginal;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#isDirty()
- */
- @Override
- public boolean isDirty() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#save()
- */
- @Override
- public IRemoteConnection save() {
- return fOriginal;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAddress(java.lang.String)
- */
- @Override
- public void setAddress(String address) {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAttribute(java.lang.String, java.lang.String)
- */
- @Override
- public void setAttribute(String key, String value) {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
- */
- @Override
- public void setName(String name) {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPassword(java.lang.String)
- */
- @Override
- public void setPassword(String password) {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPort(int)
- */
- @Override
- public void setPort(int port) {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setUsername(java.lang.String)
- */
- @Override
- public void setUsername(String username) {
- // Do nothing
- }
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalFileManager.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalFileManager.java
index c619b7084bf..5577850b453 100644
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalFileManager.java
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalFileManager.java
@@ -17,56 +17,56 @@ import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.remote.core.IRemoteFileManager;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteFileService;
+import org.eclipse.remote.core.IRemoteProcessService;
+
+public class LocalFileManager implements IRemoteFileService {
+
+ private final IRemoteConnection connection;
+
+ public LocalFileManager(IRemoteConnection connection) {
+ this.connection = connection;
+ }
+
+ @Override
+ public IRemoteConnection getRemoteConnection() {
+ return connection;
+ }
-public class LocalFileManager implements IRemoteFileManager {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteFileManager#getDirectorySeparator()
- */
@Override
public String getDirectorySeparator() {
return System.getProperty("file.separator", "/"); //$NON-NLS-1$ //$NON-NLS-2$
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteFileManager#getResource(java.lang.String)
- */
@Override
public IFileStore getResource(String path) {
return EFS.getLocalFileSystem().getStore(new Path(path));
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteFileManager#toPath(java.net.URI)
- */
+ @Override
+ public String getBaseDirectory() {
+ return connection.getService(IRemoteProcessService.class).getWorkingDirectory();
+ }
+
+ @Override
+ public void setBaseDirectory(String path) {
+ connection.getService(IRemoteProcessService.class).setWorkingDirectory(path);
+ }
+
@Override
public String toPath(URI uri) {
return URIUtil.toPath(uri).toString();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteFileManager#toURI(org.eclipse.core.runtime.IPath)
- */
@Override
public URI toURI(IPath path) {
return URIUtil.toURI(path);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteFileManager#toURI(java.lang.String)
- */
@Override
public URI toURI(String path) {
return URIUtil.toURI(path);
}
+
}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalProcessService.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalProcessService.java
new file mode 100644
index 00000000000..6bdb204c1ee
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalProcessService.java
@@ -0,0 +1,76 @@
+package org.eclipse.remote.internal.core.services.local;
+
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Path;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnection.Service;
+import org.eclipse.remote.core.IRemoteProcessBuilder;
+import org.eclipse.remote.core.IRemoteProcessService;
+
+public class LocalProcessService implements IRemoteProcessService {
+
+ private final IRemoteConnection remoteConnection;
+ private String workingDirectory;
+
+ public LocalProcessService(IRemoteConnection remoteConnection) {
+ this.remoteConnection = remoteConnection;
+ }
+
+ public static class Factory implements IRemoteProcessService.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(IRemoteConnection remoteConnection, Class service) {
+ if (IRemoteProcessService.class.equals(service)) {
+ return (T) new LocalProcessService(remoteConnection);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public IRemoteConnection getRemoteConnection() {
+ return remoteConnection;
+ }
+
+ @Override
+ public Map getEnv() {
+ return System.getenv();
+ }
+
+ @Override
+ public String getEnv(String name) {
+ return System.getenv(name);
+ }
+
+ @Override
+ public IRemoteProcessBuilder getProcessBuilder(List command) {
+ return new LocalProcessBuilder(command);
+ }
+
+ @Override
+ public IRemoteProcessBuilder getProcessBuilder(String... command) {
+ return new LocalProcessBuilder(command);
+ }
+
+ @Override
+ public String getWorkingDirectory() {
+ if (workingDirectory == null) {
+ workingDirectory = System.getProperty("user.home"); //$NON-NLS-1$
+ if (workingDirectory == null) {
+ workingDirectory = System.getProperty("user.dir"); //$NON-NLS-1$
+ if (workingDirectory == null) {
+ workingDirectory = Path.ROOT.toOSString();
+ }
+ }
+ }
+ return workingDirectory;
+ }
+
+ @Override
+ public void setWorkingDirectory(String path) {
+ workingDirectory = path;
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalServices.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalServices.java
deleted file mode 100644
index 06024a5a78c..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalServices.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.core.services.local;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.remote.core.AbstractRemoteServices;
-import org.eclipse.remote.core.IRemoteConnectionManager;
-import org.eclipse.remote.core.IRemoteServicesDescriptor;
-
-public class LocalServices extends AbstractRemoteServices {
- public static final String LocalServicesId = "org.eclipse.remote.LocalServices"; //$NON-NLS-1$
-
- private final IRemoteConnectionManager fConnMgr = new LocalConnectionManager(this);
-
- public LocalServices(IRemoteServicesDescriptor descriptor) {
- super(descriptor);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getCapabilities()
- */
- @Override
- public int getCapabilities() {
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteServicesDescriptor#getConnectionManager
- * ()
- */
- @Override
- public IRemoteConnectionManager getConnectionManager() {
- return fConnMgr;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#initialize(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public boolean initialize(IProgressMonitor monitor) {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalServicesFactory.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalServicesFactory.java
deleted file mode 100644
index ae24bd94140..00000000000
--- a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/LocalServicesFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.core.services.local;
-
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.IRemoteServicesDescriptor;
-import org.eclipse.remote.core.IRemoteServicesFactory;
-
-public class LocalServicesFactory implements IRemoteServicesFactory {
- private static LocalServices services = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.remote.core.IRemoteServicesFactory#getServices(org.eclipse.remote.core.IRemoteServicesDescriptor)
- */
- public IRemoteServices getServices(IRemoteServicesDescriptor descriptor) {
- if (services == null) {
- services = new LocalServices(descriptor);
- }
- return services;
- }
-}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/Messages.java b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/Messages.java
new file mode 100644
index 00000000000..571f9045ca8
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/Messages.java
@@ -0,0 +1,15 @@
+package org.eclipse.remote.internal.core.services.local;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.remote.internal.core.services.local.messages"; //$NON-NLS-1$
+ public static String LocalConnectionProviderService_LocalConnectionName;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/messages.properties b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/messages.properties
new file mode 100644
index 00000000000..e72dc8616fc
--- /dev/null
+++ b/bundles/org.eclipse.remote.core/src/org/eclipse/remote/internal/core/services/local/messages.properties
@@ -0,0 +1 @@
+LocalConnectionProviderService_LocalConnectionName=Local
diff --git a/bundles/org.eclipse.remote.jsch.core/META-INF/MANIFEST.MF b/bundles/org.eclipse.remote.jsch.core/META-INF/MANIFEST.MF
index a004fb31789..35e5cbd3b36 100644
--- a/bundles/org.eclipse.remote.jsch.core/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.remote.jsch.core/META-INF/MANIFEST.MF
@@ -12,7 +12,7 @@ Require-Bundle: org.eclipse.core.runtime,
com.jcraft.jsch,
org.eclipse.equinox.security
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.remote.internal.jsch.core;x-friends:="org.eclipse.remote.jsch.ui",
+Export-Package: org.eclipse.remote.internal.jsch.core;x-friends:="org.eclipse.remote.jsch.ui,org.eclipse.remote.jsch.tests",
org.eclipse.remote.internal.jsch.core.messages;x-internal:=true
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
diff --git a/bundles/org.eclipse.remote.jsch.core/plugin.xml b/bundles/org.eclipse.remote.jsch.core/plugin.xml
index e6bc8c9474b..0a85f2ed12c 100644
--- a/bundles/org.eclipse.remote.jsch.core/plugin.xml
+++ b/bundles/org.eclipse.remote.jsch.core/plugin.xml
@@ -3,12 +3,42 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+ T getService(Class service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
public IJSchService getService() {
return fJSchService;
}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java
index 0ca81d6c5b3..89155a6fe52 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnection.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.remote.internal.jsch.core;
-import java.io.IOException;
import java.net.PasswordAuthentication;
import java.util.ArrayList;
import java.util.Collections;
@@ -19,20 +18,19 @@ import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jsch.core.IJSchService;
import org.eclipse.osgi.util.NLS;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
-import org.eclipse.remote.core.IRemoteConnectionChangeListener;
+import org.eclipse.remote.core.IRemoteConnectionControlService;
+import org.eclipse.remote.core.IRemoteConnectionPropertyService;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-import org.eclipse.remote.core.IRemoteFileManager;
-import org.eclipse.remote.core.IRemoteProcess;
+import org.eclipse.remote.core.IRemotePortForwardingService;
import org.eclipse.remote.core.IRemoteProcessBuilder;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.IUserAuthenticator;
+import org.eclipse.remote.core.IRemoteProcessService;
+import org.eclipse.remote.core.IUserAuthenticatorService;
+import org.eclipse.remote.core.RemoteConnectionChangeEvent;
import org.eclipse.remote.core.exception.AddressInUseException;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.core.exception.UnableToForwardPortException;
@@ -50,17 +48,27 @@ import com.jcraft.jsch.UserInfo;
/**
* @since 5.0
*/
-public class JSchConnection implements IRemoteConnection {
+public class JSchConnection implements IRemoteConnectionControlService, IRemoteConnectionPropertyService, IRemotePortForwardingService, IRemoteProcessService {
+ // Connection Type ID
+ public static final String JSCH_ID = "org.eclipse.remote.JSch"; //$NON-NLS-1$
+
+ // Attributes
+ public static final String ADDRESS_ATTR = "JSCH_ADDRESS_ATTR"; //$NON-NLS-1$
+ public static final String USERNAME_ATTR = "JSCH_USERNAME_ATTR"; //$NON-NLS-1$
+ public static final String PASSWORD_ATTR = "JSCH_PASSWORD_ATTR"; //$NON-NLS-1$
+ public static final String PORT_ATTR = "JSCH_PORT_ATTR"; //$NON-NLS-1$
+ public static final String PROXYCONNECTION_ATTR = "JSCH_PROXYCONNECTION_ATTR"; //$NON-NLS-1$
+ public static final String PROXYCOMMAND_ATTR = "JSCH_PROXYCOMMAND_ATTR"; //$NON-NLS-1$
+ public static final String IS_PASSWORD_ATTR = "JSCH_IS_PASSWORD_ATTR"; //$NON-NLS-1$
+ public static final String PASSPHRASE_ATTR = "JSCH_PASSPHRASE_ATTR"; //$NON-NLS-1$
+ public static final String TIMEOUT_ATTR = "JSCH_TIMEOUT_ATTR"; //$NON-NLS-1$
+ public static final String USE_LOGIN_SHELL_ATTR = "JSCH_USE_LOGIN_SHELL_ATTR"; //$NON-NLS-1$
+
/**
* Class to supply credentials from connection attributes without user interaction.
*/
private class JSchUserInfo implements UserInfo, UIKeyboardInteractive {
private boolean firstTryPassphrase = true;
- private final IUserAuthenticator fAuthenticator;
-
- public JSchUserInfo(IUserAuthenticator authenticator) {
- fAuthenticator = authenticator;
- }
@Override
public String getPassphrase() {
@@ -88,11 +96,18 @@ public class JSchConnection implements IRemoteConnection {
}
}
- if (fAuthenticator != null) {
- String[] result = fAuthenticator.prompt(destination, name, instruction, prompt, echo);
+ IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
+ if (authService != null) {
+ String[] result = authService.prompt(destination, name, instruction, prompt, echo);
if (result != null) {
if (prompt.length == 1 && prompt[0].trim().equalsIgnoreCase("password:")) { //$NON-NLS-1$
- fAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, result[0]);
+ IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
+ wc.setSecureAttribute(PASSWORD_ATTR, result[0]);
+ try {
+ wc.save();
+ } catch (RemoteConnectionException e) {
+ Activator.log(e.getStatus());
+ }
}
}
return result;
@@ -109,13 +124,20 @@ public class JSchConnection implements IRemoteConnection {
firstTryPassphrase = false;
return true;
}
- if (fAuthenticator != null) {
- PasswordAuthentication auth = fAuthenticator.prompt(getUsername(), message);
+ IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
+ if (authService != null) {
+ PasswordAuthentication auth = authService.prompt(getUsername(), message);
if (auth == null) {
return false;
}
- fAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, auth.getUserName());
- fAttributes.setSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, new String(auth.getPassword()));
+ IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
+ wc.setAttribute(USERNAME_ATTR, auth.getUserName());
+ wc.setSecureAttribute(PASSPHRASE_ATTR, new String(auth.getPassword()));
+ try {
+ wc.save();
+ } catch (RemoteConnectionException e) {
+ Activator.log(e.getStatus());
+ }
return true;
}
return false;
@@ -126,13 +148,20 @@ public class JSchConnection implements IRemoteConnection {
if (logging) {
System.out.println("promptPassword:" + message); //$NON-NLS-1$
}
- if (fAuthenticator != null) {
- PasswordAuthentication auth = fAuthenticator.prompt(getUsername(), message);
+ IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
+ if (authService != null) {
+ PasswordAuthentication auth = authService.prompt(getUsername(), message);
if (auth == null) {
return false;
}
- fAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, auth.getUserName());
- fAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, new String(auth.getPassword()));
+ IRemoteConnectionWorkingCopy wc = fRemoteConnection.getWorkingCopy();
+ wc.setAttribute(USERNAME_ATTR, auth.getUserName());
+ wc.setSecureAttribute(PASSWORD_ATTR, new String(auth.getPassword()));
+ try {
+ wc.save();
+ } catch (RemoteConnectionException e) {
+ Activator.log(e.getStatus());
+ }
return true;
}
return false;
@@ -143,10 +172,11 @@ public class JSchConnection implements IRemoteConnection {
if (logging) {
System.out.println("promptYesNo:" + message); //$NON-NLS-1$
}
- if (fAuthenticator != null) {
- int prompt = fAuthenticator.prompt(IUserAuthenticator.QUESTION, Messages.AuthInfo_Authentication_message, message,
- new int[] { IUserAuthenticator.YES, IUserAuthenticator.NO }, IUserAuthenticator.YES);
- return prompt == IUserAuthenticator.YES;
+ IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
+ if (authService != null) {
+ int prompt = authService.prompt(IUserAuthenticatorService.QUESTION, Messages.AuthInfo_Authentication_message, message,
+ new int[] { IUserAuthenticatorService.YES, IUserAuthenticatorService.NO }, IUserAuthenticatorService.YES);
+ return prompt == IUserAuthenticatorService.YES;
}
return true;
}
@@ -156,9 +186,10 @@ public class JSchConnection implements IRemoteConnection {
if (logging) {
System.out.println("showMessage:" + message); //$NON-NLS-1$
}
- if (fAuthenticator != null) {
- fAuthenticator.prompt(IUserAuthenticator.INFORMATION, Messages.AuthInfo_Authentication_message, message,
- new int[] { IUserAuthenticator.OK }, IUserAuthenticator.OK);
+ IUserAuthenticatorService authService = fRemoteConnection.getService(IUserAuthenticatorService.class);
+ if (authService != null) {
+ authService.prompt(IUserAuthenticatorService.INFORMATION, Messages.AuthInfo_Authentication_message, message,
+ new int[] { IUserAuthenticatorService.OK }, IUserAuthenticatorService.OK);
}
}
}
@@ -173,35 +204,46 @@ public class JSchConnection implements IRemoteConnection {
private String fWorkingDir;
+ private final IRemoteConnection fRemoteConnection;
private final IJSchService fJSchService;
- private final JSchConnectionAttributes fAttributes;
- private final JSchConnectionManager fManager;
private final Map fEnv = new HashMap();
private final Map fProperties = new HashMap();
- private final IRemoteServices fRemoteServices;
- private final ListenerList fListeners = new ListenerList();
private final List fSessions = new ArrayList();
private ChannelSftp fSftpChannel;
private boolean isFullySetup; // including sftp channel and environment
- public JSchConnection(String name, IRemoteServices services) {
- fRemoteServices = services;
- fManager = (JSchConnectionManager) services.getConnectionManager();
- fAttributes = new JSchConnectionAttributes(name);
+ public JSchConnection(IRemoteConnection connection) {
+ fRemoteConnection = connection;
fJSchService = Activator.getDefault().getService();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#addConnectionChangeListener
- * (org.eclipse.remote.core.IRemoteConnectionChangeListener)
- */
@Override
- public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
- fListeners.add(listener);
+ public IRemoteConnection getRemoteConnection() {
+ return fRemoteConnection;
+ }
+
+ public static class Factory implements IRemoteConnection.Service.Factory {
+ @Override
+ @SuppressWarnings("unchecked")
+ public T getService(IRemoteConnection connection, Class service) {
+ // This little trick creates an instance of this class for a connection
+ // then for each interface it implements, it returns the same object.
+ // This works because the connection caches the service so only one gets created.
+ // As a side effect, it makes this class a service too which can be used
+ // by the this plug-in
+ if (JSchConnection.class.equals(service)) {
+ return (T) new JSchConnection(connection);
+ } else if (IRemoteConnectionControlService.class.equals(service)
+ || IRemoteConnectionPropertyService.class.equals(service)
+ || IRemotePortForwardingService.class.equals(service)
+ || IRemoteProcessService.class.equals(service)) {
+ return (T) connection.getService(JSchConnection.class);
+ } else {
+ return null;
+ }
+ }
}
private boolean checkConfiguration(Session session, IProgressMonitor monitor) throws RemoteConnectionException {
@@ -237,19 +279,14 @@ public class JSchConnection implements IRemoteConnection {
* @throws RemoteConnectionException
*/
private void checkIsConfigured() throws RemoteConnectionException {
- if (fAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, null) == null) {
+ if (fRemoteConnection.getAttribute(ADDRESS_ATTR) == null) {
throw new RemoteConnectionException(Messages.JSchConnection_remote_address_must_be_set);
}
- if (fAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, null) == null) {
+ if (fRemoteConnection.getAttribute(USERNAME_ATTR) == null) {
throw new RemoteConnectionException(Messages.JSchConnection_username_must_be_set);
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#close()
- */
@Override
public synchronized void close() {
if (fSftpChannel != null) {
@@ -264,17 +301,7 @@ public class JSchConnection implements IRemoteConnection {
}
}
fSessions.clear();
- fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_CLOSED);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(IRemoteConnection o) {
- return getName().compareTo(o.getName());
+ fRemoteConnection.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_CLOSED);
}
/**
@@ -293,35 +320,6 @@ public class JSchConnection implements IRemoteConnection {
return exec.setCommand(cmd).getResult(monitor).trim();
}
- /**
- * Notify all fListeners when this connection's status changes.
- *
- * @param event
- */
- @Override
- public void fireConnectionChangeEvent(final int type) {
- final IRemoteConnection connection = this;
- IRemoteConnectionChangeEvent event = new IRemoteConnectionChangeEvent() {
- @Override
- public IRemoteConnection getConnection() {
- return connection;
- }
-
- @Override
- public int getType() {
- return type;
- }
- };
- for (Object listener : fListeners.getListeners()) {
- ((IRemoteConnectionChangeListener) listener).connectionChanged(event);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(int, java.lang.String, int)
- */
@Override
public void forwardLocalPort(int localPort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
if (!isOpen()) {
@@ -334,12 +332,6 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#forwardLocalPort(java.lang .String, int,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
public int forwardLocalPort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
if (!isOpen()) {
@@ -370,11 +362,6 @@ public class JSchConnection implements IRemoteConnection {
return -1;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(int, java.lang.String, int)
- */
@Override
public void forwardRemotePort(int remotePort, String fwdAddress, int fwdPort) throws RemoteConnectionException {
if (!isOpen()) {
@@ -387,12 +374,6 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#forwardRemotePort(java.lang.String, int,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
public int forwardRemotePort(String fwdAddress, int fwdPort, IProgressMonitor monitor) throws RemoteConnectionException {
if (!isOpen()) {
@@ -422,34 +403,8 @@ public class JSchConnection implements IRemoteConnection {
return -1;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getAddress()
- */
- @Override
public String getAddress() {
- return fAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
- */
- @Override
- public Map getAttributes() {
- return Collections.unmodifiableMap(fAttributes.getAttributes());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getCommandShell(int)
- */
- @Override
- public IRemoteProcess getCommandShell(int flags) throws IOException {
- throw new IOException("Not currently implemented"); //$NON-NLS-1$
+ return fRemoteConnection.getAttribute(ADDRESS_ATTR);
}
/**
@@ -467,21 +422,11 @@ public class JSchConnection implements IRemoteConnection {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getEnv()
- */
@Override
public Map getEnv() {
return Collections.unmodifiableMap(fEnv);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getEnv(java.lang.String)
- */
@Override
public String getEnv(String name) {
return getEnv().get(name);
@@ -503,89 +448,41 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getFileManager()
- */
- @Override
- public IRemoteFileManager getFileManager() {
- return new JSchFileManager(this);
- }
-
- public JSchConnectionAttributes getInfo() {
- return fAttributes;
- }
-
- public JSchConnectionManager getManager() {
- return fManager;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getName()
- */
- @Override
- public String getName() {
- return fAttributes.getName();
- }
-
public String getPassphrase() {
- return fAttributes.getSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, EMPTY_STRING);
+ return fRemoteConnection.getSecureAttribute(PASSPHRASE_ATTR);
}
public String getPassword() {
- return fAttributes.getSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, EMPTY_STRING);
+ return fRemoteConnection.getSecureAttribute(PASSWORD_ATTR);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getPort()
- */
- @Override
public int getPort() {
- return fAttributes.getInt(JSchConnectionAttributes.PORT_ATTR, DEFAULT_PORT);
+ String portStr = fRemoteConnection.getAttribute(PORT_ATTR);
+ return portStr != null ? Integer.parseInt(portStr) : DEFAULT_PORT;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.util.List)
- */
@Override
public IRemoteProcessBuilder getProcessBuilder(List command) {
return new JSchProcessBuilder(this, command);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getProcessBuilder(java.lang.String[])
- */
@Override
public IRemoteProcessBuilder getProcessBuilder(String... command) {
return new JSchProcessBuilder(this, command);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getProperty(java.lang.String )
- */
@Override
public String getProperty(String key) {
return fProperties.get(key);
}
/**
- * Gets the proxy command. For no proxy command an empty string is returned.
+ * Gets the proxy command. For no proxy command null is returned.
*
* @return proxy command
*/
public String getProxyCommand() {
- return fAttributes.getAttribute(JSchConnectionAttributes.PROXYCOMMAND_ATTR, EMPTY_STRING);
+ return fRemoteConnection.getAttribute(PROXYCOMMAND_ATTR);
}
/**
@@ -595,29 +492,19 @@ public class JSchConnection implements IRemoteConnection {
*/
public JSchConnection getProxyConnection() {
String proxyConnectionName = getProxyConnectionName();
- if (proxyConnectionName.equals(EMPTY_STRING)) {
+ if (proxyConnectionName.isEmpty()) {
return null;
}
- return (JSchConnection) fManager.getConnection(proxyConnectionName);
+ return fRemoteConnection.getConnectionType().getConnection(proxyConnectionName).getService(JSchConnection.class);
}
/**
* Gets the proxy connection name
*
- * @return proxy connection name. If no proxy is used returns an empty string. Never returns null.
+ * @return proxy connection name. If no proxy is used returns null.
*/
public String getProxyConnectionName() {
- return fAttributes.getAttribute(JSchConnectionAttributes.PROXYCONNECTION_ATTR, EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getRemoteServices()
- */
- @Override
- public IRemoteServices getRemoteServices() {
- return fRemoteServices;
+ return fRemoteConnection.getAttribute(PROXYCONNECTION_ATTR);
}
/**
@@ -641,11 +528,6 @@ public class JSchConnection implements IRemoteConnection {
return fSftpChannel;
}
- /*
- * (non-Javadoc)
- *
- * @see com.jcraft.jsch.Session#getStreamForwarder(java.lang.String, int)
- */
public Channel getStreamForwarder(String host, int port) throws RemoteConnectionException
{
try {
@@ -658,34 +540,14 @@ public class JSchConnection implements IRemoteConnection {
}
public int getTimeout() {
- return fAttributes.getInt(JSchConnectionAttributes.TIMEOUT_ATTR, DEFAULT_TIMEOUT);
+ String str = fRemoteConnection.getAttribute(TIMEOUT_ATTR);
+ return str != null ? Integer.parseInt(str) : DEFAULT_TIMEOUT;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getUsername()
- */
- @Override
public String getUsername() {
- return fAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, EMPTY_STRING);
+ return fRemoteConnection.getAttribute(USERNAME_ATTR);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
- */
- @Override
- public IRemoteConnectionWorkingCopy getWorkingCopy() {
- return new JSchConnectionWorkingCopy(this);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getWorkingDirectory()
- */
@Override
public String getWorkingDirectory() {
if (!isOpen()) {
@@ -715,18 +577,14 @@ public class JSchConnection implements IRemoteConnection {
return hasOpenSession;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#isOpen()
- */
@Override
public boolean isOpen() {
return hasOpenSession() && isFullySetup;
}
public boolean isPasswordAuth() {
- return fAttributes.getBoolean(JSchConnectionAttributes.IS_PASSWORD_ATTR, DEFAULT_IS_PASSWORD);
+ String str = fRemoteConnection.getAttribute(IS_PASSWORD_ATTR);
+ return str != null ? Boolean.parseBoolean(str) : DEFAULT_IS_PASSWORD;
}
private void loadEnv(IProgressMonitor monitor) throws RemoteConnectionException {
@@ -793,10 +651,10 @@ public class JSchConnection implements IRemoteConnection {
*/
private void loadProperties(IProgressMonitor monitor) throws RemoteConnectionException {
SubMonitor subMon = SubMonitor.convert(monitor, 100);
- fProperties.put(FILE_SEPARATOR_PROPERTY, "/"); //$NON-NLS-1$
- fProperties.put(PATH_SEPARATOR_PROPERTY, ":"); //$NON-NLS-1$
- fProperties.put(LINE_SEPARATOR_PROPERTY, "\n"); //$NON-NLS-1$
- fProperties.put(USER_HOME_PROPERTY, getWorkingDirectory());
+ fProperties.put(IRemoteConnection.FILE_SEPARATOR_PROPERTY, "/"); //$NON-NLS-1$
+ fProperties.put(IRemoteConnection.PATH_SEPARATOR_PROPERTY, ":"); //$NON-NLS-1$
+ fProperties.put(IRemoteConnection.LINE_SEPARATOR_PROPERTY, "\n"); //$NON-NLS-1$
+ fProperties.put(IRemoteConnection.USER_HOME_PROPERTY, getWorkingDirectory());
String osVersion;
String osArch;
@@ -830,26 +688,26 @@ public class JSchConnection implements IRemoteConnection {
osVersion = "unknown"; //$NON-NLS-1$
osArch = "unknown"; //$NON-NLS-1$
}
- fProperties.put(OS_NAME_PROPERTY, osName);
- fProperties.put(OS_VERSION_PROPERTY, osVersion);
- fProperties.put(OS_ARCH_PROPERTY, osArch);
+ fProperties.put(IRemoteConnection.OS_NAME_PROPERTY, osName);
+ fProperties.put(IRemoteConnection.OS_VERSION_PROPERTY, osVersion);
+ fProperties.put(IRemoteConnection.OS_ARCH_PROPERTY, osArch);
}
- private Session newSession(final IUserAuthenticator authenticator, IProgressMonitor monitor) throws RemoteConnectionException {
+ private Session newSession(IProgressMonitor monitor) throws RemoteConnectionException {
SubMonitor progress = SubMonitor.convert(monitor, 10);
try {
Session session = fJSchService.createSession(getAddress(), getPort(), getUsername());
- session.setUserInfo(new JSchUserInfo(authenticator));
+ session.setUserInfo(new JSchUserInfo());
if (isPasswordAuth()) {
session.setConfig("PreferredAuthentications", "password,keyboard-interactive,gssapi-with-mic,publickey"); //$NON-NLS-1$ //$NON-NLS-2$
session.setPassword(getPassword());
} else {
session.setConfig("PreferredAuthentications", "publickey,gssapi-with-mic,password,keyboard-interactive"); //$NON-NLS-1$ //$NON-NLS-2$
}
- if (getProxyCommand().equals(EMPTY_STRING) && getProxyConnectionName().equals(EMPTY_STRING)) {
+ if (getProxyCommand().isEmpty() && getProxyConnectionName().isEmpty()) {
fJSchService.connect(session, getTimeout() * 1000, progress.newChild(10)); // connect without proxy
} else {
- if (getProxyCommand().equals(EMPTY_STRING)) {
+ if (getProxyCommand().isEmpty()) {
session.setProxy(JSchConnectionProxyFactory.createForwardProxy(getProxyConnection(),
progress.newChild(10)));
fJSchService.connect(session, getTimeout() * 1000, progress.newChild(10));
@@ -869,11 +727,6 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#open()
- */
@Override
public void open(IProgressMonitor monitor) throws RemoteConnectionException {
open(monitor, true);
@@ -903,7 +756,7 @@ public class JSchConnection implements IRemoteConnection {
SubMonitor subMon = SubMonitor.convert(monitor, 60);
if (!hasOpenSession()) {
checkIsConfigured();
- newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
+ newSession(subMon.newChild(10));
if (subMon.isCanceled()) {
throw new RemoteConnectionException(Messages.JSchConnection_Connection_was_cancelled);
}
@@ -914,11 +767,11 @@ public class JSchConnection implements IRemoteConnection {
// getCwd checks the exec channel before checkConfiguration checks the sftp channel
fWorkingDir = getCwd(subMon.newChild(10));
if (!checkConfiguration(fSessions.get(0), subMon.newChild(20))) {
- newSession(fManager.getUserAuthenticator(this), subMon.newChild(10));
+ newSession(subMon.newChild(10));
loadEnv(subMon.newChild(10));
}
loadProperties(subMon.newChild(10));
- fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_OPENED);
+ fRemoteConnection.fireConnectionChangeEvent(RemoteConnectionChangeEvent.CONNECTION_OPENED);
}
}
@@ -932,22 +785,6 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#removeConnectionChangeListener
- * (org.eclipse.remote.core.IRemoteConnectionChangeListener)
- */
- @Override
- public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
- fListeners.remove(listener);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#removeLocalPortForwarding(int)
- */
@Override
public void removeLocalPortForwarding(int port) throws RemoteConnectionException {
if (!isOpen()) {
@@ -960,11 +797,6 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#removeRemotePortForwarding(int)
- */
@Override
public void removeRemotePortForwarding(int port) throws RemoteConnectionException {
if (!isOpen()) {
@@ -977,11 +809,6 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#setWorkingDirectory(java.lang.String)
- */
@Override
public void setWorkingDirectory(String path) {
if (new Path(path).isAbsolute()) {
@@ -989,31 +816,9 @@ public class JSchConnection implements IRemoteConnection {
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#supportsTCPPortForwarding()
- */
- @Override
- public boolean supportsTCPPortForwarding() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- String str = getName() + " [" + getUsername() + "@" + getAddress(); //$NON-NLS-1$ //$NON-NLS-2$
- if (getPort() >= 0) {
- str += ":" + getPort(); //$NON-NLS-1$
- }
- return str + "]"; //$NON-NLS-1$
- }
-
public boolean useLoginShell() {
- return fAttributes.getBoolean(JSchConnectionAttributes.USE_LOGIN_SHELL_ATTR, DEFAULT_USE_LOGIN_SHELL);
+ String str = fRemoteConnection.getAttribute(USE_LOGIN_SHELL_ATTR);
+ return !str.isEmpty() ? Boolean.parseBoolean(str) : DEFAULT_USE_LOGIN_SHELL;
}
+
}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionAttributes.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionAttributes.java
deleted file mode 100644
index 4ceaa0af373..00000000000
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionAttributes.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2014 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Markus Schorn - Bug 449306: Unnecessary access to secure storage.
- *******************************************************************************/
-package org.eclipse.remote.internal.jsch.core;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.equinox.security.storage.ISecurePreferences;
-import org.eclipse.equinox.security.storage.SecurePreferencesFactory;
-import org.eclipse.equinox.security.storage.StorageException;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-public class JSchConnectionAttributes {
- public static final String CONNECTIONS_KEY = "connections"; //$NON-NLS-1$
-
- public static final String ADDRESS_ATTR = "JSCH_ADDRESS_ATTR"; //$NON-NLS-1$
- public static final String USERNAME_ATTR = "JSCH_USERNAME_ATTR"; //$NON-NLS-1$
- public static final String PASSWORD_ATTR = "JSCH_PASSWORD_ATTR"; //$NON-NLS-1$
- public static final String PORT_ATTR = "JSCH_PORT_ATTR"; //$NON-NLS-1$
- public static final String PROXYCONNECTION_ATTR = "JSCH_PROXYCONNECTION_ATTR"; //$NON-NLS-1$
- public static final String PROXYCOMMAND_ATTR = "JSCH_PROXYCOMMAND_ATTR"; //$NON-NLS-1$
- public static final String IS_PASSWORD_ATTR = "JSCH_IS_PASSWORD_ATTR"; //$NON-NLS-1$
- public static final String PASSPHRASE_ATTR = "JSCH_PASSPHRASE_ATTR"; //$NON-NLS-1$
- public static final String TIMEOUT_ATTR = "JSCH_TIMEOUT_ATTR"; //$NON-NLS-1$
- public static final String USE_LOGIN_SHELL_ATTR = "JSCH_USE_LOGIN_SHELL_ATTR"; //$NON-NLS-1$
-
- private String fName;
- private String fNewName;
-
- private final Map fAttributes = Collections.synchronizedMap(new HashMap());
- private final Map fSecureAttributes = Collections.synchronizedMap(new HashMap());
-
- private boolean fSecureAttributesLoaded;
-
- public JSchConnectionAttributes(String name) {
- fName = name;
- load();
- }
-
- private void clearPreferences() {
- try {
- getPreferences().clear();
- } catch (BackingStoreException e) {
- Activator.log(e.getMessage());
- }
- getSecurePreferences().clear();
- }
-
- public JSchConnectionAttributes copy() {
- JSchConnectionAttributes copy = new JSchConnectionAttributes(fName);
- copy.getAttributes().putAll(fAttributes);
- copy.setSecureAttributes(getSecureAttributes());
- return copy;
- }
-
- private void flushPreferences() {
- try {
- getPreferences().flush();
- } catch (BackingStoreException e) {
- Activator.log(e.getMessage());
- }
- try {
- getSecurePreferences().flush();
- } catch (IOException e) {
- Activator.log(e.getMessage());
- }
- }
-
- public String getAttribute(String key, String def) {
- if (fAttributes.containsKey(key)) {
- return fAttributes.get(key);
- }
- return def;
- }
-
- public Map getAttributes() {
- return fAttributes;
- }
-
- public boolean getBoolean(String key, boolean def) {
- if (fAttributes.containsKey(key)) {
- return Boolean.parseBoolean(fAttributes.get(key));
- }
- return def;
- }
-
- public int getInt(String key, int def) {
- try {
- return Integer.parseInt(fAttributes.get(key));
- } catch (NumberFormatException e) {
- return def;
- }
- }
-
- public String getName() {
- if (fNewName == null) {
- return fName;
- }
- return fNewName;
- }
-
- private Preferences getPreferences() {
- IEclipsePreferences root = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
- Preferences connections = root.node(CONNECTIONS_KEY);
- return connections.node(fName);
- }
-
- public String getSecureAttribute(String key, String def) {
- loadSecureAttributes();
- if (fSecureAttributes.containsKey(key)) {
- return fSecureAttributes.get(key);
- }
- return def;
- }
-
- public Map getSecureAttributes() {
- loadSecureAttributes();
- return fSecureAttributes;
- }
-
- void setSecureAttributes(Map secureAttributes) {
- fSecureAttributes.clear();
- fSecureAttributes.putAll(secureAttributes);
- fSecureAttributesLoaded = true;
- }
-
- private ISecurePreferences getSecurePreferences() {
- ISecurePreferences secRoot = SecurePreferencesFactory.getDefault();
- ISecurePreferences secConnections = secRoot.node(CONNECTIONS_KEY);
- return secConnections.node(fName);
- }
-
- private void load() {
- IEclipsePreferences root = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
- Preferences connections = root.node(CONNECTIONS_KEY);
- Preferences nodes = connections.node(fName);
- try {
- loadAttributes(nodes);
- } catch (BackingStoreException e) {
- Activator.log(e.getMessage());
- }
- fSecureAttributesLoaded = false;
- }
-
- private void loadAttributes(Preferences node) throws BackingStoreException {
- fAttributes.clear();
- for (String key : node.keys()) {
- fAttributes.put(key, node.get(key, null));
- }
- }
-
- private void loadSecureAttributes() {
- if (fSecureAttributesLoaded) {
- return;
- }
-
- ISecurePreferences secNode = getSecurePreferences();
- try {
- fSecureAttributes.clear();
- for (String key : secNode.keys()) {
- fSecureAttributes.put(key, secNode.get(key, null));
- }
- } catch (StorageException e) {
- Activator.log(e.getMessage());
- }
- fSecureAttributesLoaded = true;
- }
-
- public void remove() {
- clearPreferences();
- flushPreferences();
- }
-
- public void save() {
- clearPreferences();
- if (fNewName != null) {
- fName = fNewName;
- fNewName = null;
- }
- savePreferences();
- flushPreferences();
- }
-
- private void savePreferences() {
- Preferences node = getPreferences();
- synchronized (fAttributes) {
- for (Entry entry : fAttributes.entrySet()) {
- if (entry.getValue() != null) {
- node.put(entry.getKey(), entry.getValue());
- } else {
- node.remove(entry.getKey());
- }
- }
- }
- if (fSecureAttributesLoaded) {
- try {
- ISecurePreferences secNode = getSecurePreferences();
- synchronized (fSecureAttributes) {
- for (Entry entry : fSecureAttributes.entrySet()) {
- secNode.put(entry.getKey(), entry.getValue(), true);
- }
- }
- } catch (StorageException e) {
- Activator.log(e.getMessage());
- }
- }
- }
-
- public void setAttribute(String key, String value) {
- fAttributes.put(key, value);
- }
-
- public void setName(String name) {
- fNewName = name;
- }
-
- public void setSecureAttribute(String key, String value) {
- loadSecureAttributes();
- fSecureAttributes.put(key, value);
- }
-}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionManager.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionManager.java
deleted file mode 100644
index a93f29ed79a..00000000000
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionManager.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.jsch.core;
-
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.remote.core.AbstractRemoteConnectionManager;
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.exception.RemoteConnectionException;
-import org.eclipse.remote.internal.jsch.core.messages.Messages;
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-
-public class JSchConnectionManager extends AbstractRemoteConnectionManager {
- private Map fConnections;
-
- /**
- * @since 4.0
- */
- public JSchConnectionManager(IRemoteServices services) {
- super(services);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
- * .lang.String)
- */
- @Override
- public IRemoteConnection getConnection(String name) {
- loadConnections();
- return fConnections.get(name);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#getConnection(java
- * .net.URI)
- */
- /**
- * @since 4.0
- */
- @Override
- public IRemoteConnection getConnection(URI uri) {
- String connName = JSchFileSystem.getConnectionNameFor(uri);
- if (connName != null) {
- return getConnection(connName);
- }
- return null;
- }
-
- public JSchConnection createConnection(String name) {
- return new JSchConnection(name, getRemoteServices());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#getConnections()
- */
- @Override
- public List getConnections() {
- loadConnections();
- List conns = new ArrayList();
- conns.addAll(fConnections.values());
- return conns;
- }
-
- private synchronized void loadConnections() {
- if (fConnections == null) {
- fConnections = Collections.synchronizedMap(new HashMap());
- IEclipsePreferences root = InstanceScope.INSTANCE.getNode(Activator.getUniqueIdentifier());
- Preferences connections = root.node(JSchConnectionAttributes.CONNECTIONS_KEY);
- try {
- for (String name : connections.childrenNames()) {
- JSchConnection connection = new JSchConnection(name, getRemoteServices());
- fConnections.put(name, connection);
- }
- } catch (BackingStoreException e) {
- Activator.log(e.getMessage());
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#newConnection(java
- * .lang.String, java.util.Map)
- */
- /**
- * @since 5.0
- */
- @Override
- public IRemoteConnectionWorkingCopy newConnection(String name) throws RemoteConnectionException {
- if (getConnection(name) != null) {
- throw new RemoteConnectionException(NLS.bind(Messages.JSchConnectionManager_connection_with_name_exists, name));
- }
- return createConnection(name).getWorkingCopy();
- }
-
- public void add(JSchConnection conn) {
- if (!fConnections.containsKey(conn.getName())) {
- fConnections.put(conn.getName(), conn);
- }
- }
-
- public void remove(JSchConnection conn) {
- if (fConnections.containsKey(conn.getName())) {
- fConnections.remove(conn.getName());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteConnectionManager#removeConnection
- * (org.eclipse.remote.core.IRemoteConnection)
- */
- @Override
- public void removeConnection(IRemoteConnection conn) throws RemoteConnectionException {
- if (!(conn instanceof JSchConnection)) {
- throw new RemoteConnectionException(Messages.JSchConnectionManager_invalidConnectionType);
- }
- if (conn.isOpen()) {
- throw new RemoteConnectionException(Messages.JSchConnectionManager_cannotRemoveOpenConnection);
- }
- ((JSchConnection) conn).getInfo().remove();
- fConnections.remove(conn.getName());
- }
-}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionProxyFactory.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionProxyFactory.java
index dbd496cb4e1..0446d5a0d74 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionProxyFactory.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionProxyFactory.java
@@ -24,9 +24,10 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
-import org.eclipse.remote.core.IRemoteConnectionManager;
+import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteProcess;
-import org.eclipse.remote.core.RemoteServices;
+import org.eclipse.remote.core.IRemoteProcessService;
+import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.internal.jsch.core.messages.Messages;
@@ -113,8 +114,9 @@ public class JSchConnectionProxyFactory {
}
} else {
List cmd = new ArgumentParser(command).getTokenList();
- process = RemoteServices.getLocalServices().getConnectionManager().getConnection(
- IRemoteConnectionManager.LOCAL_CONNECTION_NAME).getProcessBuilder(cmd).start();
+ IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
+ IRemoteConnection connection = manager.getLocalConnectionType().getConnections().get(0);
+ process = connection.getService(IRemoteProcessService.class).getProcessBuilder(cmd).start();
}
// Wait on command to produce stdout output
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionWorkingCopy.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionWorkingCopy.java
deleted file mode 100644
index 1fef9769203..00000000000
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchConnectionWorkingCopy.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010, 2014 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- * Markus Schorn - Bug 449306: Unnecessary access to secure storage.
- *******************************************************************************/
-package org.eclipse.remote.internal.jsch.core;
-
-import java.util.Collections;
-import java.util.Map;
-
-import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionChangeEvent;
-import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-
-/**
- * @since 5.0
- */
-public class JSchConnectionWorkingCopy extends JSchConnection implements IRemoteConnectionWorkingCopy {
- private final JSchConnectionAttributes fWorkingAttributes;
- private final JSchConnection fOriginal;
- private boolean fIsDirty;
-
- public JSchConnectionWorkingCopy(JSchConnection connection) {
- super(connection.getName(), connection.getRemoteServices());
- fWorkingAttributes = connection.getInfo().copy();
- fOriginal = connection;
- fIsDirty = false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getAddress()
- */
- @Override
- public String getAddress() {
- return fWorkingAttributes.getAttribute(JSchConnectionAttributes.ADDRESS_ATTR, EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getAttributes()
- */
- @Override
- public Map getAttributes() {
- return Collections.unmodifiableMap(fWorkingAttributes.getAttributes());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getName()
- */
- @Override
- public String getName() {
- return fWorkingAttributes.getName();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#getOriginal()
- */
- @Override
- public IRemoteConnection getOriginal() {
- return fOriginal;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.internal.jsch.core.JSchConnection#getPassphrase()
- */
- @Override
- public String getPassphrase() {
- return fWorkingAttributes.getSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.internal.jsch.core.JSchConnection#getPassword()
- */
- @Override
- public String getPassword() {
- return fWorkingAttributes.getSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getPort()
- */
- @Override
- public int getPort() {
- return fWorkingAttributes.getInt(JSchConnectionAttributes.PORT_ATTR, DEFAULT_PORT);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.internal.jsch.core.JSchConnection#getProxyCommand()
- */
- @Override
- public String getProxyCommand() {
- return fWorkingAttributes.getAttribute(JSchConnectionAttributes.PROXYCOMMAND_ATTR, EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.internal.jsch.core.JSchConnection#getProxyConnectionName()
- */
- @Override
- public String getProxyConnectionName() {
- return fWorkingAttributes.getAttribute(JSchConnectionAttributes.PROXYCONNECTION_ATTR, EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.internal.jsch.core.JSchConnection#getTimeout()
- */
- @Override
- public int getTimeout() {
- return fWorkingAttributes.getInt(JSchConnectionAttributes.TIMEOUT_ATTR, DEFAULT_TIMEOUT);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getUsername()
- */
- @Override
- public String getUsername() {
- return fWorkingAttributes.getAttribute(JSchConnectionAttributes.USERNAME_ATTR, JSchConnection.EMPTY_STRING);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnection#getWorkingCopy()
- */
- @Override
- public IRemoteConnectionWorkingCopy getWorkingCopy() {
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#isDirty()
- */
- @Override
- public boolean isDirty() {
- return fIsDirty;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.internal.jsch.core.JSchConnection#isPasswordAuth()
- */
- @Override
- public boolean isPasswordAuth() {
- return fWorkingAttributes.getBoolean(JSchConnectionAttributes.IS_PASSWORD_ATTR, DEFAULT_IS_PASSWORD);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#save()
- */
- @Override
- public IRemoteConnection save() {
- JSchConnectionAttributes info = fOriginal.getInfo();
- info.getAttributes().clear();
- info.getAttributes().putAll(fWorkingAttributes.getAttributes());
- info.setSecureAttributes(fWorkingAttributes.getSecureAttributes());
- if (!getName().equals(info.getName())) {
- info.setName(getName());
- getManager().remove(fOriginal);
- fOriginal.fireConnectionChangeEvent(IRemoteConnectionChangeEvent.CONNECTION_RENAMED);
- }
- info.save();
- getManager().add(fOriginal);
- fIsDirty = false;
- return fOriginal;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAddress(java.lang.String)
- */
- @Override
- public void setAddress(String address) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.ADDRESS_ATTR, address);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setAttribute(java.lang.String, java.lang.String)
- */
- @Override
- public void setAttribute(String key, String value) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(key, value);
- }
-
- public void setIsPasswordAuth(boolean flag) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.IS_PASSWORD_ATTR, Boolean.toString(flag));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
- */
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setName(java.lang.String)
- */
- @Override
- public void setName(String name) {
- fIsDirty = true;
- fWorkingAttributes.setName(name);
- }
-
- public void setPassphrase(String passphrase) {
- fIsDirty = true;
- fWorkingAttributes.setSecureAttribute(JSchConnectionAttributes.PASSPHRASE_ATTR, passphrase);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPassword(java.lang.String)
- */
- @Override
- public void setPassword(String password) {
- fIsDirty = true;
- fWorkingAttributes.setSecureAttribute(JSchConnectionAttributes.PASSWORD_ATTR, password);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setPort(int)
- */
- @Override
- public void setPort(int port) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
- }
-
- /**
- * Sets the proxy command. Set to empty string for no command
- *
- * @param proxyCommand
- * proxy command
- */
- public void setProxyCommand(String proxyCommand) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.PROXYCOMMAND_ATTR, proxyCommand);
- }
-
- /**
- * Sets the proxy connection name. Set to empty string for no proxy connection
- *
- * @param proxyCommand
- * proxy connection name
- */
- public void setProxyConnectionName(String proxyConnectionName) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.PROXYCONNECTION_ATTR, proxyConnectionName);
- }
-
- public void setTimeout(int timeout) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.TIMEOUT_ATTR, Integer.toString(timeout));
- }
-
- public void setUseLoginShell(boolean flag) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.USE_LOGIN_SHELL_ATTR, Boolean.toString(flag));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteConnectionWorkingCopy#setUsername(java.lang.String)
- */
- @Override
- public void setUsername(String userName) {
- fIsDirty = true;
- fWorkingAttributes.setAttribute(JSchConnectionAttributes.USERNAME_ATTR, userName);
- }
-}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchFileManager.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchFileManager.java
index fb4ea90eee2..565eb480dab 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchFileManager.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchFileManager.java
@@ -15,62 +15,64 @@ import java.net.URI;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-import org.eclipse.remote.core.IRemoteFileManager;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteFileService;
+import org.eclipse.remote.core.IRemoteProcessService;
+import org.eclipse.remote.core.IRemoteConnection.Service;
-public class JSchFileManager implements IRemoteFileManager {
- private final JSchConnection fConnection;
+public class JSchFileManager implements IRemoteFileService {
- public JSchFileManager(JSchConnection connection) {
+ private final IRemoteConnection fConnection;
+
+ public JSchFileManager(IRemoteConnection connection) {
fConnection = connection;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteFileManager#getDirectorySeparator()
- */
- /**
- * @since 4.0
- */
+ public static class Factory implements IRemoteFileService.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(IRemoteConnection remoteConnection, Class service) {
+ if (IRemoteFileService.class.equals(service)) {
+ return (T) new JSchFileManager(remoteConnection);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public IRemoteConnection getRemoteConnection() {
+ return fConnection;
+ }
+
@Override
public String getDirectorySeparator() {
return "/"; //$NON-NLS-1$
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteFileManager#getResource(java.lang.
- * String)
- */
@Override
public IFileStore getResource(String pathStr) {
IPath path = new Path(pathStr);
if (!path.isAbsolute()) {
- path = new Path(fConnection.getWorkingDirectory()).append(path);
+ path = new Path(getBaseDirectory()).append(path);
}
return JschFileStore.getInstance(JSchFileSystem.getURIFor(fConnection.getName(), path.toString()));
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteFileManager#toPath(java.net.URI)
- */
+ @Override
+ public String getBaseDirectory() {
+ return fConnection.getService(IRemoteProcessService.class).getWorkingDirectory();
+ }
+
+ @Override
+ public void setBaseDirectory(String path) {
+ fConnection.getService(IRemoteProcessService.class).setWorkingDirectory(path);
+ }
+
@Override
public String toPath(URI uri) {
return uri.getPath();
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteFileManager#toURI(org.eclipse.core
- * .runtime.IPath)
- */
@Override
public URI toURI(IPath path) {
try {
@@ -80,14 +82,9 @@ public class JSchFileManager implements IRemoteFileManager {
}
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteFileManager#toURI(java.lang.String)
- */
@Override
public URI toURI(String path) {
return toURI(new Path(path));
}
+
}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchProcessBuilder.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchProcessBuilder.java
index 7b6bc9fea6f..5793bd8c301 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchProcessBuilder.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchProcessBuilder.java
@@ -24,7 +24,7 @@ import java.util.Set;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.remote.core.AbstractRemoteProcessBuilder;
-import org.eclipse.remote.core.IRemoteFileManager;
+import org.eclipse.remote.core.IRemoteFileService;
import org.eclipse.remote.core.IRemoteProcess;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.internal.core.RemoteDebugOptions;
@@ -34,15 +34,13 @@ import com.jcraft.jsch.ChannelExec;
import com.jcraft.jsch.JSchException;
public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
+
private final JSchConnection fConnection;
private final Map fRemoteEnv = new HashMap();
private final Set charSet = new HashSet();
private Map fNewRemoteEnv = null;
- /**
- * @since 4.0
- */
public JSchProcessBuilder(JSchConnection connection, List command) {
super(command);
fConnection = connection;
@@ -58,34 +56,21 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
}
}
- /**
- * @since 4.0
- */
public JSchProcessBuilder(JSchConnection connection, String... command) {
this(connection, Arrays.asList(command));
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.AbstractRemoteProcessBuilder#directory()
- */
@Override
public IFileStore directory() {
IFileStore dir = super.directory();
- IRemoteFileManager fileMgr = fConnection.getFileManager();
- if (dir == null && fileMgr != null) {
- dir = fileMgr.getResource(fConnection.getWorkingDirectory());
+ IRemoteFileService fileService = fConnection.getRemoteConnection().getService(IRemoteFileService.class);
+ if (dir == null && fileService != null) {
+ dir = fileService.getResource(fConnection.getWorkingDirectory());
directory(dir);
}
return dir;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.AbstractRemoteProcessBuilder#environment()
- */
@Override
public Map environment() {
if (fNewRemoteEnv == null) {
@@ -95,21 +80,11 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
return fNewRemoteEnv;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.AbstractRemoteProcessBuilder#getSupportedFlags ()
- */
@Override
public int getSupportedFlags() {
return ALLOCATE_PTY | FORWARD_X11;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteProcessBuilder#start(int)
- */
@Override
public IRemoteProcess start(int flags) throws IOException {
if (!fConnection.isOpen()) {
@@ -234,4 +209,5 @@ public class JSchProcessBuilder extends AbstractRemoteProcessBuilder {
inputString = newString.toString();
return inputString;
}
+
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchServices.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchServices.java
deleted file mode 100644
index 6117a9ed902..00000000000
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchServices.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.jsch.core;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.remote.core.AbstractRemoteServices;
-import org.eclipse.remote.core.IRemoteConnectionManager;
-import org.eclipse.remote.core.IRemoteServicesDescriptor;
-
-public class JSchServices extends AbstractRemoteServices {
- public static final String JSCH_ID = "org.eclipse.remote.JSch"; //$NON-NLS-1$
-
- private final JSchConnectionManager connMgr = new JSchConnectionManager(this);
-
- public JSchServices(IRemoteServicesDescriptor descriptor) {
- super(descriptor);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.core.IRemoteServicesDescriptor#getConnectionManager
- * ()
- */
- public IRemoteConnectionManager getConnectionManager() {
- return connMgr;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#initialize(org.eclipse.core.runtime.IProgressMonitor)
- */
- public boolean initialize(IProgressMonitor monitor) {
- return true;
- }
-
- public int getCapabilities() {
- return CAPABILITY_ADD_CONNECTIONS | CAPABILITY_EDIT_CONNECTIONS | CAPABILITY_REMOVE_CONNECTIONS
- | CAPABILITY_SUPPORTS_TCP_PORT_FORWARDING | CAPABILITY_SUPPORTS_X11_FORWARDING;
- }
-}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchServicesFactory.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchServicesFactory.java
deleted file mode 100644
index 52320843b0d..00000000000
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JSchServicesFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.jsch.core;
-
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.IRemoteServicesDescriptor;
-import org.eclipse.remote.core.IRemoteServicesFactory;
-
-public class JSchServicesFactory implements IRemoteServicesFactory {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServicesFactory#getServices(org.eclipse.remote.core.IRemoteServicesDescriptor)
- */
- public IRemoteServices getServices(IRemoteServicesDescriptor descriptor) {
- return new JSchServices(descriptor);
- }
-}
diff --git a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JschFileStore.java b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JschFileStore.java
index d7b6f4e248f..1082c4d75bc 100644
--- a/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JschFileStore.java
+++ b/bundles/org.eclipse.remote.jsch.core/src/org/eclipse/remote/internal/jsch/core/JschFileStore.java
@@ -30,9 +30,8 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionManager;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.RemoteServices;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.internal.jsch.core.commands.ChildInfosCommand;
import org.eclipse.remote.internal.jsch.core.commands.DeleteCommand;
@@ -73,24 +72,27 @@ public class JschFileStore extends FileStore {
}
private JSchConnection checkConnection(IProgressMonitor monitor) throws RemoteConnectionException {
- IRemoteServices services = RemoteServices.getRemoteServices(fURI);
- assert (services instanceof JSchServices);
- if (services == null) {
+ IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
+ IRemoteConnectionType connectionType = manager.getConnectionType(fURI);
+ if (connectionType == null) {
throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_No_remote_services_found_for_URI, fURI));
}
- IRemoteConnectionManager manager = services.getConnectionManager();
- assert (manager != null);
- IRemoteConnection connection = manager.getConnection(fURI);
- if (connection == null || !(connection instanceof JSchConnection)) {
- throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_Invalid_connection_for_URI, fURI));
- }
- if (!connection.isOpen()) {
- connection.open(monitor);
- if (!connection.isOpen()) {
- throw new RemoteConnectionException(Messages.JschFileStore_Connection_is_not_open);
+
+ try {
+ IRemoteConnection connection = connectionType.getConnection(fURI);
+ if (connection == null) {
+ throw new RemoteConnectionException(NLS.bind(Messages.JschFileStore_Invalid_connection_for_URI, fURI));
}
+ if (!connection.isOpen()) {
+ connection.open(monitor);
+ if (!connection.isOpen()) {
+ throw new RemoteConnectionException(Messages.JschFileStore_Connection_is_not_open);
+ }
+ }
+ return connection.getService(JSchConnection.class);
+ } catch (CoreException e) {
+ throw new RemoteConnectionException(e);
}
- return (JSchConnection) connection;
}
/*
diff --git a/bundles/org.eclipse.remote.jsch.ui/plugin.xml b/bundles/org.eclipse.remote.jsch.ui/plugin.xml
index f84b7e90cb5..d25045b6819 100644
--- a/bundles/org.eclipse.remote.jsch.ui/plugin.xml
+++ b/bundles/org.eclipse.remote.jsch.ui/plugin.xml
@@ -1,14 +1,6 @@
-
-
-
-
+
+
+
+
+
+
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/Activator.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/Activator.java
index be51be3f318..080fe5c6e4f 100644
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/Activator.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/Activator.java
@@ -78,6 +78,18 @@ public class Activator extends Plugin {
public Activator() {
}
+ /**
+ * Return the OSGi service with the given service interface.
+ *
+ * @param service service interface
+ * @return the specified service or null if it's not registered
+ */
+ public static T getService(Class service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
public IJSchService getService() {
return fJSchService;
}
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchFileSystemContributor.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchFileSystemContributor.java
index 85d5d25260d..667f02475ac 100644
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchFileSystemContributor.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchFileSystemContributor.java
@@ -27,14 +27,12 @@ import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.RemoteServices;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.remote.internal.jsch.core.JSchConnection;
import org.eclipse.remote.internal.jsch.core.JSchFileSystem;
-import org.eclipse.remote.internal.jsch.core.JSchServices;
import org.eclipse.remote.internal.jsch.ui.messages.Messages;
-import org.eclipse.remote.ui.IRemoteUIFileManager;
-import org.eclipse.remote.ui.IRemoteUIServices;
-import org.eclipse.remote.ui.RemoteUIServices;
+import org.eclipse.remote.ui.IRemoteUIFileService;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.ide.fileSystem.FileSystemContributor;
@@ -48,9 +46,9 @@ public class JSchFileSystemContributor extends FileSystemContributor {
*/
@Override
public URI browseFileSystem(String initialPath, Shell shell) {
- IRemoteServices services = RemoteServices.getRemoteServices(JSchServices.JSCH_ID);
- IRemoteUIServices uiServices = RemoteUIServices.getRemoteUIServices(services);
- IRemoteUIFileManager uiFileMgr = uiServices.getUIFileManager();
+ IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
+ IRemoteConnectionType connectionType = manager.getConnectionType(JSchConnection.JSCH_ID);
+ IRemoteUIFileService uiFileMgr = connectionType.getService(IRemoteUIFileService.class);
uiFileMgr.showConnections(true);
String path = uiFileMgr.browseDirectory(shell, Messages.JSchFileSystemContributor_0, initialPath, 0);
if (path != null) {
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIConnectionManager.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIConnectionService.java
similarity index 75%
rename from bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIConnectionManager.java
rename to bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIConnectionService.java
index 9c108403141..f0e6bfd1064 100644
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIConnectionManager.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIConnectionService.java
@@ -20,30 +20,43 @@ import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteServices;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionType.Service;
import org.eclipse.remote.core.exception.RemoteConnectionException;
-import org.eclipse.remote.internal.jsch.core.JSchConnectionManager;
import org.eclipse.remote.internal.jsch.ui.messages.Messages;
import org.eclipse.remote.internal.jsch.ui.wizards.JSchConnectionWizard;
import org.eclipse.remote.ui.AbstractRemoteUIConnectionManager;
+import org.eclipse.remote.ui.IRemoteUIConnectionService;
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
import org.eclipse.swt.widgets.Shell;
-public class JSchUIConnectionManager extends AbstractRemoteUIConnectionManager {
- private final JSchConnectionManager fConnMgr;
+public class JSchUIConnectionService extends AbstractRemoteUIConnectionManager {
- public JSchUIConnectionManager(IRemoteServices services) {
- fConnMgr = (JSchConnectionManager) services.getConnectionManager();
+ private final IRemoteConnectionType fConnectionType;
+
+ public JSchUIConnectionService(IRemoteConnectionType connectionType) {
+ fConnectionType = connectionType;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIConnectionManager#getConnectionWizard(org.eclipse.swt.widgets.Shell)
- */
+ public static class Factory implements IRemoteConnectionType.Service.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(IRemoteConnectionType connectionType, Class service) {
+ if (IRemoteUIConnectionService.class.equals(service)) {
+ return (T) new JSchUIConnectionService(connectionType);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType() {
+ return fConnectionType;
+ }
+
@Override
public IRemoteUIConnectionWizard getConnectionWizard(Shell shell) {
- return new JSchConnectionWizard(shell, fConnMgr);
+ return new JSchConnectionWizard(shell, fConnectionType);
}
@Override
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIFileManager.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIFileService.java
similarity index 82%
rename from bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIFileManager.java
rename to bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIFileService.java
index 96557a0449a..200c0de397f 100644
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIFileManager.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIFileService.java
@@ -16,15 +16,38 @@ import java.util.List;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.jface.window.Window;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.ui.IRemoteUIFileManager;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionType.Service;
+import org.eclipse.remote.ui.IRemoteUIFileService;
import org.eclipse.remote.ui.dialogs.RemoteResourceBrowser;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
-public class JSchUIFileManager implements IRemoteUIFileManager {
+public class JSchUIFileService implements IRemoteUIFileService {
+ private final IRemoteConnectionType connectionType;
private IRemoteConnection connection = null;
private boolean showConnections = false;
+ public JSchUIFileService(IRemoteConnectionType connectionType) {
+ this.connectionType = connectionType;
+ }
+
+ public static class Factory implements IRemoteConnectionType.Service.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(IRemoteConnectionType connectionType, Class service) {
+ if (IRemoteUIFileService.class.equals(service)) {
+ return (T) new JSchUIFileService(connectionType);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType() {
+ return connectionType;
+ }
+
/*
* (non-Javadoc)
*
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIServices.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIServices.java
deleted file mode 100644
index 4da5846584d..00000000000
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIServices.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.jsch.ui;
-
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.ui.IRemoteUIConnectionManager;
-import org.eclipse.remote.ui.IRemoteUIFileManager;
-import org.eclipse.remote.ui.IRemoteUIServices;
-
-public class JSchUIServices implements IRemoteUIServices {
- private static JSchUIServices fInstance = null;
-
- /**
- * Get shared instance of this class
- *
- * @return instance
- */
- public static JSchUIServices getInstance(IRemoteServices services) {
- if (fInstance == null) {
- fInstance = new JSchUIServices(services);
- }
- return fInstance;
- }
-
- private final IRemoteServices fServices;
-
- public JSchUIServices(IRemoteServices services) {
- fServices = services;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getId()
- */
- @Override
- public String getId() {
- return fServices.getId();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getName()
- */
- @Override
- public String getName() {
- return fServices.getName();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getUIConnectionManager()
- */
- @Override
- public IRemoteUIConnectionManager getUIConnectionManager() {
- return new JSchUIConnectionManager(fServices);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ptp.remote.ui.IRemoteUIServicesDescriptor#getUIFileManager()
- */
- @Override
- public IRemoteUIFileManager getUIFileManager() {
- return new JSchUIFileManager();
- }
-}
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIServicesFactory.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIServicesFactory.java
deleted file mode 100644
index bacc32f74d5..00000000000
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUIServicesFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.jsch.ui;
-
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.ui.IRemoteUIServices;
-import org.eclipse.remote.ui.IRemoteUIServicesFactory;
-
-public class JSchUIServicesFactory implements IRemoteUIServicesFactory {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ptp.remote.ui.IRemoteUIServicesFactory#getServices(org.eclipse.ptp.remote.core.IRemoteServices)
- */
- public IRemoteUIServices getServices(IRemoteServices services) {
- return JSchUIServices.getInstance(services);
- }
-}
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUserAuthenticator.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUserAuthenticator.java
index 7f14b5c6384..646fa3a303d 100644
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUserAuthenticator.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/JSchUserAuthenticator.java
@@ -16,24 +16,35 @@ import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jsch.ui.UserInfoPrompter;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IUserAuthenticator;
+import org.eclipse.remote.core.IUserAuthenticatorService;
+import org.eclipse.remote.internal.jsch.core.JSchConnection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
-public class JSchUserAuthenticator implements IUserAuthenticator {
+public class JSchUserAuthenticator implements IUserAuthenticatorService {
+
+ private final IRemoteConnection remoteConnection;
private UserInfoPrompter prompter;
public JSchUserAuthenticator(IRemoteConnection conn) {
+ this.remoteConnection = conn;
try {
- prompter = new UserInfoPrompter(new JSch().getSession(conn.getUsername(), conn.getAddress()));
+ String username = conn.getAttribute(JSchConnection.USERNAME_ATTR);
+ String address = conn.getAttribute(JSchConnection.ADDRESS_ATTR);
+ prompter = new UserInfoPrompter(new JSch().getSession(username, address));
} catch (JSchException e) {
// Not allowed
}
}
+ @Override
+ public IRemoteConnection getRemoteConnection() {
+ return remoteConnection;
+ }
+
@Override
public PasswordAuthentication prompt(String username, String message) {
if (prompter.promptPassword(message)) {
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java
index 6cef7805c48..89ff0e951e8 100755
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionPage.java
@@ -15,16 +15,16 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionManager;
-import org.eclipse.remote.core.RemoteServices;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
+import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
import org.eclipse.remote.internal.jsch.core.Activator;
import org.eclipse.remote.internal.jsch.core.JSchConnection;
-import org.eclipse.remote.internal.jsch.core.JSchConnectionAttributes;
-import org.eclipse.remote.internal.jsch.core.JSchConnectionWorkingCopy;
import org.eclipse.remote.internal.jsch.ui.messages.Messages;
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
import org.eclipse.swt.SWT;
@@ -51,6 +51,7 @@ import org.eclipse.ui.forms.events.IExpansionListener;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
public class JSchConnectionPage extends WizardPage {
+
private class DataModifyListener implements ModifyListener {
@Override
public synchronized void modifyText(ModifyEvent e) {
@@ -72,18 +73,18 @@ public class JSchConnectionPage extends WizardPage {
private String fInitialName = "Remote Host"; //$NON-NLS-1$
private Set fInvalidConnectionNames;
private final Map fInitialAttributes = new HashMap();
- private JSchConnectionWorkingCopy fConnection;
+ private IRemoteConnectionWorkingCopy fConnection;
- private final IRemoteConnectionManager fConnectionManager;
+ private final IRemoteConnectionType fConnectionType;
private final DataModifyListener fDataModifyListener = new DataModifyListener();
private RemoteConnectionWidget fProxyConnectionWidget;
private Text fProxyCommandText;
private static final String PREFS_PAGE_ID_NET_PROXY = "org.eclipse.ui.net.NetPreferences"; //$NON-NLS-1$
- public JSchConnectionPage(IRemoteConnectionManager connMgr) {
+ public JSchConnectionPage(IRemoteConnectionType connectionType) {
super(Messages.JSchNewConnectionPage_New_Connection);
- fConnectionManager = connMgr;
+ fConnectionType = connectionType;
setPageComplete(false);
}
@@ -258,7 +259,12 @@ public class JSchConnectionPage extends WizardPage {
createAuthControls(authGroup);
createAdvancedControls(authGroup);
- loadValues();
+ try {
+ loadValues();
+ } catch (CoreException e) {
+ Activator.log(e.getStatus());
+ }
+
/*
* Register listeners after loading values so we don't trigger listeners
*/
@@ -312,7 +318,7 @@ public class JSchConnectionPage extends WizardPage {
link.setText(Messages.JSchConnectionPage_Help);
}
- public JSchConnectionWorkingCopy getConnection() {
+ public IRemoteConnectionWorkingCopy getConnection() {
return fConnection;
}
@@ -326,67 +332,69 @@ public class JSchConnectionPage extends WizardPage {
private boolean isInvalidName(String name) {
if (fConnection == null) {
if (fInvalidConnectionNames == null) {
- return fConnectionManager.getConnection(name) != null;
+ return fConnectionType.getConnection(name) != null;
}
return fInvalidConnectionNames.contains(name);
}
return false;
}
- private void loadValues() {
+ private void loadValues() throws CoreException {
+ IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
if (fConnection != null) {
fConnectionName.setText(fConnection.getName());
- fHostText.setText(fConnection.getAddress());
- fUserText.setText(fConnection.getUsername());
- fPortText.setText(Integer.toString(fConnection.getPort()));
- fTimeoutText.setText(Integer.toString(fConnection.getTimeout()));
- boolean isPwd = fConnection.isPasswordAuth();
+ fHostText.setText(fConnection.getAttribute(JSchConnection.ADDRESS_ATTR));
+ fUserText.setText(fConnection.getAttribute(JSchConnection.USERNAME_ATTR));
+ fPortText.setText(fConnection.getAttribute(JSchConnection.PORT_ATTR));
+ fTimeoutText.setText(fConnection.getAttribute(JSchConnection.TIMEOUT_ATTR));
+ String isPwdStr = fConnection.getAttribute(JSchConnection.IS_PASSWORD_ATTR);
+ boolean isPwd = isPwdStr != null && Boolean.parseBoolean(isPwdStr);
fPasswordButton.setSelection(isPwd);
fPublicKeyButton.setSelection(!isPwd);
if (isPwd) {
- fPasswordText.setText(fConnection.getPassword());
+ fPasswordText.setText(fConnection.getSecureAttribute(JSchConnection.PASSWORD_ATTR));
} else {
- fPassphraseText.setText(fConnection.getPassphrase());
+ fPassphraseText.setText(fConnection.getSecureAttribute(JSchConnection.PASSPHRASE_ATTR));
}
- fProxyCommandText.setText(fConnection.getProxyCommand());
- IRemoteConnection proxyConn = fConnection.getProxyConnection();
+ fProxyCommandText.setText(fConnection.getAttribute(JSchConnection.PROXYCOMMAND_ATTR));
+ JSchConnection proxyConn = fConnection.getService(JSchConnection.class).getProxyConnection();
if (proxyConn == null) {
- proxyConn = RemoteServices.getLocalServices().getConnectionManager()
- .getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME);
+ // Use local connection
+ fProxyConnectionWidget.setConnection(manager.getLocalConnectionType().getConnections().get(0));
+ } else {
+ fProxyConnectionWidget.setConnection(proxyConn.getRemoteConnection());
}
- fProxyConnectionWidget.setConnection(proxyConn);
} else {
fConnectionName.setText(fInitialName);
- String host = fInitialAttributes.get(JSchConnectionAttributes.ADDRESS_ATTR);
+ String host = fInitialAttributes.get(JSchConnection.ADDRESS_ATTR);
if (host != null) {
fHostText.setText(host);
}
- String username = fInitialAttributes.get(JSchConnectionAttributes.USERNAME_ATTR);
+ String username = fInitialAttributes.get(JSchConnection.USERNAME_ATTR);
if (username != null) {
fUserText.setText(username);
}
- String port = fInitialAttributes.get(JSchConnectionAttributes.PORT_ATTR);
+ String port = fInitialAttributes.get(JSchConnection.PORT_ATTR);
if (port != null) {
fPortText.setText(port);
}
- String timeout = fInitialAttributes.get(JSchConnectionAttributes.TIMEOUT_ATTR);
+ String timeout = fInitialAttributes.get(JSchConnection.TIMEOUT_ATTR);
if (timeout != null) {
fTimeoutText.setText(timeout);
}
- String isPwd = fInitialAttributes.get(JSchConnectionAttributes.IS_PASSWORD_ATTR);
+ String isPwd = fInitialAttributes.get(JSchConnection.IS_PASSWORD_ATTR);
if (isPwd != null) {
fPasswordButton.setSelection(Boolean.parseBoolean(isPwd));
}
- String password = fInitialAttributes.get(JSchConnectionAttributes.PASSWORD_ATTR);
+ String password = fInitialAttributes.get(JSchConnection.PASSWORD_ATTR);
if (password != null) {
fPasswordText.setText(password);
}
- String passphrase = fInitialAttributes.get(JSchConnectionAttributes.PASSPHRASE_ATTR);
+ String passphrase = fInitialAttributes.get(JSchConnection.PASSPHRASE_ATTR);
if (passphrase != null) {
fPassphraseText.setText(passphrase);
}
- fProxyConnectionWidget.setConnection(RemoteServices.getLocalServices().getConnectionManager()
- .getConnection(IRemoteConnectionManager.LOCAL_CONNECTION_NAME));
+ fProxyConnectionWidget.setConnection(manager.getLocalConnectionType().getConnections().get(0));
}
}
@@ -409,14 +417,14 @@ public class JSchConnectionPage extends WizardPage {
}
public void setAddress(String address) {
- fInitialAttributes.put(JSchConnectionAttributes.ADDRESS_ATTR, address);
+ fInitialAttributes.put(JSchConnection.ADDRESS_ATTR, address);
}
public void setAttributes(Map attributes) {
fInitialAttributes.putAll(attributes);
}
- public void setConnection(JSchConnectionWorkingCopy connection) {
+ public void setConnection(IRemoteConnectionWorkingCopy connection) {
fConnection = connection;
}
@@ -437,7 +445,7 @@ public class JSchConnectionPage extends WizardPage {
}
public void setPort(int port) {
- fInitialAttributes.put(JSchConnectionAttributes.PORT_ATTR, Integer.toString(port));
+ fInitialAttributes.put(JSchConnection.PORT_ATTR, Integer.toString(port));
}
private void setTextFieldWidthInChars(Text text, int chars) {
@@ -453,56 +461,34 @@ public class JSchConnectionPage extends WizardPage {
}
public void setUsername(String username) {
- fInitialAttributes.put(JSchConnectionAttributes.USERNAME_ATTR, username);
+ fInitialAttributes.put(JSchConnection.USERNAME_ATTR, username);
}
private void storeValues() {
if (fConnection == null) {
try {
- JSchConnection conn = (JSchConnection) fConnectionManager.newConnection(fConnectionName.getText().trim());
- fConnection = (JSchConnectionWorkingCopy) conn.getWorkingCopy();
+ fConnection = fConnectionType.newConnection(fConnectionName.getText().trim());
} catch (RemoteConnectionException e) {
Activator.log(e);
}
}
if (fConnection != null) {
- if (!fConnection.getName().equals(fConnectionName.getText().trim())) {
- fConnection.setName(fConnectionName.getText().trim());
- }
- if (!fConnection.getAddress().equals(fHostText.getText().trim())) {
- fConnection.setAddress(fHostText.getText().trim());
- }
- if (!fConnection.getUsername().equals(fUserText.getText().trim())) {
- fConnection.setUsername(fUserText.getText().trim());
- }
- if (!fConnection.getPassword().equals(fPasswordText.getText().trim())) {
- fConnection.setPassword(fPasswordText.getText().trim());
- }
- if (!fConnection.getPassphrase().equals(fPassphraseText.getText().trim())) {
- fConnection.setPassphrase(fPassphraseText.getText().trim());
- }
- if (fConnection.isPasswordAuth() != fPasswordButton.getSelection()) {
- fConnection.setIsPasswordAuth(fPasswordButton.getSelection());
- }
- int timeout = Integer.parseInt(fTimeoutText.getText().trim());
- if (fConnection.getTimeout() != timeout) {
- fConnection.setTimeout(timeout);
- }
- int port = Integer.parseInt(fPortText.getText().trim());
- if (fConnection.getPort() != port) {
- fConnection.setPort(port);
- }
- if (!fConnection.getProxyCommand().equals(fProxyCommandText.getText().trim())) {
- fConnection.setProxyCommand(fProxyCommandText.getText().trim());
- }
+ fConnection.setName(fConnectionName.getText().trim());
+ fConnection.setAttribute(JSchConnection.ADDRESS_ATTR, fHostText.getText().trim());
+ fConnection.setAttribute(JSchConnection.USERNAME_ATTR, fUserText.getText().trim());
+ fConnection.setSecureAttribute(JSchConnection.PASSWORD_ATTR, fPasswordText.getText().trim());
+ fConnection.setSecureAttribute(JSchConnection.PASSPHRASE_ATTR, fPassphraseText.getText().trim());
+ fConnection.setAttribute(JSchConnection.IS_PASSWORD_ATTR, Boolean.toString(fPasswordButton.getSelection()));
+ fConnection.setAttribute(JSchConnection.TIMEOUT_ATTR, fTimeoutText.getText().trim());
+ fConnection.setAttribute(JSchConnection.PORT_ATTR, fPortText.getText().trim());
+ fConnection.setAttribute(JSchConnection.PROXYCOMMAND_ATTR, fProxyCommandText.getText().trim());
IRemoteConnection proxyConnection = fProxyConnectionWidget.getConnection();
+ IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
String proxyConnectionName = ""; //$NON-NLS-1$
- if (proxyConnection != null && proxyConnection.getRemoteServices() != RemoteServices.getLocalServices()) {
+ if (proxyConnection != null && proxyConnection.getConnectionType() != manager.getLocalConnectionType()) {
proxyConnectionName = proxyConnection.getName();
}
- if (!fConnection.getProxyConnectionName().equals(proxyConnectionName)) {
- fConnection.setProxyConnectionName(proxyConnectionName);
- }
+ fConnection.setAttribute(JSchConnection.PROXYCONNECTION_ATTR, proxyConnectionName);
}
}
diff --git a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionWizard.java b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionWizard.java
index b768e9213dc..3383f1e4440 100755
--- a/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionWizard.java
+++ b/bundles/org.eclipse.remote.jsch.ui/src/org/eclipse/remote/internal/jsch/ui/wizards/JSchConnectionWizard.java
@@ -15,37 +15,27 @@ import java.util.Set;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.remote.core.IRemoteConnectionManager;
+import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
-import org.eclipse.remote.internal.jsch.core.JSchConnectionWorkingCopy;
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
import org.eclipse.swt.widgets.Shell;
public class JSchConnectionWizard extends Wizard implements IRemoteUIConnectionWizard {
+
private final Shell fShell;
private final JSchConnectionPage fPage;
- public JSchConnectionWizard(Shell shell, IRemoteConnectionManager connMgr) {
+ public JSchConnectionWizard(Shell shell, IRemoteConnectionType connectionType) {
fShell = shell;
- fPage = new JSchConnectionPage(connMgr);
+ fPage = new JSchConnectionPage(connectionType);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
@Override
public void addPages() {
super.addPages();
addPage(fPage);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#getWorkingCopy()
- */
public IRemoteConnectionWorkingCopy open() {
WizardDialog dialog = new WizardDialog(fShell, this);
dialog.setBlockOnOpen(true);
@@ -55,50 +45,31 @@ public class JSchConnectionWizard extends Wizard implements IRemoteUIConnectionW
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#performCancel()
- */
+ @Override
+ public IRemoteConnectionWorkingCopy getConnection() {
+ return fPage.getConnection();
+ }
+
@Override
public boolean performCancel() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
@Override
public boolean performFinish() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setConnection(org.eclipse.remote.core.IRemoteConnectionWorkingCopy)
- */
public void setConnection(IRemoteConnectionWorkingCopy connection) {
- fPage.setConnection((JSchConnectionWorkingCopy) connection);
+ fPage.setConnection(connection);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setConnectionName(java.lang.String)
- */
public void setConnectionName(String name) {
fPage.setConnectionName(name);
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIConnectionWizard#setInvalidConnectionNames(java.util.Set)
- */
public void setInvalidConnectionNames(Set names) {
fPage.setInvalidConnectionNames(names);
}
+
}
diff --git a/bundles/org.eclipse.remote.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.remote.ui/META-INF/MANIFEST.MF
index 5515186f105..21a994d8c0a 100644
--- a/bundles/org.eclipse.remote.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.remote.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.remote.ui;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 2.0.0.qualifier
Bundle-Activator: org.eclipse.remote.internal.ui.RemoteUIPlugin
Bundle-Vendor: %pluginProvider
Require-Bundle: org.eclipse.ui,
@@ -12,7 +12,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.remote.core,
org.eclipse.core.filesystem,
org.eclipse.core.resources,
- org.eclipse.ui.trace
+ org.eclipse.ui.trace,
+ org.eclipse.ui.navigator,
+ org.eclipse.core.expressions
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.remote.internal.ui;x-internal:=true,
diff --git a/bundles/org.eclipse.remote.ui/icons/new_wiz.gif b/bundles/org.eclipse.remote.ui/icons/new_wiz.gif
new file mode 100644
index 00000000000..7aea894d0b6
Binary files /dev/null and b/bundles/org.eclipse.remote.ui/icons/new_wiz.gif differ
diff --git a/bundles/org.eclipse.remote.ui/plugin.properties b/bundles/org.eclipse.remote.ui/plugin.properties
index 4a15de900f4..06336c3c29e 100644
--- a/bundles/org.eclipse.remote.ui/plugin.properties
+++ b/bundles/org.eclipse.remote.ui/plugin.properties
@@ -10,4 +10,11 @@
pluginName=Remote Services UI
pluginProvider=Eclipse PTP
RemoteDevPrefPage.name=Remote Development
-ConnectionsPreferencePage.name=Remote Connections
\ No newline at end of file
+ConnectionsPreferencePage.name=Remote Connections
+ConnectionsViewCategory.name=Connections
+ConnectionsView.name=Connections
+ConnectionsContent.name=Connections
+NewConnectionCommand.name=New Connection
+DeleteConnectionCommand.name=Delete Connection
+OpenTerminalCommand.name=Open Terminal
+ConnectionProperties.name=Connection
diff --git a/bundles/org.eclipse.remote.ui/plugin.xml b/bundles/org.eclipse.remote.ui/plugin.xml
index 4d605d28529..b1de474ad95 100644
--- a/bundles/org.eclipse.remote.ui/plugin.xml
+++ b/bundles/org.eclipse.remote.ui/plugin.xml
@@ -1,15 +1,6 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ name
diff --git a/bundles/org.eclipse.remote.ui/pom.xml b/bundles/org.eclipse.remote.ui/pom.xml
index 57570bbb584..851df2fb7b1 100644
--- a/bundles/org.eclipse.remote.ui/pom.xml
+++ b/bundles/org.eclipse.remote.ui/pom.xml
@@ -11,6 +11,6 @@
org.eclipse.remote.ui
- 1.1.0-SNAPSHOT
+ 2.0.0-SNAPSHOTeclipse-plugin
diff --git a/bundles/org.eclipse.remote.ui/schema/remoteUIServices.exsd b/bundles/org.eclipse.remote.ui/schema/remoteUIServices.exsd
deleted file mode 100644
index 06b64bf6b46..00000000000
--- a/bundles/org.eclipse.remote.ui/schema/remoteUIServices.exsd
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
-
- [Enter description of this extension point.]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Enter the first release in which this extension point appears.]
-
-
-
-
-
-
-
-
- [Enter extension point usage example here.]
-
-
-
-
-
-
-
-
- [Enter API information here.]
-
-
-
-
-
-
-
-
- [Enter information about supplied implementation of this extension point.]
-
-
-
-
-
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/Messages.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/Messages.java
new file mode 100644
index 00000000000..a98aa0636cf
--- /dev/null
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/Messages.java
@@ -0,0 +1,20 @@
+package org.eclipse.remote.internal.ui;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.remote.internal.ui.messages"; //$NON-NLS-1$
+ public static String NewRemoteConnectionTypePage_LaunchTargetType;
+ public static String NewRemoteConnectionTypePage_SelectTargetType;
+ public static String NewRemoteConnectionWizard_0;
+ public static String OpenTerminalHandler_OpenTerminalDesc;
+ public static String OpenTerminalHandler_OpenTerminalTitle;
+ public static String RemoteConnectionPropertyPage_ConnectionName;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/RemoteUIPlugin.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/RemoteUIPlugin.java
index 3df651febba..3173ec632aa 100644
--- a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/RemoteUIPlugin.java
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/RemoteUIPlugin.java
@@ -5,6 +5,7 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.remote.internal.ui.messages.Messages;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
/**
* The activator class controls the plug-in life cycle
@@ -70,6 +71,18 @@ public class RemoteUIPlugin extends AbstractUIPlugin {
log(new Status(IStatus.ERROR, getDefault().getBundle().getSymbolicName(), IStatus.ERROR, Messages.PTPRemoteUIPlugin_3, e));
}
+ /**
+ * Return the OSGi service with the given service interface.
+ *
+ * @param service service interface
+ * @return the specified service or null if it's not registered
+ */
+ public static T getService(Class service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
/**
* The constructor
*/
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/RemoteUIServicesDescriptor.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/RemoteUIServicesDescriptor.java
deleted file mode 100644
index 1117dac743a..00000000000
--- a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/RemoteUIServicesDescriptor.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.ui;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.internal.ui.messages.Messages;
-import org.eclipse.remote.ui.IRemoteUIServices;
-import org.eclipse.remote.ui.IRemoteUIServicesDescriptor;
-import org.eclipse.remote.ui.IRemoteUIServicesFactory;
-
-public class RemoteUIServicesDescriptor implements IRemoteUIServicesDescriptor {
- private static final String ATTR_ID = "id"; //$NON-NLS-1$
- private static final String ATTR_NAME = "name"; //$NON-NLS-1$
- private static final String ATTR_CLASS = "class"; //$NON-NLS-1$
-
- private static String getAttribute(IConfigurationElement configElement, String name, String defaultValue) {
- String value = configElement.getAttribute(name);
- if (value != null) {
- return value;
- }
- if (defaultValue != null) {
- return defaultValue;
- }
- throw new IllegalArgumentException(NLS.bind(Messages.RemoteUIServicesProxy_1, name));
- }
-
- private final IConfigurationElement configElement;
- private final String id;
- private final String name;
- private IRemoteUIServicesFactory fFactory = null;
- private IRemoteUIServices fDelegate = null;
-
- public RemoteUIServicesDescriptor(IConfigurationElement configElement) {
- this.configElement = configElement;
- this.id = getAttribute(configElement, ATTR_ID, null);
- this.name = getAttribute(configElement, ATTR_NAME, this.id);
- getAttribute(configElement, ATTR_CLASS, null);
- }
-
- /**
- * Get the factory from the plugin
- *
- * @return instance of the factory
- */
- public IRemoteUIServicesFactory getFactory() {
- if (fFactory != null) {
- return fFactory;
- }
- try {
- fFactory = (IRemoteUIServicesFactory) configElement.createExecutableExtension(ATTR_CLASS);
- } catch (Exception e) {
- RemoteUIPlugin.log(NLS.bind(Messages.RemoteUIServicesProxy_2, new Object[] { configElement.getAttribute(ATTR_CLASS),
- id, configElement.getDeclaringExtension().getNamespaceIdentifier() }));
- }
- return fFactory;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getId()
- */
- public String getId() {
- return id;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.core.IRemoteServices#getName()
- */
- public String getName() {
- return name;
- }
-
- /**
- * Get the remote UI services implementation for this descriptor.
- *
- * @return the remote UI services implementation, or null if initialization failed
- */
- public IRemoteUIServices getUIServices(IRemoteServices services) {
- loadServices(services);
- return fDelegate;
- }
-
- /**
- * Create and initialize the remote UI services factory
- */
- private void loadServices(IRemoteServices services) {
- if (fDelegate == null) {
- IRemoteUIServicesFactory factory = getFactory();
- if (factory != null) {
- fDelegate = factory.getServices(services);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/ServicePropertyTester.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/ServicePropertyTester.java
new file mode 100644
index 00000000000..e11a355517c
--- /dev/null
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/ServicePropertyTester.java
@@ -0,0 +1,41 @@
+package org.eclipse.remote.internal.ui;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+
+public class ServicePropertyTester extends PropertyTester {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (receiver instanceof IRemoteConnection) {
+ IRemoteConnection connection = (IRemoteConnection) receiver;
+ if (property.equals("hasConnectionTypeService")) { //$NON-NLS-1$
+ if (args.length > 0 && args[0] instanceof String) {
+ String serviceName = (String) args[0];
+ try {
+ Class> service = Class.forName(serviceName);
+ return connection.getConnectionType().hasService((Class) service);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+ } else if (property.equals("hasConnectionService")) { //$NON-NLS-1$
+ if (args.length > 0 && args[0] instanceof String) {
+ String serviceName = (String) args[0];
+ try {
+ Class> service = Class.forName(serviceName);
+ return connection.hasService((Class) service);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+ } else if (property.equals("canDelete")) { //$NON-NLS-1$
+ return (connection.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_REMOVE_CONNECTIONS) != 0;
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/messages.properties b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/messages.properties
new file mode 100644
index 00000000000..26212f3755b
--- /dev/null
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/messages.properties
@@ -0,0 +1,6 @@
+NewRemoteConnectionTypePage_LaunchTargetType=Launch Target Type
+NewRemoteConnectionTypePage_SelectTargetType=Select type of launch target to create.
+NewRemoteConnectionWizard_0=Launch Target Type
+OpenTerminalHandler_OpenTerminalDesc=A real terminal would open now
+OpenTerminalHandler_OpenTerminalTitle=Open Terminal
+RemoteConnectionPropertyPage_ConnectionName=Connection Name:
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/ConnectionsPreferencePage.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/ConnectionsPreferencePage.java
index 7da4f298e2c..def2e77dd59 100644
--- a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/ConnectionsPreferencePage.java
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/ConnectionsPreferencePage.java
@@ -28,19 +28,17 @@ import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.core.IRemoteConnectionManager;
+import org.eclipse.remote.core.IRemoteConnectionControlService;
+import org.eclipse.remote.core.IRemoteConnectionType;
import org.eclipse.remote.core.IRemoteConnectionWorkingCopy;
import org.eclipse.remote.core.IRemotePreferenceConstants;
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.core.RemoteServices;
+import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.exception.RemoteConnectionException;
-import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
-import org.eclipse.remote.internal.core.RemoteServicesImpl;
import org.eclipse.remote.internal.core.preferences.Preferences;
+import org.eclipse.remote.internal.ui.RemoteUIPlugin;
import org.eclipse.remote.internal.ui.messages.Messages;
-import org.eclipse.remote.ui.IRemoteUIConnectionManager;
+import org.eclipse.remote.ui.IRemoteUIConnectionService;
import org.eclipse.remote.ui.IRemoteUIConnectionWizard;
-import org.eclipse.remote.ui.RemoteUIServices;
import org.eclipse.remote.ui.widgets.RemoteConnectionWidget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
@@ -112,10 +110,10 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
return connection.isOpen() ? Messages.ConnectionsPreferencePage_open : Messages.ConnectionsPreferencePage_closed;
case 1:
return connection.getName();
- case 2:
- return connection.getAddress();
- case 3:
- return connection.getUsername();
+// case 2:
+// return connection.getAttribute(IRemoteConnection.ADDRESS_ATTR);
+// case 3:
+// return connection.getAttribute(IRemoteConnection.USERNAME_ATTR);
}
return null;
}
@@ -188,8 +186,8 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
private String[] fServiceIDs;
private boolean fIsDirty;
private IRemoteConnection fSelectedConnection;
- private IRemoteConnectionManager fConnectionManager;
- private IRemoteUIConnectionManager fUIConnectionManager;
+ private IRemoteConnectionType fConnectionType;
+ private IRemoteUIConnectionService fUIConnectionManager;
private final Map fWorkingCopies = new HashMap();
@@ -214,7 +212,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
if (fIsDirty) {
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions, null,
Messages.ConnectionsPreferencePage_There_are_unsaved_changes, MessageDialog.QUESTION, new String[] {
- IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
+ IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
if (dialog.open() == 1) {
return;
}
@@ -263,12 +261,18 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
label.setLayoutData(new GridData());
fServicesCombo = new Combo(selectComp, SWT.READ_ONLY);
label.setLayoutData(new GridData());
- List descriptors = RemoteServicesImpl.getRemoteServiceDescriptors();
- String[] names = new String[descriptors.size()];
- fServiceIDs = new String[descriptors.size()];
- for (int i = 0; i < descriptors.size(); i++) {
- names[i] = descriptors.get(i).getName();
- fServiceIDs[i] = descriptors.get(i).getId();
+
+ IRemoteServicesManager manager = RemoteUIPlugin.getService(IRemoteServicesManager.class);
+ List services = manager.getRemoteConnectionTypes();
+ String[] names = new String[services.size()];
+ fServiceIDs = new String[services.size()];
+ {
+ int i = 0;
+ for (IRemoteConnectionType s : services) {
+ names[i] = s.getName();
+ fServiceIDs[i] = s.getId();
+ i++;
+ }
}
fServicesCombo.addSelectionListener(fEventHandler);
fServicesCombo.setItems(names);
@@ -287,8 +291,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
fConnectionTable.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
- if (fSelectedConnection != null && !getOriginalIfClean(fSelectedConnection).isOpen()) {
- editConnection();
+ if (fSelectedConnection != null) {
+ IRemoteConnection original = getOriginalIfClean(fSelectedConnection);
+ if (original.isOpen()) {
+ editConnection();
+ }
}
}
@@ -404,7 +411,7 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
private void initWorkingConnections() {
fWorkingCopies.clear();
- for (IRemoteConnection conn : fConnectionManager.getConnections()) {
+ for (IRemoteConnection conn : fConnectionType.getConnections()) {
fWorkingCopies.put(conn.getName(), conn);
}
}
@@ -467,13 +474,13 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
}
private void selectServices(String id) {
- IRemoteServices services = RemoteServices.getRemoteServices(id);
- if (services != null) {
- fConnectionManager = services.getConnectionManager();
- fUIConnectionManager = RemoteUIServices.getRemoteUIServices(services).getUIConnectionManager();
+ IRemoteServicesManager manager = RemoteUIPlugin.getService(IRemoteServicesManager.class);
+ fConnectionType = manager.getConnectionType(id);
+ if (fConnectionType != null) {
+ fUIConnectionManager = fConnectionType.getService(IRemoteUIConnectionService.class);
initWorkingConnections();
fConnectionViewer.refresh();
- fAddButton.setEnabled((services.getCapabilities() & IRemoteServices.CAPABILITY_ADD_CONNECTIONS) != 0);
+ fAddButton.setEnabled((fConnectionType.getCapabilities() & IRemoteConnectionType.CAPABILITY_ADD_CONNECTIONS) != 0);
}
fIsDirty = false;
}
@@ -485,12 +492,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
TableItem[] items = fConnectionTable.getSelection();
if (items.length > 0) {
IRemoteConnection conn = getOriginalIfClean((IRemoteConnection) items[0].getData());
- if (conn.isOpen()) {
+ if (conn.hasService(IRemoteConnectionControlService.class) && conn.isOpen()) {
conn.close();
} else {
if (conn instanceof IRemoteConnectionWorkingCopy) {
IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn;
- conn = wc.getOriginal();
if (wc.isDirty()) {
MessageDialog dialog = new MessageDialog(getShell(), Messages.ConnectionsPreferencePage_Confirm_Actions,
null, Messages.ConnectionsPreferencePage_This_connection_contains_unsaved_changes,
@@ -498,15 +504,18 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
if (dialog.open() == 1) {
return;
}
- wc.save();
+ try {
+ conn = wc.save();
+ } catch (RemoteConnectionException e) {
+ RemoteUIPlugin.log(e);
+ }
/*
* Replace working copy with original so that the correct version will be used in the future
*/
fWorkingCopies.put(conn.getName(), conn);
}
}
- IRemoteUIConnectionManager mgr = RemoteUIServices.getRemoteUIServices(conn.getRemoteServices())
- .getUIConnectionManager();
+ IRemoteUIConnectionService mgr = conn.getConnectionType().getService(IRemoteUIConnectionService.class);
if (mgr != null) {
mgr.openConnectionWithProgress(getShell(), null, conn);
}
@@ -523,10 +532,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
/*
* Remove any deleted connections
*/
- for (IRemoteConnection conn : fConnectionManager.getConnections()) {
- if (!fWorkingCopies.containsKey(conn.getName()) && !conn.isOpen()) {
+ for (IRemoteConnection conn : fConnectionType.getConnections()) {
+ if (!fWorkingCopies.containsKey(conn.getName()) &&
+ (!conn.hasService(IRemoteConnectionControlService.class) || !conn.isOpen())) {
try {
- fConnectionManager.removeConnection(conn);
+ fConnectionType.removeConnection(conn);
} catch (RemoteConnectionException e) {
// Ignore
}
@@ -539,7 +549,11 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
if (conn instanceof IRemoteConnectionWorkingCopy) {
IRemoteConnectionWorkingCopy wc = (IRemoteConnectionWorkingCopy) conn;
if (wc.isDirty()) {
- wc.save();
+ try {
+ wc.save();
+ } catch (RemoteConnectionException e) {
+ RemoteUIPlugin.log(e);
+ }
}
}
}
@@ -553,14 +567,16 @@ public class ConnectionsPreferencePage extends PreferencePage implements IWorkbe
fCloseButton.setEnabled(false);
if (fSelectedConnection != null) {
IRemoteConnection conn = getOriginalIfClean(fSelectedConnection);
- if (!conn.isOpen()) {
- fEditButton
- .setEnabled((conn.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_EDIT_CONNECTIONS) != 0);
- fRemoveButton
- .setEnabled((conn.getRemoteServices().getCapabilities() & IRemoteServices.CAPABILITY_REMOVE_CONNECTIONS) != 0);
- fOpenButton.setEnabled(true);
+ if (conn.hasService(IRemoteConnectionControlService.class)) {
+ if (!conn.isOpen()) {
+ fEditButton.setEnabled((conn.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_EDIT_CONNECTIONS) != 0);
+ fRemoveButton.setEnabled((conn.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_REMOVE_CONNECTIONS) != 0);
+ fOpenButton.setEnabled(true);
+ } else {
+ fCloseButton.setEnabled(true);
+ }
} else {
- fCloseButton.setEnabled(true);
+ fEditButton.setEnabled((conn.getConnectionType().getCapabilities() & IRemoteConnectionType.CAPABILITY_EDIT_CONNECTIONS) != 0);
}
}
}
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/RemoteDevelopmentPreferencePage.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/RemoteDevelopmentPreferencePage.java
index 6877fba0c74..476d3909295 100644
--- a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/RemoteDevelopmentPreferencePage.java
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/preferences/RemoteDevelopmentPreferencePage.java
@@ -17,8 +17,9 @@ import java.util.List;
import org.eclipse.jface.preference.ComboFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.remote.core.IRemotePreferenceConstants;
-import org.eclipse.remote.internal.core.RemoteServicesDescriptor;
-import org.eclipse.remote.internal.core.RemoteServicesImpl;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteServicesManager;
+import org.eclipse.remote.internal.ui.RemoteUIPlugin;
import org.eclipse.remote.internal.ui.messages.Messages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
@@ -46,7 +47,8 @@ public class RemoteDevelopmentPreferencePage extends FieldEditorPreferencePage i
nameAndValue[1] = ""; //$NON-NLS-1$
namesAndValues.add(nameAndValue);
- for (RemoteServicesDescriptor service : RemoteServicesImpl.getRemoteServiceDescriptors()) {
+ IRemoteServicesManager manager = RemoteUIPlugin.getService(IRemoteServicesManager.class);
+ for (IRemoteConnectionType service : manager.getRemoteConnectionTypes()) {
nameAndValue = new String[2];
nameAndValue[0] = service.getName();
nameAndValue[1] = service.getId();
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIFileManager.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIFileService.java
similarity index 80%
rename from bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIFileManager.java
rename to bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIFileService.java
index d22f7bd34fe..cfe33f0ba06 100644
--- a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIFileManager.java
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIFileService.java
@@ -15,15 +15,38 @@ import java.util.Arrays;
import java.util.List;
import org.eclipse.remote.core.IRemoteConnection;
-import org.eclipse.remote.ui.IRemoteUIFileManager;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.IRemoteConnectionType.Service;
+import org.eclipse.remote.ui.IRemoteUIFileService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
-public class LocalUIFileManager implements IRemoteUIFileManager {
+public class LocalUIFileService implements IRemoteUIFileService {
+ private final IRemoteConnectionType connectionType;
private IRemoteConnection connection = null;
+ public LocalUIFileService(IRemoteConnectionType connectionType) {
+ this.connectionType = connectionType;
+ }
+
+ public static class Factory implements IRemoteConnectionType.Service.Factory {
+ @SuppressWarnings("unchecked")
+ @Override
+ public T getService(IRemoteConnectionType connectionType, Class service) {
+ if (IRemoteUIFileService.class.equals(service)) {
+ return (T) new LocalUIFileService(connectionType);
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public IRemoteConnectionType getConnectionType() {
+ return connectionType;
+ }
+
/*
* (non-Javadoc)
*
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIServices.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIServices.java
deleted file mode 100644
index 6977175a162..00000000000
--- a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIServices.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.ui.services.local;
-
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.ui.IRemoteUIConnectionManager;
-import org.eclipse.remote.ui.IRemoteUIFileManager;
-import org.eclipse.remote.ui.IRemoteUIServices;
-
-public class LocalUIServices implements IRemoteUIServices {
- private static LocalUIServices fInstance = null;
- private final static LocalUIFileManager fFileMgr = new LocalUIFileManager();
-
- /**
- * Get shared instance of this class
- *
- * @return instance
- */
- public static LocalUIServices getInstance(IRemoteServices services) {
- if (fInstance == null) {
- fInstance = new LocalUIServices(services);
- }
- return fInstance;
- }
-
- private final IRemoteServices fServices;
-
- public LocalUIServices(IRemoteServices services) {
- fServices = services;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getId()
- */
- public String getId() {
- return fServices.getId();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getName()
- */
- public String getName() {
- return fServices.getName();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getUIConnectionManager(org.eclipse.remote.core.IRemoteConnectionManager)
- */
- public IRemoteUIConnectionManager getUIConnectionManager() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIServicesDescriptor#getUIFileManager(org.eclipse.remote.core.IRemoteConnection)
- */
- public IRemoteUIFileManager getUIFileManager() {
- return fFileMgr;
- }
-}
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIServicesFactory.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIServicesFactory.java
deleted file mode 100644
index 55ed14c8d07..00000000000
--- a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/services/local/LocalUIServicesFactory.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * 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
- *
- * Contributors:
- * IBM Corporation - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.remote.internal.ui.services.local;
-
-import org.eclipse.remote.core.IRemoteServices;
-import org.eclipse.remote.ui.IRemoteUIServices;
-import org.eclipse.remote.ui.IRemoteUIServicesFactory;
-
-public class LocalUIServicesFactory implements IRemoteUIServicesFactory {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.remote.ui.IRemoteUIServicesFactory#getServices(org.eclipse.remote.core.IRemoteServices)
- */
- public IRemoteUIServices getServices(IRemoteServices services) {
- return LocalUIServices.getInstance(services);
- }
-}
diff --git a/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/views/DeleteRemoteConnectionHandler.java b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/views/DeleteRemoteConnectionHandler.java
new file mode 100644
index 00000000000..b962ba9ab23
--- /dev/null
+++ b/bundles/org.eclipse.remote.ui/src/org/eclipse/remote/internal/ui/views/DeleteRemoteConnectionHandler.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2015 QNX Software Systems and others.
+ * 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
+ *
+ * Contributors:
+ * QNX - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.remote.internal.ui.views;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteConnectionType;
+import org.eclipse.remote.core.exception.RemoteConnectionException;
+import org.eclipse.remote.internal.ui.RemoteUIPlugin;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public class DeleteRemoteConnectionHandler extends AbstractHandler {
+
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
+ if (selection != null && selection instanceof IStructuredSelection) {
+ // Get the manageable connections from the selection
+ List connections = new ArrayList();
+ @SuppressWarnings("unchecked")
+ Iterator