Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 217689 Details for
Bug 378494
Change RuntimeProcessFactory to use file and process proxies
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Finally a last version
0001-tools.launch-Using-proxies-instead-of-local-files.patch (text/plain), 14.71 KB, created by
Otavio Pontes
on 2012-06-21 09:20:15 EDT
(
hide
)
Description:
Finally a last version
Filename:
MIME Type:
Creator:
Otavio Pontes
Created:
2012-06-21 09:20:15 EDT
Size:
14.71 KB
patch
obsolete
>From ba418dc5fbf2af176365fe7c905850a2e8ec9215 Mon Sep 17 00:00:00 2001 >From: Otavio Pontes <obusatto@linux.vnet.ibm.com> >Date: Tue, 19 Jun 2012 10:38:42 -0300 >Subject: [PATCH 1/2] tools.launch: Using proxies instead of local files > >Switching RuntimeProcessFactory to use file and process proxies. >Work done by Rafael Medeiros Teixeira <rafaelmt@linux.vnet.ibm.com> and >bugs fixed by Otavio and Xavier Raynaud. >--- > .../profiling/launch/RemoteProxyManager.java | 9 +- > .../META-INF/MANIFEST.MF | 6 +- > .../pom.xml | 2 +- > .../launch/core/factory/RuntimeProcessFactory.java | 212 +++++++++++++++++++- > 4 files changed, 212 insertions(+), 17 deletions(-) > >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 e800244..4d6d5b7 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 >@@ -74,7 +74,8 @@ public class RemoteProxyManager implements IRemoteProxyManager { > > public IRemoteFileProxy getFileProxy(URI uri) throws CoreException { > String scheme = uri.getScheme(); >- if (scheme != null && !LocalHost.equals(uri.getHost())) { >+ String host = uri.getHost(); >+ if (scheme != null && host != null && !LocalHost.equals(host)) { > IRemoteProxyManager manager = getRemoteManager(scheme); > if (manager != null) > return manager.getFileProxy(uri); >@@ -92,7 +93,8 @@ public class RemoteProxyManager implements IRemoteProxyManager { > > public IRemoteCommandLauncher getLauncher(URI uri) throws CoreException { > String scheme = uri.getScheme(); >- if (scheme != null && !LocalHost.equals(uri.getHost())) { >+ String host = uri.getHost(); >+ if (scheme != null && host != null && !LocalHost.equals(host)) { > IRemoteProxyManager manager = getRemoteManager(scheme); > if (manager != null) > return manager.getLauncher(uri); >@@ -107,7 +109,8 @@ public class RemoteProxyManager implements IRemoteProxyManager { > > public String getOS(URI uri) throws CoreException { > String scheme = uri.getScheme(); >- if (scheme != null && !LocalHost.equals(uri.getHost())) { >+ String host = uri.getHost(); >+ if (scheme != null && host != null && !LocalHost.equals(host)) { > IRemoteProxyManager manager = getRemoteManager(scheme); > if (manager != null) > return manager.getOS(uri); >diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF b/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF >index 444b4b9..678742e 100644 >--- a/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF >+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF >@@ -2,14 +2,16 @@ Manifest-Version: 1.0 > Bundle-ManifestVersion: 2 > Bundle-Name: %bundleName > Bundle-SymbolicName: org.eclipse.linuxtools.tools.launch.core >-Bundle-Version: 1.0.0.qualifier >+Bundle-Version: 1.1.0.qualifier > Bundle-Vendor: %provider > Bundle-Activator: org.eclipse.linuxtools.tools.launch.core.Activator > Bundle-Localization: plugin > Require-Bundle: org.eclipse.core.runtime, > org.eclipse.cdt.core, > org.eclipse.core.resources, >- org.eclipse.ui;bundle-version="3.7.0" >+ org.eclipse.ui;bundle-version="3.7.0", >+ org.eclipse.linuxtools.profiling.launch;bundle-version="0.10.0", >+ org.eclipse.core.filesystem;bundle-version="1.3.100" > Bundle-RequiredExecutionEnvironment: JavaSE-1.6 > Bundle-ActivationPolicy: lazy > Export-Package: org.eclipse.linuxtools.tools.launch.core.factory, >diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml b/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml >index e8af04b..0596ffa 100644 >--- a/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml >+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml >@@ -18,7 +18,7 @@ > </parent> > > <artifactId>org.eclipse.linuxtools.tools.launch.core</artifactId> >- <version>1.0.0-SNAPSHOT</version> >+ <version>1.1.0-SNAPSHOT</version> > <packaging>eclipse-plugin</packaging> > > <name>Linux Tools Tools Launcher Core Plug-in</name> >diff --git a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java >index a01e5ab..edc07bc 100644 >--- a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java >+++ b/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java >@@ -15,12 +15,21 @@ import java.io.BufferedReader; > import java.io.File; > import java.io.IOException; > import java.io.InputStreamReader; >+import java.net.URI; > import java.util.ArrayList; > import java.util.Arrays; > import java.util.List; > import java.util.StringTokenizer; > >+import org.eclipse.core.filesystem.IFileStore; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher; >+import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy; >+import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager; > > /* > * Create process using Runtime.getRuntime().exec and prepends the >@@ -42,20 +51,44 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { > return cmdarray; > } > >+ private String[] fillPathCommand(String[] cmdarray, IProject project) throws IOException { >+ cmdarray[0] = whichCommand(cmdarray[0], project); >+ return cmdarray; >+ } >+ >+ /** >+ * @deprecated >+ * >+ * Use {@link RuntimeProcessFactory#fillPathCommand(String[], IProject)} instead. >+ */ >+ @Deprecated > private String[] fillPathCommand(String[] cmdarray, String[] envp) throws IOException { > cmdarray[0] = whichCommand(cmdarray[0], envp); > return cmdarray; > } > >+ /** >+ * @deprecated >+ * >+ * Use {@link RuntimeProcessFactory#fillPathSudoCommand(String[], IProject)} instead. >+ */ >+ @Deprecated > private String[] fillPathSudoCommand(String[] cmdarray, String[] envp) throws IOException { > cmdarray[2] = whichCommand(cmdarray[2], envp); > return cmdarray; > } > >- public String whichCommand(String command, IProject project) throws IOException { >- return whichCommand(command, updateEnvironment(null, project)); >+ private String[] fillPathSudoCommand(String[] cmdarray, IProject project) throws IOException { >+ cmdarray[1] = whichCommand(cmdarray[1], project); >+ return cmdarray; > } > >+ /** >+ * @deprecated >+ * >+ * Use {@link RuntimeProcessFactory#whichCommand(String, IProject)} instead. >+ */ >+ @Deprecated > public String whichCommand(String command, String[] envp) throws IOException { > Process p = Runtime.getRuntime().exec(new String[] {WHICH_CMD, command}, envp); > try { >@@ -72,6 +105,31 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { > return command; > } > >+ public String whichCommand(String command, IProject project) throws IOException { >+ if (project != null) { >+ String[] envp = updateEnvironment(null, project); >+ try { >+ IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project); >+ URI whichUri = URI.create(WHICH_CMD); >+ IPath whichPath = new Path(proxy.toPath(whichUri)); >+ IRemoteCommandLauncher launcher = RemoteProxyManager.getInstance().getLauncher(project); >+ Process pProxy = launcher.execute(whichPath, new String[]{command}, envp, null, new NullProgressMonitor()); >+ if (pProxy != null){ >+ BufferedReader error = new BufferedReader(new InputStreamReader(pProxy.getErrorStream())); >+ if(error.readLine() != null){ >+ throw new IOException(error.readLine()); >+ } >+ BufferedReader reader = new BufferedReader(new InputStreamReader(pProxy.getInputStream())); >+ String readLine = reader.readLine(); >+ command = readLine; >+ } >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ } >+ return command; >+ } >+ > public static RuntimeProcessFactory getFactory() { > if (instance == null) > instance = new RuntimeProcessFactory(); >@@ -79,7 +137,7 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { > } > > public Process exec(String cmd, IProject project) throws IOException { >- return exec(cmd, null, null, project); >+ return exec(cmd, null, (IFileStore)null, project); > } > > public Process exec(String[] cmdarray, IProject project) throws IOException { >@@ -87,18 +145,38 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { > } > > public Process exec(String[] cmdarray, String[] envp, IProject project) throws IOException { >- return exec(cmdarray, envp, null, project); >+ return exec(cmdarray, envp, (IFileStore)null, project); > } > > public Process exec(String cmd, String[] envp, IProject project) throws IOException { >- return exec(cmd, envp, null, project); >+ return exec(cmd, envp, (IFileStore)null, project); > } > >+ /** >+ * @deprecated >+ * >+ * Use {@link RuntimeProcessFactory#exec(String, String[], IFileStore, IProject)} instead. >+ */ >+ @Deprecated > public Process exec(String cmd, String[] envp, File dir, IProject project) > throws IOException { > return exec(tokenizeCommand(cmd), envp, dir, project); > } > >+ /** >+ * @since 1.1 >+ */ >+ public Process exec(String cmd, String[] envp, IFileStore dir, IProject project) >+ throws IOException { >+ return exec(tokenizeCommand(cmd), envp, dir, project); >+ } >+ >+ /** >+ * @deprecated >+ * >+ * Use {@link RuntimeProcessFactory#exec(String[], String[], IFileStore, IProject)} instead. >+ */ >+ @Deprecated > public Process exec(String cmdarray[], String[] envp, File dir, IProject project) > throws IOException { > envp = updateEnvironment(envp, project); >@@ -106,28 +184,93 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { > > return Runtime.getRuntime().exec(cmdarray, envp, dir); > } >+ >+ /** >+ * @since 1.1 >+ */ >+ public Process exec(String cmdarray[], String[] envp, IFileStore dir, IProject project) >+ throws IOException { >+ >+ Process p = null; >+ try { >+ cmdarray = fillPathCommand(cmdarray, project); >+ >+ String command = cmdarray[0]; >+ URI uri = URI.create(command); >+ >+ IPath changeToDir = null; >+ IPath path; >+ IRemoteCommandLauncher launcher; >+ >+ if (project != null) { >+ IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project); >+ path = new Path(proxy.toPath(uri)); >+ launcher = RemoteProxyManager.getInstance().getLauncher(project); >+ envp = updateEnvironment(envp, project); >+ if (dir != null) >+ changeToDir = new Path(proxy.toPath(dir.toURI())); >+ } else { >+ path = new Path(uri.getPath()); >+ launcher = RemoteProxyManager.getInstance().getLauncher(uri); >+ if (dir != null) >+ changeToDir = new Path(dir.toURI().getPath()); >+ } >+ >+ >+ List<String> cmdlist = new ArrayList<String>(Arrays.asList(cmdarray)); >+ cmdlist.remove(0); >+ cmdlist.toArray(cmdarray); >+ cmdarray = cmdlist.toArray(new String[0]); >+ >+ p = launcher.execute(path, cmdarray, envp, changeToDir , new NullProgressMonitor()); >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ >+ return p; >+ } > > public Process sudoExec(String cmd, IProject project) throws IOException { >- return sudoExec(cmd, null, null, project); >+ return sudoExec(cmd, null, (IFileStore)null, project); > } > > public Process sudoExec(String cmd, String[] envp, IProject project) throws IOException { >- return exec(cmd, envp, null, project); >+ return exec(cmd, envp, (IFileStore)null, project); > } >- >+ >+ /** >+ * @deprecated >+ * >+ * Use {@link RuntimeProcessFactory#sudoExec(String, String[], IFileStore, IProject)} instead. >+ */ >+ @Deprecated > public Process sudoExec(String cmd, String[] envp, File dir, IProject project) > throws IOException { > return sudoExec(tokenizeCommand(cmd), envp, dir, project); >- } >+ } >+ >+ /** >+ * @since 1.1 >+ */ >+ public Process sudoExec(String cmd, String[] envp, IFileStore dir, IProject project) >+ throws IOException { >+ return sudoExec(tokenizeCommand(cmd), envp, dir, project); >+ } > > public Process sudoExec(String[] cmdarray, IProject project) throws IOException { > return sudoExec(cmdarray, null, project); > } > > public Process sudoExec(String[] cmdarray, String[] envp, IProject project) throws IOException { >- return sudoExec(cmdarray, envp, null, project); >+ return sudoExec(cmdarray, envp, (IFileStore)null, project); > } >- >+ >+ /** >+ * @deprecated >+ * >+ * Use {@link RuntimeProcessFactory#sudoExec(String[], String[], IFileStore, IProject)} instead. >+ */ >+ @Deprecated > public Process sudoExec(String[] cmdarray, String[] envp, File dir, IProject project) throws IOException { > List<String> cmdList = Arrays.asList(cmdarray); > ArrayList<String> cmdArrayList = new ArrayList<String>(cmdList); >@@ -142,4 +285,51 @@ public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { > > return Runtime.getRuntime().exec(cmdArraySudo, envp, dir); > } >+ >+ /** >+ * @since 1.1 >+ */ >+ public Process sudoExec(String[] cmdarray, String[] envp, IFileStore dir, IProject project) throws IOException { >+ URI uri = URI.create("sudo"); //$NON-NLS-1$ >+ >+ List<String> cmdList = Arrays.asList(cmdarray); >+ ArrayList<String> cmdArrayList = new ArrayList<String>(cmdList); >+ cmdArrayList.add(0, "-n"); //$NON-NLS-1$ >+ >+ String[] cmdArraySudo = new String[cmdArrayList.size()]; >+ cmdArrayList.toArray(cmdArraySudo); >+ >+ Process p = null; >+ try { >+ cmdArraySudo = fillPathSudoCommand(cmdArraySudo, project); >+ IRemoteCommandLauncher launcher; >+ IPath changeToDir = null, path; >+ if (project != null) { >+ IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project); >+ path = new Path(proxy.toPath(uri)); >+ launcher = RemoteProxyManager.getInstance().getLauncher(project); >+ envp = updateEnvironment(envp, project); >+ >+ if (dir != null) >+ changeToDir = new Path(proxy.toPath(dir.toURI())); >+ } else { >+ launcher = RemoteProxyManager.getInstance().getLauncher(uri); >+ path = new Path(uri.getPath()); >+ if (dir != null) >+ changeToDir = new Path(dir.toURI().getPath()); >+ } >+ >+ List<String> cmdlist = new ArrayList<String>(Arrays.asList(cmdArraySudo)); >+ cmdlist.remove(0); >+ cmdlist.toArray(cmdArraySudo); >+ cmdArraySudo = cmdlist.toArray(new String[0]); >+ >+ p = launcher.execute(path, cmdArraySudo, envp, changeToDir , new NullProgressMonitor()); >+ } catch (CoreException e) { >+ e.printStackTrace(); >+ } >+ >+ return p; >+ >+ } > } >-- >1.7.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
obusatto
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 378494
:
215063
|
215989
|
215990
|
216600
|
217547
|
217562
|
217688
| 217689