| author | Corey Ashford | 2011-11-21 20:46:03 (EST) |
|---|---|---|
| committer | Jeff Johnston | 2012-01-20 18:21:52 (EST) |
| commit | 7e17e752d40205a6a96d9a6b9e6d82d9ce4e0e9d (patch) (side-by-side diff) | |
| tree | 1cf2bf7da2bd2a0f2facdbdc37486ef2df15dc2a | |
| parent | d44ad77b87ecfc5d278669f826da1ee14f4af60c (diff) | |
| download | org.eclipse.linuxtools-7e17e752d40205a6a96d9a6b9e6d82d9ce4e0e9d.zip org.eclipse.linuxtools-7e17e752d40205a6a96d9a6b9e6d82d9ce4e0e9d.tar.gz org.eclipse.linuxtools-7e17e752d40205a6a96d9a6b9e6d82d9ce4e0e9d.tar.bz2 | |
Add ability to create the proxy using a URI in addition to an IProject
In order to implement the RemoteConnection class in terms of this proxy,
we need to have the ability to create a proxy based upon the URI of
an executable, which may reside on a remote machine, but not the machine
where the project is located. A similar situation occurs when downloading
a locally-built executable to a remote machine to run it. In these cases
we need to access a remote file system which is not related to where the
project is located.
In addition to these changes, I also sprinkled in a few @Override annotations
on the methods of classes that implement an interface. Note that I was
not able to do this on the methods in org.eclipse.linuxtools.rdt.proxy
because it uses Java 1.5 instead of 1.6, where @Override is not allowed
on methods which directly implement an interface (i.e. not from a superclass).
Signed-off-by: Corey Ashford <cjashfor@linux.vnet.ibm.com>
5 files changed, 90 insertions, 26 deletions
diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteProxyManager.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteProxyManager.java index 9b63e19..1af3ee7 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteProxyManager.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/IRemoteProxyManager.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.linuxtools.profiling.launch; +import java.net.URI; + import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -18,6 +20,9 @@ public interface IRemoteProxyManager { String MANAGER_NAME = "manager"; //$NON-NLS-1$ String SCHEME_ID = "scheme"; //$NON-NLS-1$ public IRemoteFileProxy getFileProxy(IProject project) throws CoreException; + public IRemoteFileProxy getFileProxy(URI uri) throws CoreException; public IRemoteCommandLauncher getLauncher(IProject project) throws CoreException; + public IRemoteCommandLauncher getLauncher(URI uri) throws CoreException; public String getOS(IProject project) throws CoreException; + public String getOS(URI uri) throws CoreException; } diff --git a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java index 4a158f7..8873227 100644 --- a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java +++ b/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java @@ -69,37 +69,49 @@ public class RemoteProxyManager implements IRemoteProxyManager { } return remoteManager; } - - public IRemoteFileProxy getFileProxy(IProject project) throws CoreException { - URI projectURI = project.getLocationURI(); - String scheme = projectURI.getScheme(); - if (scheme != null && !LocalHost.equals(projectURI.getHost())) { + + public IRemoteFileProxy getFileProxy(URI uri) throws CoreException { + String scheme = uri.getScheme(); + if (scheme != null && !LocalHost.equals(uri.getHost())) { IRemoteProxyManager manager = getRemoteManager(scheme); if (manager != null) - return manager.getFileProxy(project); + return manager.getFileProxy(uri); } return getLocalFileProxy(); } - - public IRemoteCommandLauncher getLauncher(IProject project) throws CoreException { + + public IRemoteFileProxy getFileProxy(IProject project) throws CoreException { URI projectURI = project.getLocationURI(); - String scheme = projectURI.getScheme(); - if (scheme != null && !LocalHost.equals(projectURI.getHost())) { + return getFileProxy(projectURI); + } + + public IRemoteCommandLauncher getLauncher(URI uri) throws CoreException { + String scheme = uri.getScheme(); + if (scheme != null && !LocalHost.equals(uri.getHost())) { IRemoteProxyManager manager = getRemoteManager(scheme); if (manager != null) - return manager.getLauncher(project); + return manager.getLauncher(uri); } return new LocalLauncher(); } - public String getOS(IProject project) throws CoreException { + public IRemoteCommandLauncher getLauncher(IProject project) throws CoreException { URI projectURI = project.getLocationURI(); - String scheme = projectURI.getScheme(); - if (scheme != null && !LocalHost.equals(projectURI.getHost())) { + return getLauncher(projectURI); + } + + public String getOS(URI uri) throws CoreException { + String scheme = uri.getScheme(); + if (scheme != null && !LocalHost.equals(uri.getHost())) { IRemoteProxyManager manager = getRemoteManager(scheme); if (manager != null) - return manager.getOS(project); + return manager.getOS(uri); } return Platform.getOS(); } + + public String getOS(IProject project) throws CoreException { + URI projectURI = project.getLocationURI(); + return getOS(projectURI); + } } diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java index dd87b96..f1dce3e 100644 --- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTCommandLauncher.java @@ -48,7 +48,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher { protected String fErrorMessage = ""; //$NON-NLS-1$ private String lineSeparator; - private IProject fProject; + private URI uri; /** * The number of milliseconds to pause between polling. @@ -63,7 +63,19 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher { public RDTCommandLauncher(IProject project) { fProcess = null; fShowCommand = false; - fProject = project; + uri = project.getLocationURI(); + lineSeparator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ + } + + /** + * Creates a new launcher Fills in stderr and stdout output to the given + * streams. Streams can be set to <code>null</code>, if output not + * required + */ + public RDTCommandLauncher(URI uri) { + fProcess = null; + fShowCommand = false; + this.uri = uri; lineSeparator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ } @@ -74,6 +86,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher { /* (non-Javadoc) * @see org.eclipse.cdt.core.ICommandLauncher#getErrorMessage() */ + @Override public String getErrorMessage() { return fErrorMessage; } @@ -113,12 +126,12 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher { /** * @see org.eclipse.cdt.core.IRemoteCommandLauncher#execute(IPath, String[], String[], IPath, IProgressMonitor) */ + @Override public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, IProgressMonitor monitor) throws CoreException { try { // add platform specific arguments (shell invocation) fCommandArgs = constructCommandArray(commandPath.toOSString(), args); fShowCommand = true; - URI uri = fProject.getLocationURI(); IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); IRemoteConnection connection = services.getConnectionManager().getConnection(uri); IRemoteFileManager fm = services.getFileManager(connection); @@ -147,6 +160,7 @@ public class RDTCommandLauncher implements IRemoteCommandLauncher { /* (non-Javadoc) * @see org.eclipse.cdt.core.IRemoteCommandLauncher#waitAndRead(java.io.OutputStream, java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor) */ + @Override public int waitAndRead(OutputStream output, OutputStream err, IProgressMonitor monitor) { if (fShowCommand) { printCommandLine(output); diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java index d222196..093b3f1 100644 --- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/internal/rdt/proxy/RDTFileProxy.java @@ -14,15 +14,23 @@ import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; public class RDTFileProxy implements IRemoteFileProxy { private IRemoteFileManager manager; - - public RDTFileProxy(IProject project) { - URI uri = project.getLocationURI(); + + private void initialize(URI uri) { IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); services.initialize(); IRemoteConnection connection = services.getConnectionManager().getConnection(uri); manager = services.getFileManager(connection); } - + + public RDTFileProxy(URI uri) { + initialize(uri); + } + + public RDTFileProxy(IProject project) { + URI uri = project.getLocationURI(); + initialize(uri); + } + @Override public URI toURI(IPath path) { return manager.toURI(path); diff --git a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java index 7cdc724..a978a91 100644 --- a/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java +++ b/profiling/org.eclipse.linuxtools.rdt.proxy/src/org/eclipse/linuxtools/rdt/proxy/RDTProxyManager.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.linuxtools.rdt.proxy; +import java.net.URI; + import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.linuxtools.internal.rdt.proxy.RDTCommandLauncher; @@ -17,26 +19,49 @@ import org.eclipse.linuxtools.internal.rdt.proxy.RDTFileProxy; import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher; import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; import org.eclipse.linuxtools.profiling.launch.IRemoteProxyManager; +import org.eclipse.ptp.remote.core.IRemoteConnection; +import org.eclipse.ptp.remote.core.IRemoteServices; +import org.eclipse.ptp.remote.core.PTPRemoteCorePlugin; public class RDTProxyManager implements IRemoteProxyManager { @Override + public IRemoteFileProxy getFileProxy(URI uri) throws CoreException { + return new RDTFileProxy(uri); + } + + @Override public IRemoteFileProxy getFileProxy(IProject project) throws CoreException { return new RDTFileProxy(project); } @Override + public IRemoteCommandLauncher getLauncher(URI uri) + throws CoreException { + return new RDTCommandLauncher(uri); + } + + @Override public IRemoteCommandLauncher getLauncher(IProject project) throws CoreException { return new RDTCommandLauncher(project); } @Override + public String getOS(URI uri) throws CoreException { + IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); + IRemoteConnection connection = services.getConnectionManager().getConnection(uri); + String os = connection.getProperty(IRemoteConnection.OS_NAME_PROPERTY); + if (os == null || os.length() == 0) + //FIXME: need better way to get this property + return "Linux"; //$NON-NLS-1$ + return os; + } + + @Override public String getOS(IProject project) throws CoreException { -// URI uri = project.getLocationURI(); -// IRemoteServices services = PTPRemoteCorePlugin.getDefault().getRemoteServices(uri); -// IRemoteConnection connection = services.getConnectionManager().getConnection(uri); - return "Linux"; //FIXME: why doesn't getProperty("os.name") work? + URI uri = project.getLocationURI(); + return getOS(uri); } } |

