Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2015-02-23 21:54:00 +0000
committerBernd Hufmann2015-02-27 12:14:26 +0000
commitd8a4fd6076219380e90975d1b7278e5a4e3601cc (patch)
tree7c4140fd397a4e9cf519312124038ccaea475ec1 /org.eclipse.tracecompass.tmf.remote.core
parentec6196150b4cb20ca29e40a016f8c1fa1ba84ae3 (diff)
downloadorg.eclipse.tracecompass-d8a4fd6076219380e90975d1b7278e5a4e3601cc.tar.gz
org.eclipse.tracecompass-d8a4fd6076219380e90975d1b7278e5a4e3601cc.tar.xz
org.eclipse.tracecompass-d8a4fd6076219380e90975d1b7278e5a4e3601cc.zip
tmf-remote: Bug 460842: clean-up RemoteSystemProxy API
Change-Id: Iaac555117a8d0099d4d5e8ab712c9ff72c322bcd Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com> Reviewed-on: https://git.eclipse.org/r/42538 Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-by: Hudson CI Reviewed-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im> Tested-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Diffstat (limited to 'org.eclipse.tracecompass.tmf.remote.core')
-rw-r--r--org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/IRemoteSystemProxy.java105
-rw-r--r--org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/RemoteSystemProxy.java107
2 files changed, 81 insertions, 131 deletions
diff --git a/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/IRemoteSystemProxy.java b/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/IRemoteSystemProxy.java
deleted file mode 100644
index 20ec69e63d..0000000000
--- a/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/IRemoteSystemProxy.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2012, 2015 Ericsson
- *
- * 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:
- * Bernd Hufmann - Initial API and implementation
- * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
- * Bernd Hufmann - Update to org.eclipse.remote API 2.0
- **********************************************************************/
-package org.eclipse.tracecompass.tmf.remote.core.proxy;
-
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.remote.core.IRemoteConnectionChangeListener;
-import org.eclipse.remote.core.IRemoteFileService;
-import org.eclipse.remote.core.IRemoteProcessBuilder;
-import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
-
-/**
- * <p>
- * Remote System Proxy interface.
- * </p>
- *
- * @author Bernd Hufmann
- */
-public interface IRemoteSystemProxy {
-
- // ------------------------------------------------------------------------
- // Operations
- // ------------------------------------------------------------------------
-
- /**
- * Finds the File Service Subsystem.
- *
- * @return file service subsystem, or <code>null</code> if not found.
- */
- IRemoteFileService getRemoteFileService();
-
- /**
- * Returns a remote process builder for remote launching a process.
- * @param command the command to be executed.
- * @return the builder, or <code>null</code> if not possible.
- */
- IRemoteProcessBuilder getProcessBuilder(String...command);
-
- /**
- * Connects the shell service sub system.
- * @param monitor a monitor to report progress.
- *
- * @param callback
- * - call-back method being called when connection was finished
- * @throws ExecutionException
- * If the connection fails
- */
- void connect(IProgressMonitor monitor) throws ExecutionException;
-
- /**
- * Disconnects from the shell service sub system.
- *
- * @throws ExecutionException
- * If the disconnect command fails
- */
- void disconnect() throws ExecutionException;
-
- /**
- * Disposes the proxy, may close the connection.
- */
- void dispose();
-
- /**
- * Creates a command shell.
- *
- * @return the command shell implementation
- * @throws ExecutionException
- * If the command fails
- */
- ICommandShell createCommandShell() throws ExecutionException;
-
- /**
- * Method to add a communication listener to the connector service defined
- * for the given connection.
- *
- * @param listener
- * - listener to add
- */
- void addConnectionChangeListener(IRemoteConnectionChangeListener listener);
-
- /**
- * Method to remove a communication listener from the connector service
- * defined for the given connection.
- *
- * @param listener
- * - listener to remove
- */
- void removeConnectionChangeListener(IRemoteConnectionChangeListener listener);
-
- /**
- * @return whether the remote host is currently connected.
- */
- boolean isConnected();
-}
diff --git a/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/RemoteSystemProxy.java b/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/RemoteSystemProxy.java
index 9280a9c1d0..0209d376f5 100644
--- a/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/RemoteSystemProxy.java
+++ b/org.eclipse.tracecompass.tmf.remote.core/src/org/eclipse/tracecompass/tmf/remote/core/proxy/RemoteSystemProxy.java
@@ -15,7 +15,7 @@ package org.eclipse.tracecompass.tmf.remote.core.proxy;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnectionChangeListener;
@@ -26,15 +26,14 @@ import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.core.IRemoteServicesManager;
import org.eclipse.remote.core.RemoteConnectionChangeEvent;
import org.eclipse.remote.core.exception.RemoteConnectionException;
+import org.eclipse.tracecompass.internal.tmf.remote.core.Activator;
+import org.eclipse.tracecompass.tmf.remote.core.shell.CommandShell;
+import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
-import org.eclipse.tracecompass.internal.tmf.remote.core.Activator;
-import org.eclipse.tracecompass.tmf.remote.core.shell.CommandShell;
-import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
-
/**
* <p>
* RemoteSystemProxy implementation.
@@ -42,7 +41,8 @@ import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandShell;
*
* @author Bernd Hufmann
*/
-public class RemoteSystemProxy implements IRemoteSystemProxy, IRemoteConnectionChangeListener {
+@NonNullByDefault
+public class RemoteSystemProxy implements IRemoteConnectionChangeListener {
/** Name of a local connection */
public static final String LOCAL_CONNECTION_NAME = "Local"; //$NON-NLS-1$
@@ -68,21 +68,48 @@ public class RemoteSystemProxy implements IRemoteSystemProxy, IRemoteConnectionC
fHost.addConnectionChangeListener(this);
}
+ /**
+ * Returns the connection instance.
+ *
+ * @return the @link{IRemoteConnection} instance
+ */
+ public IRemoteConnection getRemoteConnection() {
+ return fHost;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
- @Override
- public IRemoteFileService getRemoteFileService() {
+ /**
+ * Finds the remote file system service.
+ *
+ * @return file service subsystem, or <code>null</code> if not found.
+ */
+ public @Nullable IRemoteFileService getRemoteFileService() {
return fHost.getService(IRemoteFileService.class);
}
- @Override
- public IRemoteProcessBuilder getProcessBuilder(String...command) {
+ /**
+ * Returns a remote process builder for remote launching a process.
+ *
+ * @param command
+ * the command to be executed.
+ * @return the builder, or <code>null</code> if not possible.
+ */
+ public @Nullable IRemoteProcessBuilder getProcessBuilder(String...command) {
return fHost.getService(IRemoteProcessService.class).getProcessBuilder(command);
}
- @Override
+ /**
+ * Connects the remote connection.
+ *
+ * @param monitor
+ * a monitor to report progress.
+ *
+ * @throws ExecutionException
+ * If the connection fails
+ */
public void connect(IProgressMonitor monitor) throws ExecutionException {
try {
if (!fHost.isOpen()) {
@@ -94,12 +121,16 @@ public class RemoteSystemProxy implements IRemoteSystemProxy, IRemoteConnectionC
}
}
- @Override
- public void disconnect() throws ExecutionException {
+ /**
+ * Disconnects from the remote connection.
+ */
+ public void disconnect() {
fHost.close();
}
- @Override
+ /**
+ * Disposes the proxy, may close the connection.
+ */
public void dispose() {
fHost.removeConnectionChangeListener(this);
if (fExplicitConnect) {
@@ -107,34 +138,58 @@ public class RemoteSystemProxy implements IRemoteSystemProxy, IRemoteConnectionC
}
}
- @Override
+ /**
+ * Creates a command shell.
+ *
+ * @return the command shell implementation
+ * @throws ExecutionException
+ * If the command fails
+ */
public ICommandShell createCommandShell() throws ExecutionException {
ICommandShell shell = new CommandShell(fHost);
shell.connect();
return shell;
}
- @Override
+ /**
+ * Method to add a communication listener to the connector service defined
+ * for the given connection.
+ *
+ * @param listener
+ * listener to add
+ */
public void addConnectionChangeListener(IRemoteConnectionChangeListener listener) {
fHost.addConnectionChangeListener(listener);
}
- @Override
+ /**
+ * Method to remove a communication listener from the connector service
+ * defined for the given connection.
+ *
+ * @param listener
+ * listener to remove
+ */
public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener) {
fHost.removeConnectionChangeListener(listener);
}
- @Override
+ /**
+ * Returns the connection state.
+ *
+ * @return whether the remote host is currently connected.
+ */
public boolean isConnected() {
return fHost.isOpen();
}
@Override
- public void connectionChanged(RemoteConnectionChangeEvent event) {
- int type = event.getType();
- if (type == RemoteConnectionChangeEvent.CONNECTION_ABORTED ||
- type == RemoteConnectionChangeEvent.CONNECTION_CLOSED) {
- fExplicitConnect = false;
+ public void connectionChanged(@Nullable RemoteConnectionChangeEvent event) {
+ if (event != null) {
+ int type = event.getType();
+ if (type == RemoteConnectionChangeEvent.CONNECTION_ABORTED ||
+ type == RemoteConnectionChangeEvent.CONNECTION_CLOSED) {
+ fExplicitConnect = false;
+ }
}
}
@@ -158,7 +213,7 @@ public class RemoteSystemProxy implements IRemoteSystemProxy, IRemoteConnectionC
* name of connection
* @return the corresponding remote connection or null
*/
- public static @Nullable IRemoteConnection getRemoteConnection(final @NonNull String remoteServicesId, final @NonNull String name) {
+ public static @Nullable IRemoteConnection getRemoteConnection(final String remoteServicesId, final String name) {
IRemoteServicesManager manager = Activator.getService(IRemoteServicesManager.class);
if (manager == null) {
return null;
@@ -166,8 +221,8 @@ public class RemoteSystemProxy implements IRemoteSystemProxy, IRemoteConnectionC
FluentIterable<IRemoteConnection> connections = FluentIterable.from(manager.getAllRemoteConnections());
Optional<IRemoteConnection> ret = connections.firstMatch(new Predicate<IRemoteConnection>() {
@Override
- public boolean apply(IRemoteConnection input) {
- return (input.getConnectionType().getId().equals(remoteServicesId.toString()) && input.getName().equals(name.toString()));
+ public boolean apply(@Nullable IRemoteConnection input) {
+ return ((input != null) && input.getConnectionType().getId().equals(remoteServicesId.toString()) && input.getName().equals(name.toString()));
}
});
return ret.orNull();

Back to the top