diff options
author | eutarass | 2011-02-23 17:31:39 +0000 |
---|---|---|
committer | eutarass | 2011-02-23 17:31:39 +0000 |
commit | 7bc6edbfd5aa161baa1b50e057d2b1164b5e49a6 (patch) | |
tree | 02c469e10e3768b273126b6b2b06dfb311c60351 /plugins/org.eclipse.tm.tcf.core | |
parent | 749b94bcae2faf05372db7614d0c1147b63ed75e (diff) | |
download | org.eclipse.tcf-7bc6edbfd5aa161baa1b50e057d2b1164b5e49a6.tar.gz org.eclipse.tcf-7bc6edbfd5aa161baa1b50e057d2b1164b5e49a6.tar.xz org.eclipse.tcf-7bc6edbfd5aa161baa1b50e057d2b1164b5e49a6.zip |
Fixed: recent extensions in Processes service API can cause compatibility problems between new clients and older agents.
To resolve this, the extended service API is given new name: ProcessesV1.
Clients can use regular service discovery methods to check which API is supported by remote peer.
The agent is changed to provide both APIs.
Diffstat (limited to 'plugins/org.eclipse.tm.tcf.core')
4 files changed, 106 insertions, 53 deletions
diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java index 662a3b115..c5d95349e 100644 --- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesProxy.java @@ -24,15 +24,15 @@ import org.eclipse.tm.tcf.services.IProcesses; public class ProcessesProxy implements IProcesses { - private final IChannel channel; + protected final IChannel channel; private final Map<ProcessesListener,IChannel.IEventListener> listeners = new HashMap<ProcessesListener,IChannel.IEventListener>(); - private class ProcessContext implements IProcesses.ProcessContext { + protected class ProcessContextInfo implements IProcesses.ProcessContext { private final Map<String,Object> props; - ProcessContext(Map<String,Object> props) { + ProcessContextInfo(Map<String,Object> props) { this.props = props; } @@ -171,7 +171,7 @@ public class ProcessesProxy implements IProcesses { if (error == null) { assert args.length == 2; error = toError(args[0]); - if (args[1] != null) ctx = new ProcessContext((Map<String, Object>)args[1]); + if (args[1] != null) ctx = new ProcessContextInfo((Map<String, Object>)args[1]); } done.doneGetContext(token, error, ctx); } @@ -206,27 +206,7 @@ public class ProcessesProxy implements IProcesses { if (error == null) { assert args.length == 2; error = toError(args[0]); - if (args[1] != null) ctx = new ProcessContext((Map<String,Object>)args[1]); - } - done.doneStart(token, error, ctx); - } - }.token; - } - - public IToken start(String directory, String file, - String[] command_line, Map<String,String> environment, - Map<String,Object> params, final DoneStart done) { - return new Command(channel, this, - "start", new Object[]{ directory, file, command_line, - toEnvStringArray(environment), params }) { - @SuppressWarnings("unchecked") - @Override - public void done(Exception error, Object[] args) { - ProcessContext ctx = null; - if (error == null) { - assert args.length == 2; - error = toError(args[0]); - if (args[1] != null) ctx = new ProcessContext((Map<String,Object>)args[1]); + if (args[1] != null) ctx = new ProcessContextInfo((Map<String,Object>)args[1]); } done.doneStart(token, error, ctx); } @@ -304,7 +284,7 @@ public class ProcessesProxy implements IProcesses { return (String[])c.toArray(new String[c.size()]); } - private static String[] toEnvStringArray(Map<String,String> m) { + protected static String[] toEnvStringArray(Map<String,String> m) { if (m == null) return new String[0]; int n = 0; String[] arr = new String[m.size()]; diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesV1Proxy.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesV1Proxy.java new file mode 100644 index 000000000..64ff4d035 --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/internal/tcf/services/remote/ProcessesV1Proxy.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.internal.tcf.services.remote; + +import java.util.Map; + +import org.eclipse.tm.tcf.core.Command; +import org.eclipse.tm.tcf.protocol.IChannel; +import org.eclipse.tm.tcf.protocol.IToken; +import org.eclipse.tm.tcf.services.IProcessesV1; + +public class ProcessesV1Proxy extends ProcessesProxy implements IProcessesV1 { + + public ProcessesV1Proxy(IChannel channel) { + super(channel); + } + + public String getName() { + return IProcessesV1.NAME; + } + + public IToken start(String directory, String file, + String[] command_line, Map<String,String> environment, + Map<String,Object> params, final DoneStart done) { + return new Command(channel, this, + "start", new Object[]{ directory, file, command_line, + toEnvStringArray(environment), params }) { + @SuppressWarnings("unchecked") + @Override + public void done(Exception error, Object[] args) { + ProcessContext ctx = null; + if (error == null) { + assert args.length == 2; + error = toError(args[0]); + if (args[1] != null) ctx = new ProcessContextInfo((Map<String,Object>)args[1]); + } + done.doneStart(token, error, ctx); + } + }.token; + } +} diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IProcesses.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IProcesses.java index a8dd7a449..b0b40eda5 100644 --- a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IProcesses.java +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IProcesses.java @@ -32,15 +32,6 @@ public interface IProcesses extends IService { static final String NAME = "Processes"; - /** Process start parameters */ - static final String - /** Boolean, attach the debugger to the process */ - START_ATTACH = "Attach", - /** Boolean, auto-attach process children */ - START_ATTACH_CHILDREN = "AttachChildren", - /** Boolean, Use pseudo-terminal for the process standard I/O */ - START_USE_TERMINAL = "UseTerminal"; - /** * Retrieve context info for given context ID. * A context corresponds to an execution thread, process, address space, etc. @@ -292,30 +283,12 @@ public interface IProcesses extends IService { * @param attach - if true debugger should be attached to the process. * @param done - call back interface called when operation is completed. * @return pending command handle, can be used to cancel the command. - * @deprecated Use "Map<String,Object> params" instead of "boolean attach". */ IToken start(String directory, String file, String[] command_line, Map<String,String> environment, boolean attach, DoneStart done); /** - * Start a new process on remote machine. - * @param directory - initial value of working directory for the process. - * @param file - process image file. - * @param command_line - command line arguments for the process. - * Note: the service does NOT add image file name as first argument for the process. - * If a client wants first parameter to be the file name, it should add it itself. - * @param environment - map of environment variables for the process, - * if null then default set of environment variables will be used. - * @param params - additional process start parameters, see START_*. - * @param done - call back interface called when operation is completed. - * @return pending command handle, can be used to cancel the command. - */ - IToken start(String directory, String file, - String[] command_line, Map<String,String> environment, - Map<String,Object> params, DoneStart done); - - /** * Call-back interface to be called when "start" command is complete. */ interface DoneStart { diff --git a/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IProcessesV1.java b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IProcessesV1.java new file mode 100644 index 000000000..dfb0ec796 --- /dev/null +++ b/plugins/org.eclipse.tm.tcf.core/src/org/eclipse/tm/tcf/services/IProcessesV1.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.tcf.services; + +import java.util.Map; + +import org.eclipse.tm.tcf.protocol.IToken; + +/** + * Extension of Processes service. + * It provides new "start" command that supports additional parameters. + */ +public interface IProcessesV1 extends IProcesses { + + static final String NAME = "ProcessesV1"; + + /** Process start parameters */ + static final String + /** Boolean, attach the debugger to the process */ + START_ATTACH = "Attach", + /** Boolean, auto-attach process children */ + START_ATTACH_CHILDREN = "AttachChildren", + /** Boolean, Use pseudo-terminal for the process standard I/O */ + START_USE_TERMINAL = "UseTerminal"; + + /** + * Start a new process on remote machine. + * @param directory - initial value of working directory for the process. + * @param file - process image file. + * @param command_line - command line arguments for the process. + * Note: the service does NOT add image file name as first argument for the process. + * If a client wants first parameter to be the file name, it should add it itself. + * @param environment - map of environment variables for the process, + * if null then default set of environment variables will be used. + * @param params - additional process start parameters, see START_*. + * @param done - call back interface called when operation is completed. + * @return pending command handle, can be used to cancel the command. + */ + IToken start(String directory, String file, + String[] command_line, Map<String,String> environment, + Map<String,Object> params, DoneStart done); + +} |