1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
12 **********************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.remote
;
15 import org
.eclipse
.core
.commands
.ExecutionException
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.remote
.core
.IRemoteConnection
;
18 import org
.eclipse
.remote
.core
.IRemoteConnectionChangeEvent
;
19 import org
.eclipse
.remote
.core
.IRemoteConnectionChangeListener
;
20 import org
.eclipse
.remote
.core
.IRemoteFileManager
;
21 import org
.eclipse
.remote
.core
.IRemoteProcessBuilder
;
22 import org
.eclipse
.remote
.core
.exception
.RemoteConnectionException
;
26 * RemoteSystemProxy implementation.
29 * @author Bernd Hufmann
31 public class RemoteSystemProxy
implements IRemoteSystemProxy
, IRemoteConnectionChangeListener
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 private IRemoteConnection fHost
;
38 private boolean fExplicitConnect
;
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
48 * The host of this proxy
50 public RemoteSystemProxy(IRemoteConnection host
) {
52 fHost
.addConnectionChangeListener(this);
55 // ------------------------------------------------------------------------
57 // ------------------------------------------------------------------------
60 public IRemoteFileManager
getFileServiceSubSystem() {
61 return fHost
.getFileManager();
65 public IRemoteProcessBuilder
getProcessBuilder(String
...command
) {
66 return fHost
.getProcessBuilder(command
);
70 public void connect(IProgressMonitor monitor
) throws ExecutionException
{
72 if (!fHost
.isOpen()) {
73 fExplicitConnect
= true;
76 } catch (RemoteConnectionException e
) {
77 throw new ExecutionException("Cannot connect " + fHost
.getName(), e
); //$NON-NLS-1$
82 public void disconnect() throws ExecutionException
{
87 public void dispose() {
88 fHost
.removeConnectionChangeListener(this);
89 if (fExplicitConnect
) {
95 public ICommandShell
createCommandShell() throws ExecutionException
{
96 ICommandShell shell
= new CommandShell(fHost
);
102 public void addConnectionChangeListener(IRemoteConnectionChangeListener listener
) {
103 fHost
.addConnectionChangeListener(listener
);
107 public void removeConnectionChangeListener(IRemoteConnectionChangeListener listener
) {
108 fHost
.removeConnectionChangeListener(listener
);
112 public boolean isConnected() {
113 return fHost
.isOpen();
117 public void connectionChanged(IRemoteConnectionChangeEvent event
) {
118 int type
= event
.getType();
119 if (type
== IRemoteConnectionChangeEvent
.CONNECTION_ABORTED
||
120 type
== IRemoteConnectionChangeEvent
.CONNECTION_CLOSED
) {
121 fExplicitConnect
= false;