mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
[Bug 226262] [api][breaking] RSE IService should be IAdaptable
This commit is contained in:
parent
98ffeae46e
commit
e3b82f8326
27 changed files with 1116 additions and 947 deletions
|
@ -1,13 +1,14 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Wind River Systems, Inc.
|
||||
* 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:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
* Copyright (c) 2006, 2008 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:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
* David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage()
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.examples.daytime.service;
|
||||
|
@ -18,17 +19,16 @@ import java.io.InputStreamReader;
|
|||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.examples.daytime.DaytimeResources;
|
||||
import org.eclipse.rse.services.AbstractService;
|
||||
|
||||
/**
|
||||
* The DaytimeService implements the UI-less protocol for accessing the
|
||||
* daytime TCP service on a remote host. Other implementations of the
|
||||
* same interface might use other methods for retrieving the time of day.
|
||||
*/
|
||||
public class DaytimeService implements IDaytimeService {
|
||||
|
||||
public class DaytimeService extends AbstractService implements IDaytimeService {
|
||||
|
||||
private String fHostname;
|
||||
|
||||
public DaytimeService() {
|
||||
|
@ -43,11 +43,6 @@ public class DaytimeService implements IDaytimeService {
|
|||
return DaytimeResources.Daytime_Service_Description;
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
|
||||
public void setHostName(String hostname) {
|
||||
fHostname = hostname;
|
||||
}
|
||||
|
@ -61,8 +56,4 @@ public class DaytimeService implements IDaytimeService {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor) {
|
||||
//nothing to do
|
||||
}
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,20 +1,21 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout
|
||||
* David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout
|
||||
* David McKnight (IBM) - [159092] For to use correct process miner id
|
||||
* David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.dstore.processes;
|
||||
|
@ -37,10 +38,9 @@ import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
|
|||
import org.eclipse.rse.services.clientserver.processes.ISystemProcessRemoteConstants;
|
||||
import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor;
|
||||
import org.eclipse.rse.services.processes.AbstractProcessService;
|
||||
import org.eclipse.rse.services.processes.IProcessService;
|
||||
|
||||
|
||||
public class DStoreProcessService extends AbstractProcessService implements IProcessService
|
||||
public class DStoreProcessService extends AbstractProcessService
|
||||
// TODO implements IDStoreService ?
|
||||
{
|
||||
protected IDataStoreProvider _provider;
|
||||
protected DataElement _minerElement = null;
|
||||
|
@ -48,23 +48,23 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
protected DataElement _procMinerStatus;
|
||||
protected String[] _statusTypes;
|
||||
protected String _userName;
|
||||
|
||||
|
||||
public DStoreProcessService(IDataStoreProvider provider)
|
||||
{
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return ServiceResources.DStore_Process_Service_Label;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return ServiceResources.DStore_Process_Service_Description;
|
||||
}
|
||||
|
||||
public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException
|
||||
|
||||
public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
if (!isInitialized())
|
||||
{
|
||||
|
@ -74,12 +74,12 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
|
||||
DataStore ds = getDataStore();
|
||||
DataElement universaltemp = getMinerElement();
|
||||
|
||||
|
||||
// create filter descriptor
|
||||
DataElement deObj;
|
||||
deObj = ds.find(universaltemp, DE.A_NAME, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_ROOT, 1);
|
||||
if (deObj == null) deObj = ds.createObject(universaltemp, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_FILTER, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_ROOT, "", "", false); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
deObj.setAttribute(DE.A_SOURCE, filter.toString());
|
||||
deObj.setAttribute(DE.A_SOURCE, filter.toString());
|
||||
|
||||
// query
|
||||
DataElement queryCmd = ds.localDescriptorQuery(deObj.getDescriptor(), IUniversalProcessDataStoreConstants.C_PROCESS_FILTER_QUERY_ALL);
|
||||
|
@ -102,13 +102,13 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
if (nested != null)
|
||||
{
|
||||
Object[] results = nested.toArray();
|
||||
|
||||
|
||||
String message = status.getAttribute(DE.A_VALUE);
|
||||
if (!message.equals(ISystemProcessRemoteConstants.PROCESS_MINER_SUCCESS))
|
||||
{
|
||||
throw new SystemMessageException(getMessage("RSEPG1301")); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
// convert objects to remote files
|
||||
String userName = getRemoteUserName();
|
||||
if (userName != null && filter.getUsername().equals("${user.id}")) //$NON-NLS-1$
|
||||
|
@ -123,7 +123,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
|
||||
return processes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to convert DataElement objects to IRemoteClientProcess objects.
|
||||
*/
|
||||
|
@ -131,7 +131,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
{
|
||||
if (objs == null)
|
||||
return null;
|
||||
|
||||
|
||||
ArrayList list = new ArrayList(objs.length);
|
||||
|
||||
for (int idx = 0; idx < objs.length; idx++)
|
||||
|
@ -141,9 +141,9 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
{
|
||||
if (processFilter == null || processFilter.allows(de.getValue()))
|
||||
{
|
||||
DStoreHostProcess newProcess = new DStoreHostProcess(de);
|
||||
DStoreHostProcess newProcess = new DStoreHostProcess(de);
|
||||
list.add(newProcess);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
|
||||
return processes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to return the DataStore object needed by comm layer.
|
||||
*/
|
||||
|
@ -164,18 +164,18 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
{
|
||||
return _provider.getDataStore();
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getMinerElement()
|
||||
{
|
||||
|
||||
if (_minerElement == null || _minerElement.getDataStore() != getDataStore())
|
||||
{
|
||||
_minerElement = getDataStore()
|
||||
.findMinerInformation(IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID);
|
||||
.findMinerInformation(IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID);
|
||||
}
|
||||
return _minerElement;
|
||||
}
|
||||
|
||||
|
||||
public DStoreStatusMonitor getStatusMonitor(DataStore dataStore)
|
||||
{
|
||||
if (_statusMonitor == null || _statusMonitor.getDataStore() != dataStore)
|
||||
|
@ -185,31 +185,31 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
return _statusMonitor;
|
||||
}
|
||||
|
||||
public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException
|
||||
public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
try
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
||||
|
||||
// run kill command on host
|
||||
DStoreHostProcess process = (DStoreHostProcess) getProcess(PID, monitor);
|
||||
|
||||
|
||||
// if there is no process, simply return true
|
||||
if (process == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
DataElement deObj = (DataElement) process.getObject();
|
||||
DataElement killCmd = ds.localDescriptorQuery(deObj.getDescriptor(), IUniversalProcessDataStoreConstants.C_PROCESS_KILL);
|
||||
deObj.setAttribute(DE.A_SOURCE, signal);
|
||||
|
||||
|
||||
if (killCmd != null)
|
||||
{
|
||||
DataElement status = ds.command(killCmd, deObj, true);
|
||||
|
||||
|
||||
DStoreStatusMonitor smon = getStatusMonitor(getDataStore());
|
||||
smon.waitForUpdate(status);
|
||||
|
||||
|
||||
// get results
|
||||
String message = status.getAttribute(DE.A_VALUE);
|
||||
if (message.equals(ISystemProcessRemoteConstants.PROCESS_MINER_SUCCESS)) return true;
|
||||
|
@ -229,10 +229,10 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
{
|
||||
throw new SystemMessageException(getMessage("RSEG1067")); //$NON-NLS-1$
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String[] getSignalTypes()
|
||||
|
||||
public String[] getSignalTypes()
|
||||
{
|
||||
if (_statusTypes != null)
|
||||
{
|
||||
|
@ -244,7 +244,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
}
|
||||
return _statusTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of the types of signals that can be sent to
|
||||
* a process on the remote system.
|
||||
|
@ -266,7 +266,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getSignalTypesMinerElement()
|
||||
{
|
||||
return getDataStore().find(_minerElement, DE.A_NAME, "universal.killinfo"); //$NON-NLS-1$
|
||||
|
@ -274,17 +274,19 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
super.initService(monitor);
|
||||
initMiner(monitor);
|
||||
}
|
||||
|
||||
|
||||
public void uninitService(IProgressMonitor monitor)
|
||||
{
|
||||
_minerElement = null;
|
||||
_procMinerStatus = null;
|
||||
_minerElement = null;
|
||||
_statusMonitor = null;
|
||||
super.uninitService(monitor);
|
||||
}
|
||||
|
||||
|
||||
public boolean isInitialized()
|
||||
{
|
||||
if (_procMinerStatus != null)
|
||||
|
@ -294,7 +296,7 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected void waitForInitialize(IProgressMonitor monitor)
|
||||
{
|
||||
if (_procMinerStatus!= null)
|
||||
|
@ -311,14 +313,14 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
{
|
||||
monitor.setCanceled(true);
|
||||
}
|
||||
|
||||
|
||||
//InterruptedException is used to report user cancellation, so no need to log
|
||||
//This should be reviewed (use OperationCanceledException) with bug #190750
|
||||
}
|
||||
getMinerElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void initMiner(IProgressMonitor monitor)
|
||||
|
@ -328,30 +330,30 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
{
|
||||
if (getServerVersion() >= 8)
|
||||
{
|
||||
String minerId = getMinerId();
|
||||
String minerId = getMinerId();
|
||||
String message = SystemMessage.sub(ServiceResources.DStore_Service_ProgMon_Initializing_Message, "&1", minerId); //$NON-NLS-1$
|
||||
monitor.beginTask(message, IProgressMonitor.UNKNOWN);
|
||||
DataStore ds = getDataStore();
|
||||
if (_minerElement == null || _minerElement.getDataStore() != ds)
|
||||
{
|
||||
{
|
||||
if (ds != null && _procMinerStatus == null)
|
||||
{
|
||||
_procMinerStatus = ds.activateMiner(minerId);
|
||||
|
||||
}
|
||||
{
|
||||
_procMinerStatus = ds.activateMiner(minerId);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the username used to connect to the remote machine
|
||||
*/
|
||||
public String getRemoteUserName()
|
||||
{
|
||||
if (_userName == null)
|
||||
{
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
||||
DataElement encodingElement = ds.createObject(null, IUniversalProcessDataStoreConstants.UNIVERSAL_PROCESS_TEMP, ""); //$NON-NLS-1$
|
||||
|
@ -364,29 +366,29 @@ public class DStoreProcessService extends AbstractProcessService implements IPro
|
|||
monitor.waitForUpdate(status);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
_userName = encodingElement.getValue();
|
||||
}
|
||||
return _userName;
|
||||
}
|
||||
|
||||
|
||||
protected String getMinerId()
|
||||
{
|
||||
return IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID;
|
||||
}
|
||||
|
||||
|
||||
public int getServerVersion()
|
||||
{
|
||||
return getDataStore().getServerVersion();
|
||||
}
|
||||
|
||||
|
||||
public int getServerMinor()
|
||||
{
|
||||
return getDataStore().getServerMinor();
|
||||
}
|
||||
|
||||
|
||||
protected String getProcessMinerId()
|
||||
{
|
||||
return IUniversalDataStoreConstants.UNIVERSAL_PROCESS_MINER_ID;
|
||||
|
|
|
@ -7,15 +7,16 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout
|
||||
* David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup
|
||||
* David McKnight (IBM) - [196624] dstore miner IDs should be String constants rather than dynamic lookup
|
||||
* David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage()
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.dstore.shells;
|
||||
|
@ -41,24 +42,24 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS
|
|||
protected String[] _envVars;
|
||||
protected DataElement _envMinerElement;
|
||||
protected DataElement _envMinerStatus;
|
||||
|
||||
|
||||
public DStoreShellService(IDataStoreProvider dataStoreProvider)
|
||||
{
|
||||
super(dataStoreProvider);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return ServiceResources.DStore_Shell_Service_Label;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return ServiceResources.DStore_Shell_Service_Description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor)
|
||||
{
|
||||
if (!isInitialized())
|
||||
|
@ -120,7 +121,7 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS
|
|||
}
|
||||
return _envVars;
|
||||
}
|
||||
|
||||
|
||||
protected String getMinerId()
|
||||
{
|
||||
return IUniversalDataStoreConstants.UNIVERSAL_COMMAND_MINER_ID;
|
||||
|
@ -130,8 +131,8 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS
|
|||
{
|
||||
return IUniversalDataStoreConstants.UNIVERSAL_ENVIRONMENT_MINER_ID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public boolean isInitialized()
|
||||
{
|
||||
if (_initializeStatus != null)
|
||||
|
@ -141,7 +142,7 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected void waitForInitialize(IProgressMonitor monitor)
|
||||
{
|
||||
if (_envMinerStatus!= null)
|
||||
|
@ -158,7 +159,7 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS
|
|||
{
|
||||
monitor.setCanceled(true);
|
||||
}
|
||||
|
||||
|
||||
//InterruptedException is used to report user cancellation, so no need to log
|
||||
//This should be reviewed (use OperationCanceledException) with bug #190750
|
||||
}
|
||||
|
@ -166,28 +167,28 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS
|
|||
}
|
||||
super.waitForInitialize(monitor);
|
||||
}
|
||||
|
||||
|
||||
public void uninitService(IProgressMonitor monitor)
|
||||
{
|
||||
super.uninitService(monitor);
|
||||
_envMinerElement = null;
|
||||
_envMinerStatus = null;
|
||||
_envMinerStatus = null;
|
||||
super.uninitService(monitor);
|
||||
}
|
||||
|
||||
|
||||
protected void initMiner(IProgressMonitor monitor)
|
||||
{
|
||||
// init env miner first
|
||||
|
||||
if (getServerVersion() >= 8)
|
||||
{
|
||||
String minerId = getEnvSystemMinerId();
|
||||
String minerId = getEnvSystemMinerId();
|
||||
String message = SystemMessage.sub(ServiceResources.DStore_Service_ProgMon_Initializing_Message, "&1", minerId); //$NON-NLS-1$
|
||||
monitor.beginTask(message, IProgressMonitor.UNKNOWN);
|
||||
DataStore ds = getDataStore();
|
||||
if (_envMinerElement == null || _envMinerElement.getDataStore() != ds)
|
||||
{
|
||||
{
|
||||
if (ds != null && _envMinerStatus == null)
|
||||
{
|
||||
{
|
||||
_envMinerStatus = ds.activateMiner(minerId);
|
||||
/*
|
||||
DStoreStatusMonitor smon = getStatusMonitor(ds);
|
||||
|
@ -199,15 +200,15 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS
|
|||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
getMinerElement(getEnvSystemMinerId());
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
super.initMiner(monitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,16 +7,17 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes
|
||||
* David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout
|
||||
* David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout
|
||||
* David McKnight (IBM) - [207095] check for null datastore
|
||||
* David McKnight (IBM) - [209593] [api] check for existing query to avoid duplicates
|
||||
* David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage()
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.dstore;
|
||||
|
@ -31,23 +32,24 @@ import org.eclipse.dstore.core.model.DataElement;
|
|||
import org.eclipse.dstore.core.model.DataStore;
|
||||
import org.eclipse.dstore.core.model.IDataStoreProvider;
|
||||
import org.eclipse.rse.internal.services.dstore.ServiceResources;
|
||||
import org.eclipse.rse.services.AbstractService;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.dstore.util.DStoreStatusMonitor;
|
||||
|
||||
public abstract class AbstractDStoreService implements IDStoreService
|
||||
public abstract class AbstractDStoreService extends AbstractService implements IDStoreService
|
||||
{
|
||||
protected IDataStoreProvider _dataStoreProvider;
|
||||
protected DataElement _minerElement;
|
||||
protected DStoreStatusMonitor _statusMonitor;
|
||||
protected Map _cmdDescriptorMap;
|
||||
protected DataElement _initializeStatus;
|
||||
|
||||
|
||||
public AbstractDStoreService(IDataStoreProvider dataStoreProvider)
|
||||
{
|
||||
_dataStoreProvider = dataStoreProvider;
|
||||
_cmdDescriptorMap = new HashMap();
|
||||
}
|
||||
|
||||
|
||||
public DStoreStatusMonitor getStatusMonitor(DataStore dataStore)
|
||||
{
|
||||
if (_statusMonitor == null || _statusMonitor.getDataStore() != dataStore)
|
||||
|
@ -56,12 +58,12 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
return _statusMonitor;
|
||||
}
|
||||
|
||||
|
||||
public DataStore getDataStore()
|
||||
{
|
||||
return _dataStoreProvider.getDataStore();
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getMinerElement()
|
||||
{
|
||||
if (_minerElement == null || _minerElement.getDataStore() != getDataStore())
|
||||
|
@ -70,20 +72,20 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
return _minerElement;
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getMinerElement(String id)
|
||||
{
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
if (ds != null)
|
||||
{
|
||||
return ds.findMinerInformation(id);
|
||||
return ds.findMinerInformation(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected DataElement[] dsQueryCommand(DataElement subject, String command, IProgressMonitor monitor)
|
||||
{
|
||||
return dsQueryCommand(subject, null, command, monitor);
|
||||
|
@ -103,7 +105,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
DataStore ds = getDataStore();
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
// check if there already is an active command for this query
|
||||
|
@ -119,7 +121,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
try
|
||||
{
|
||||
smonitor.waitForUpdate(status, monitor);
|
||||
|
||||
|
||||
int resultSize = subject.getNestedSize();
|
||||
|
||||
checkHostJVM();
|
||||
|
@ -131,26 +133,26 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
{
|
||||
// cancel monitor if it's still not canceled
|
||||
if (monitor != null && !monitor.isCanceled())
|
||||
{
|
||||
monitor.setCanceled(true);
|
||||
}
|
||||
|
||||
|
||||
//InterruptedException is used to report user cancellation, so no need to log
|
||||
//This should be reviewed (use OperationCanceledException) with bug #190750
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new DataElement[0];
|
||||
}
|
||||
|
||||
|
||||
protected List dsQueryCommandMulti(DataElement[] subjects, String[] commands, IProgressMonitor monitor)
|
||||
{
|
||||
return dsQueryCommandMulti(subjects, null, commands, monitor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query multiple subjects in one shot
|
||||
* @param subjects the subjects to query
|
||||
|
@ -162,20 +164,20 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
protected List dsQueryCommandMulti(DataElement[] subjects, ArrayList[] argses, String[] commands, IProgressMonitor monitor)
|
||||
{
|
||||
List statuses = new ArrayList();
|
||||
DataStore ds = getDataStore();
|
||||
DataStore ds = getDataStore();
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < subjects.length && !monitor.isCanceled(); i++)
|
||||
{
|
||||
DataElement subject = subjects[i];
|
||||
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(subject, commands[i]);
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
{
|
||||
// check if there already is an active command for this query
|
||||
DataElement status = smonitor.getCommandStatus(queryCmd, subject);
|
||||
|
||||
|
||||
if (status == null){
|
||||
if (argses != null){
|
||||
status = ds.command(queryCmd, argses[i], subject, true);
|
||||
|
@ -184,65 +186,65 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
status = ds.command(queryCmd, subject, true);
|
||||
}
|
||||
}
|
||||
statuses.add(status);
|
||||
statuses.add(status);
|
||||
}
|
||||
}
|
||||
|
||||
List consolidatedResults = new ArrayList();
|
||||
|
||||
|
||||
// wait for each command to complete
|
||||
for (int i = 0; i < statuses.size() && !monitor.isCanceled(); i++)
|
||||
{
|
||||
DataElement status = (DataElement)statuses.get(i);
|
||||
DataElement deObj = subjects[i];
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
smonitor.waitForUpdate(status, monitor);
|
||||
|
||||
smonitor.waitForUpdate(status, monitor);
|
||||
|
||||
if (!monitor.isCanceled() && smonitor.determineStatusDone(status))
|
||||
{
|
||||
List nested = deObj.getNestedData();
|
||||
if (nested != null)
|
||||
{
|
||||
consolidatedResults.add(nested.toArray(new DataElement[nested.size()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
{
|
||||
// cancel monitor if it's still not canceled
|
||||
if (monitor != null && !monitor.isCanceled())
|
||||
{
|
||||
monitor.setCanceled(true);
|
||||
}
|
||||
|
||||
|
||||
//InterruptedException is used to report user cancellation, so no need to log
|
||||
//This should be reviewed (use OperationCanceledException) with bug #190750
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return consolidatedResults;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected DataElement dsStatusCommand(DataElement subject, ArrayList args, String command, IProgressMonitor monitor)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
// check if there already is an active command for this query
|
||||
DataElement status = smonitor.getCommandStatus(queryCmd, subject);
|
||||
|
||||
if (status == null){
|
||||
|
||||
if (status == null){
|
||||
status = ds.command(queryCmd, args, subject, true);
|
||||
}
|
||||
try
|
||||
|
@ -250,35 +252,35 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
smonitor.waitForUpdate(status, monitor);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
{
|
||||
// cancel monitor if it's still not canceled
|
||||
if (monitor != null && !monitor.isCanceled())
|
||||
{
|
||||
monitor.setCanceled(true);
|
||||
}
|
||||
|
||||
|
||||
//InterruptedException is used to report user cancellation, so no need to log
|
||||
//This should be reviewed (use OperationCanceledException) with bug #190750
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected DataElement dsStatusCommand(DataElement subject, String command, IProgressMonitor monitor)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
DStoreStatusMonitor smonitor = getStatusMonitor(ds);
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
DataElement queryCmd = getCommandDescriptor(subject, command);
|
||||
|
||||
if (queryCmd != null && ds != null)
|
||||
{
|
||||
{
|
||||
// check if there already is an active command for this query
|
||||
DataElement status = smonitor.getCommandStatus(queryCmd, subject);
|
||||
|
||||
if (status == null){
|
||||
|
||||
if (status == null){
|
||||
status = ds.command(queryCmd, subject, true);
|
||||
}
|
||||
try
|
||||
|
@ -286,13 +288,13 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
smonitor.waitForUpdate(status, monitor);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
{
|
||||
// cancel monitor if it's still not canceled
|
||||
if (monitor != null && !monitor.isCanceled())
|
||||
{
|
||||
monitor.setCanceled(true);
|
||||
}
|
||||
|
||||
|
||||
//InterruptedException is used to report user cancellation, so no need to log
|
||||
//This should be reviewed (use OperationCanceledException) with bug #190750
|
||||
|
||||
|
@ -301,7 +303,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
protected DataElement getCommandDescriptor(DataElement subject, String command)
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
@ -316,7 +318,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
public int getServerVersion()
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
@ -324,7 +326,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
return ds.getServerVersion();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public int getServerMinor()
|
||||
{
|
||||
DataStore ds = getDataStore();
|
||||
|
@ -332,25 +334,25 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
return ds.getServerMinor();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
protected void checkHostJVM()
|
||||
{
|
||||
/*
|
||||
DataElement status = getDataStore().queryHostJVM();
|
||||
String source = status.getSource();
|
||||
String[] tokens = source.split(",");
|
||||
|
||||
|
||||
long freeMem = Long.parseLong(tokens[0]);
|
||||
long totalMem = Long.parseLong(tokens[1]);
|
||||
|
||||
int numElements = Integer.parseInt(tokens[3]);
|
||||
|
||||
|
||||
System.out.println("Host JVM Stats:");
|
||||
System.out.println("\tfreeMem="+freeMem);
|
||||
System.out.println("\ttotalMem="+totalMem);
|
||||
|
||||
|
||||
System.out.println("\tnumber of elements="+numElements);
|
||||
|
||||
|
||||
String[] lastCreated = tokens[4].split(";");
|
||||
System.out.println("\tlast created:");
|
||||
for (int i = 0; i < lastCreated.length; i++)
|
||||
|
@ -359,7 +361,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public boolean isInitialized()
|
||||
{
|
||||
if (_initializeStatus != null)
|
||||
|
@ -373,7 +375,7 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
protected void waitForInitialize(IProgressMonitor monitor)
|
||||
{
|
||||
if (_initializeStatus != null)
|
||||
|
@ -393,27 +395,29 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
{
|
||||
monitor.setCanceled(true);
|
||||
}
|
||||
|
||||
|
||||
//InterruptedException is used to report user cancellation, so no need to log
|
||||
//This should be reviewed (use OperationCanceledException) with bug #190750
|
||||
}
|
||||
|
||||
|
||||
getMinerElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
super.initService(monitor);
|
||||
initMiner(monitor);
|
||||
}
|
||||
|
||||
|
||||
public void uninitService(IProgressMonitor monitor)
|
||||
{
|
||||
_initializeStatus = null;
|
||||
_cmdDescriptorMap.clear();
|
||||
_minerElement = null;
|
||||
_statusMonitor = null;
|
||||
super.uninitService(monitor);
|
||||
}
|
||||
|
||||
protected void initMiner(IProgressMonitor monitor)
|
||||
|
@ -428,9 +432,9 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
monitor.beginTask(message, IProgressMonitor.UNKNOWN);
|
||||
DataStore ds = getDataStore();
|
||||
if (_minerElement == null || _minerElement.getDataStore() != ds)
|
||||
{
|
||||
{
|
||||
if (ds != null && _initializeStatus == null)
|
||||
{
|
||||
{
|
||||
_initializeStatus = ds.activateMiner(minerId);
|
||||
/*
|
||||
DStoreStatusMonitor smon = getStatusMonitor(ds);
|
||||
|
@ -442,16 +446,16 @@ public abstract class AbstractDStoreService implements IDStoreService
|
|||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
getMinerElement();
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
|
||||
protected abstract String getMinerId();
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
* Martin Oberhuber (Wind River) - [216351] Improve cancellation of SystemFetchOperation for files
|
||||
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
||||
* Javier Montalvo Orus (Symbian) - [212382] additional "initCommands" slot for ftpListingParsers extension point
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.files.ftp;
|
||||
|
@ -1382,14 +1383,6 @@ public class FTPService extends AbstractFileService implements IFTPService, IFil
|
|||
return hasSucceeded;
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor)
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isCaseSensitive()
|
||||
{
|
||||
//TODO find out whether remote is case sensitive or not
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
* David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage()
|
||||
* David McKnight (IBM) - [220241] JJ: IRemoteFileSubSystem.list() on the Local file subsystem does not return correct results
|
||||
* David McKnight (IBM) - [220547] [api][breaking] SimpleSystemMessage needs to specify a message id and some messages should be shared
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.local.files;
|
||||
|
@ -1545,15 +1546,6 @@ public class LocalFileService extends AbstractFileService implements ILocalServi
|
|||
return (rc == 0);
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor)
|
||||
{
|
||||
}
|
||||
|
||||
public boolean isCaseSensitive()
|
||||
{
|
||||
return !isWindows();
|
||||
|
|
|
@ -7,13 +7,14 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Kevin Doyle (IBM) - [199871] LocalProcessService needs to implement getMessage()
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.local.processes;
|
||||
|
@ -32,30 +33,29 @@ import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
|
|||
import org.eclipse.rse.services.clientserver.processes.handlers.ProcessHandler;
|
||||
import org.eclipse.rse.services.clientserver.processes.handlers.ProcessHandlerManager;
|
||||
import org.eclipse.rse.services.processes.AbstractProcessService;
|
||||
import org.eclipse.rse.services.processes.IProcessService;
|
||||
|
||||
public class LocalProcessService extends AbstractProcessService implements ILocalService, IProcessService
|
||||
{
|
||||
public class LocalProcessService extends AbstractProcessService implements ILocalService
|
||||
{
|
||||
protected String[] _statusTypes;
|
||||
protected ProcessHandler handler;
|
||||
|
||||
|
||||
public LocalProcessService()
|
||||
{
|
||||
handler = ProcessHandlerManager.getInstance().getNewProcessHandler();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return LocalServiceResources.Local_Process_Service_Name;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return LocalServiceResources.Local_Process_Service_Description;
|
||||
}
|
||||
|
||||
public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException
|
||||
|
||||
public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
IHostProcess[] processes = null;
|
||||
|
||||
|
@ -72,18 +72,18 @@ public class LocalProcessService extends AbstractProcessService implements ILoca
|
|||
return processes;
|
||||
}
|
||||
|
||||
public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException
|
||||
public boolean kill(long PID, String signal, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
IHostProcess process = null;
|
||||
try
|
||||
{
|
||||
process = getProcess(PID, monitor);
|
||||
|
||||
|
||||
// if there is no process, simply return true
|
||||
if (process == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
handler.kill(process, signal);
|
||||
return true;
|
||||
}
|
||||
|
@ -97,14 +97,14 @@ public class LocalProcessService extends AbstractProcessService implements ILoca
|
|||
if (process != null) name += process.getName();
|
||||
String pid = ""; //$NON-NLS-1$
|
||||
if (process != null) pid += process.getPid();
|
||||
|
||||
|
||||
SystemMessage msg = getMessage("RSEPG1300"); //$NON-NLS-1$
|
||||
msg.makeSubstitution(name + " (" + pid + ")", e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new SystemMessageException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getSignalTypes()
|
||||
public String[] getSignalTypes()
|
||||
{
|
||||
if (_statusTypes != null)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ public class LocalProcessService extends AbstractProcessService implements ILoca
|
|||
}
|
||||
return _statusTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of the signal types supported by the 'kill' command on this system
|
||||
* @return a list of the signal types or null if there are none or there is an error in
|
||||
|
@ -152,13 +152,4 @@ public class LocalProcessService extends AbstractProcessService implements ILoca
|
|||
}
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.local.shells;
|
||||
|
@ -25,34 +26,27 @@ import java.util.List;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.rse.internal.services.local.ILocalService;
|
||||
import org.eclipse.rse.internal.services.local.LocalServiceResources;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.shells.AbstractShellService;
|
||||
import org.eclipse.rse.services.shells.IHostShell;
|
||||
import org.eclipse.rse.services.shells.IShellService;
|
||||
|
||||
public class LocalShellService implements IShellService, ILocalService
|
||||
public class LocalShellService extends AbstractShellService implements ILocalService
|
||||
{
|
||||
private static final String SHELL_INVOCATION = ">"; //$NON-NLS-1$
|
||||
private String[] _envVars;
|
||||
|
||||
|
||||
public LocalShellService()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return LocalServiceResources.Local_Shell_Service_Name;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return LocalServiceResources.Local_Shell_Service_Description;
|
||||
}
|
||||
|
||||
public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor)
|
||||
{
|
||||
String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
return launchShell(initialWorkingDirectory, defaultEncoding, environment, monitor);
|
||||
}
|
||||
|
||||
public IHostShell launchShell(String initialWorkingDirectory, String encoding, String[] environment, IProgressMonitor monitor)
|
||||
{
|
||||
|
@ -61,12 +55,6 @@ public class LocalShellService implements IShellService, ILocalService
|
|||
return hostShell;
|
||||
}
|
||||
|
||||
public IHostShell runCommand(String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor)
|
||||
{
|
||||
String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
return runCommand(initialWorkingDirectory, command, defaultEncoding, environment, monitor);
|
||||
}
|
||||
|
||||
public IHostShell runCommand(String initialWorkingDirectory, String command, String encoding, String[] environment, IProgressMonitor monitor)
|
||||
{
|
||||
LocalHostShell hostShell = new LocalHostShell(initialWorkingDirectory,command, encoding, environment);
|
||||
|
@ -81,7 +69,7 @@ public class LocalShellService implements IShellService, ILocalService
|
|||
List envVars = new ArrayList();
|
||||
|
||||
String[] envCommand = new String[3];
|
||||
//If we're on windows, change the envCommand.
|
||||
//If we're on windows, change the envCommand.
|
||||
if (System.getProperty("os.name").toLowerCase().startsWith("win")) //$NON-NLS-1$ //$NON-NLS-2$
|
||||
{
|
||||
envCommand[0] = "cmd"; //$NON-NLS-1$
|
||||
|
@ -132,17 +120,4 @@ public class LocalShellService implements IShellService, ILocalService
|
|||
return _envVars;
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor)
|
||||
{
|
||||
|
||||
}
|
||||
public SystemMessage getMessage(String messageID)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
* Martin Oberhuber (Wind River) - [216343] immediate link targets and canonical paths for Sftp
|
||||
* David McKnight (IBM) - [216252] [api][nls] Resource Strings specific to subsystems should be moved from rse.ui into files.ui / shells.ui / processes.ui where possible
|
||||
* Martin Oberhuber (Wind River) - [224799] Fix JSch encoding problems with Arabic filenames
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.ssh.files;
|
||||
|
@ -1068,6 +1069,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
|||
|
||||
public void initService(IProgressMonitor monitor) {
|
||||
Activator.trace("SftpFileService.initService"); //$NON-NLS-1$
|
||||
super.initService(monitor);
|
||||
try
|
||||
{
|
||||
connect();
|
||||
|
@ -1080,6 +1082,7 @@ public class SftpFileService extends AbstractFileService implements ISshService,
|
|||
public void uninitService(IProgressMonitor monitor) {
|
||||
Activator.trace("SftpFileService.uninitService"); //$NON-NLS-1$
|
||||
disconnect();
|
||||
super.uninitService(monitor);
|
||||
}
|
||||
|
||||
public boolean isCaseSensitive() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
|
@ -7,15 +7,16 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - Adapted from LocalHostShell.
|
||||
* David McKnight (IBM) - [191599] Use the remote encoding specified in the host property page
|
||||
* David McKnight (IBM) - [196301] Check that the remote encoding isn't null before using it
|
||||
* Martin Oberhuber (Wind River) - [204744] Honor encoding in SSH command input field
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.ssh.shell;
|
||||
|
@ -53,7 +54,7 @@ public class SshHostShell extends AbstractHostShell implements IHostShell {
|
|||
private SshShellOutputReader fStdoutHandler;
|
||||
private SshShellOutputReader fStderrHandler;
|
||||
private SshShellWriterThread fShellWriter;
|
||||
|
||||
|
||||
public SshHostShell(ISshSessionProvider sessionProvider, String initialWorkingDirectory, String commandToRun, String encoding, String[] environment) {
|
||||
try {
|
||||
fSessionProvider = sessionProvider;
|
||||
|
@ -66,7 +67,7 @@ public class SshHostShell extends AbstractHostShell implements IHostShell {
|
|||
//if(commandToRun!=null && !commandToRun.equals(SHELL_INVOCATION) & (fChannel instanceof ChannelShell)) {
|
||||
// ((ChannelShell)fChannel).setPty(false);
|
||||
//}
|
||||
|
||||
|
||||
//Try to set the user environment. On most sshd configurations, this will
|
||||
//not work since in sshd_config, PermitUserEnvironment and AcceptEnv
|
||||
//settings are disabled. Still, it's worth a try.
|
||||
|
@ -91,6 +92,9 @@ public class SshHostShell extends AbstractHostShell implements IHostShell {
|
|||
}
|
||||
else
|
||||
{
|
||||
// default encoding - same as
|
||||
// System.getProperty("file.encoding")
|
||||
// TODO should try to determine remote encoding if possible
|
||||
fStdoutHandler = new SshShellOutputReader(this, new BufferedReader(new InputStreamReader(fChannel.getInputStream())), false);
|
||||
}
|
||||
fStderrHandler = new SshShellOutputReader(this, null,true);
|
||||
|
@ -106,10 +110,10 @@ public class SshHostShell extends AbstractHostShell implements IHostShell {
|
|||
fShellWriter = new SshShellWriterThread(outputWriter);
|
||||
}
|
||||
fChannel.connect();
|
||||
if (initialWorkingDirectory!=null && initialWorkingDirectory.length()>0
|
||||
if (initialWorkingDirectory!=null && initialWorkingDirectory.length()>0
|
||||
&& !initialWorkingDirectory.equals(".") //$NON-NLS-1$
|
||||
&& !initialWorkingDirectory.equals("Command Shell") //$NON-NLS-1$ //FIXME workaround for bug 153047
|
||||
) {
|
||||
) {
|
||||
writeToShell("cd "+PathUtility.enQuoteUnix(initialWorkingDirectory)); //$NON-NLS-1$
|
||||
} else if (SHELL_INVOCATION.equals(commandToRun)) {
|
||||
writeToShell(getPromptCommand());
|
||||
|
@ -135,9 +139,9 @@ public class SshHostShell extends AbstractHostShell implements IHostShell {
|
|||
}
|
||||
|
||||
/**
|
||||
* Connect to remote system and launch Threads for the
|
||||
* shell as needed.
|
||||
* @param monitor
|
||||
* Connect to remote system and launch Threads for the shell as needed.
|
||||
*
|
||||
* @param monitor progress monitor for long-running operation
|
||||
*/
|
||||
protected void start(IProgressMonitor monitor)
|
||||
{
|
||||
|
@ -162,11 +166,11 @@ public class SshHostShell extends AbstractHostShell implements IHostShell {
|
|||
}
|
||||
|
||||
private static final Pattern cdCommands = Pattern.compile("\\A\\s*(cd|chdir|ls)\\b"); //$NON-NLS-1$
|
||||
|
||||
|
||||
public String getPromptCommand() {
|
||||
return "echo $PWD'>'"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
public void writeToShell(String command) {
|
||||
if (isActive()) {
|
||||
if ("#break".equals(command)) { //$NON-NLS-1$
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
|
@ -7,13 +7,14 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - Adapted from LocalShellService.
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.services.ssh.shell;
|
||||
|
@ -23,29 +24,21 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.rse.internal.services.ssh.ISshService;
|
||||
import org.eclipse.rse.internal.services.ssh.ISshSessionProvider;
|
||||
import org.eclipse.rse.internal.services.ssh.SshServiceResources;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.shells.AbstractShellService;
|
||||
import org.eclipse.rse.services.shells.IHostShell;
|
||||
import org.eclipse.rse.services.shells.IShellService;
|
||||
|
||||
/**
|
||||
* A Shell Services for ssh.
|
||||
* Adapted from LocalShellService.
|
||||
*/
|
||||
public class SshShellService implements ISshService, IShellService {
|
||||
public class SshShellService extends AbstractShellService implements ISshService {
|
||||
|
||||
private ISshSessionProvider fSessionProvider;
|
||||
|
||||
|
||||
public SshShellService(ISshSessionProvider sessionProvider) {
|
||||
fSessionProvider = sessionProvider;
|
||||
}
|
||||
|
||||
//TODO abstract base class should handle default encodings
|
||||
public IHostShell launchShell(String initialWorkingDirectory,
|
||||
String[] environment, IProgressMonitor monitor) {
|
||||
String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
return launchShell(initialWorkingDirectory, defaultEncoding, environment, monitor);
|
||||
}
|
||||
|
||||
public IHostShell launchShell(String initialWorkingDirectory,
|
||||
String encoding, String[] environment,
|
||||
IProgressMonitor monitor) {
|
||||
|
@ -53,13 +46,6 @@ public class SshShellService implements ISshService, IShellService {
|
|||
return hostShell;
|
||||
}
|
||||
|
||||
//TODO abstract base class should handle default encodings
|
||||
public IHostShell runCommand(String initialWorkingDirectory,
|
||||
String command, String[] environment, IProgressMonitor monitor) {
|
||||
String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
return runCommand(initialWorkingDirectory, command, defaultEncoding, environment, monitor);
|
||||
}
|
||||
|
||||
public IHostShell runCommand(String initialWorkingDirectory,
|
||||
String command, String encoding, String[] environment,
|
||||
IProgressMonitor monitor) {
|
||||
|
@ -80,16 +66,4 @@ public class SshShellService implements ISshService, IShellService {
|
|||
return SshServiceResources.SshShellService_Description;
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor) {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
public SystemMessage getMessage(String messageID) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
|
@ -7,13 +7,14 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - Adapted from LocalShellService.
|
||||
* Sheldon D'souza (Celunite) - Adapted from SshShellService.
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.services.telnet.shell;
|
||||
|
||||
|
@ -21,46 +22,32 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.rse.internal.services.telnet.ITelnetService;
|
||||
import org.eclipse.rse.internal.services.telnet.ITelnetSessionProvider;
|
||||
import org.eclipse.rse.internal.services.telnet.TelnetServiceResources;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.shells.AbstractShellService;
|
||||
import org.eclipse.rse.services.shells.IHostShell;
|
||||
import org.eclipse.rse.services.shells.IShellService;
|
||||
|
||||
public class TelnetShellService implements ITelnetService, IShellService {
|
||||
public class TelnetShellService extends AbstractShellService implements ITelnetService {
|
||||
|
||||
|
||||
private ITelnetSessionProvider fTelnetSessionProvider;
|
||||
|
||||
|
||||
public TelnetShellService( ITelnetSessionProvider sessionProvider) {
|
||||
this.fTelnetSessionProvider = sessionProvider;
|
||||
}
|
||||
|
||||
|
||||
public String[] getHostEnvironment() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
public IHostShell launchShell(String initialWorkingDirectory,
|
||||
String[] environment, IProgressMonitor monitor) {
|
||||
String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
return launchShell(initialWorkingDirectory, defaultEncoding, environment, monitor);
|
||||
}
|
||||
|
||||
public IHostShell launchShell(String initialWorkingDirectory,
|
||||
String encoding, String[] environment,
|
||||
IProgressMonitor monitor) {
|
||||
TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment);
|
||||
TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment);
|
||||
return hostShell;
|
||||
}
|
||||
|
||||
public IHostShell runCommand(String initialWorkingDirectory,
|
||||
String command, String[] environment, IProgressMonitor monitor) {
|
||||
String defaultEncoding = System.getProperty("file.encoding"); //$NON-NLS-1$
|
||||
return runCommand(initialWorkingDirectory, command, defaultEncoding, environment, monitor);
|
||||
}
|
||||
|
||||
public IHostShell runCommand(String initialWorkingDirectory,
|
||||
String command, String encoding, String[] environment,
|
||||
IProgressMonitor monitor) {
|
||||
TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment);
|
||||
TelnetHostShell hostShell = new TelnetHostShell(fTelnetSessionProvider, initialWorkingDirectory, TelnetHostShell.SHELL_INVOCATION, encoding, environment);
|
||||
return hostShell;
|
||||
}
|
||||
|
||||
|
@ -68,23 +55,8 @@ public class TelnetShellService implements ITelnetService, IShellService {
|
|||
return TelnetServiceResources.TelnetShellService_Description;
|
||||
}
|
||||
|
||||
public SystemMessage getMessage(String messageID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return TelnetServiceResources.TelnetShellService_Name;
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#Wed Apr 09 15:34:43 CEST 2008
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=ISO-8859-1
|
|
@ -0,0 +1,51 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.services;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* Abstract default implementation of an RSE Service. Clients are expected to
|
||||
* extend this class.
|
||||
*
|
||||
* @see IService
|
||||
* @since org.eclipse.rse.core 3.0
|
||||
*/
|
||||
public abstract class AbstractService extends PlatformObject implements IService {
|
||||
|
||||
public String getDescription() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.getClass().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of initService. Extenders who override this method
|
||||
* must call <code>super.initService(monitor)</code> as the first call in
|
||||
* their implementation.
|
||||
*/
|
||||
public void initService(IProgressMonitor monitor) {
|
||||
// Do nothing by default
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of uninitService. Extenders who override this
|
||||
* method must call <code>super.uninitService(monitor)</code> as the last
|
||||
* call in their implementation.
|
||||
*/
|
||||
public void uninitService(IProgressMonitor monitor) {
|
||||
// Do nothing by default
|
||||
}
|
||||
|
||||
}
|
|
@ -7,22 +7,74 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public interface IService
|
||||
/**
|
||||
* IService is the base interface for any non-UI service contributions to RSE.
|
||||
*
|
||||
* An actual Service is free to perform any operations at all - the only
|
||||
* commonality between services is that they have a name, can be initialized,
|
||||
* and are adaptable for future extension.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* Service implementations must subclass
|
||||
* {@link AbstractService} rather than implementing this
|
||||
* interface directly.
|
||||
*/
|
||||
public interface IService extends IAdaptable
|
||||
{
|
||||
/**
|
||||
* Get the name of this Service as a translated, UI-visible String.
|
||||
* Extenders are expected to override this method.
|
||||
*
|
||||
* @return the name of this Service.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Get the description of this Service as a translated, UI-visible String.
|
||||
* Extenders are expected to override this method.
|
||||
*
|
||||
* @return the description of this Service.
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/**
|
||||
* Initialize this Service to make it ready for operation. This method may
|
||||
* be long-running, but is not yet expected to open a connection to a
|
||||
* particular remote system.
|
||||
*
|
||||
* Extenders are expected to override this method.
|
||||
*
|
||||
* @param monitor A progress monitor to provide progress of long-running
|
||||
* operation. There is no guarantee that cancellation is actually
|
||||
* supported by a Service since it would leave the service in a
|
||||
* potentially inconsistent, partially initialized state.
|
||||
*/
|
||||
public void initService(IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* Clean up this Service. This method is called by clients as part of a
|
||||
* disconnect operation and should clean up any local status that the
|
||||
* Service might have.
|
||||
*
|
||||
* Extenders are expected to override this method.
|
||||
*
|
||||
* @param monitor A progress monitor to provide progress of long-running
|
||||
* operation. There is no guarantee that cancellation is actually
|
||||
* supported by a Service since it would leave the service in a
|
||||
* potentially inconsistent, partially initialized state.
|
||||
*/
|
||||
public void uninitService(IProgressMonitor monitor);
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* David McKnight (IBM) - [207178] changing list APIs for file service and subsystems
|
||||
|
@ -24,6 +24,7 @@
|
|||
* Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND
|
||||
* David McKnight (IBM) - [209704] added supportsEncodingConversion()
|
||||
* David McKnight (IBM) - [216252] use SimpleSystemMessage instead of getMessage()
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.files;
|
||||
|
@ -36,15 +37,16 @@ import java.util.List;
|
|||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.AbstractService;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
|
||||
|
||||
public abstract class AbstractFileService implements IFileService
|
||||
public abstract class AbstractFileService extends AbstractService implements IFileService
|
||||
{
|
||||
|
||||
|
||||
protected abstract IHostFile[] internalFetch(String parentPath, String fileFilter, int fileType, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor)
|
||||
|
||||
public IHostFile[] getFileMultiple(String remoteParents[], String names[], IProgressMonitor monitor)
|
||||
throws SystemMessageException
|
||||
{
|
||||
List results = new ArrayList();
|
||||
|
@ -55,12 +57,12 @@ public abstract class AbstractFileService implements IFileService
|
|||
return (IHostFile[])results.toArray(new IHostFile[results.size()]);
|
||||
}
|
||||
|
||||
public IHostFile[] list(String remoteParent, String fileFilter,
|
||||
public IHostFile[] list(String remoteParent, String fileFilter,
|
||||
int fileType, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
return internalFetch(remoteParent, fileFilter, fileType, monitor);
|
||||
}
|
||||
|
||||
|
||||
public IHostFile[] listMultiple(String[] remoteParents,
|
||||
String[] fileFilters, int fileTypes[], IProgressMonitor monitor)
|
||||
throws SystemMessageException {
|
||||
|
@ -74,7 +76,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
files.add(result[j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (IHostFile[])files.toArray(new IHostFile[files.size()]);
|
||||
}
|
||||
|
||||
|
@ -91,10 +93,10 @@ public abstract class AbstractFileService implements IFileService
|
|||
files.add(result[j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (IHostFile[])files.toArray(new IHostFile[files.size()]);
|
||||
}
|
||||
|
||||
|
||||
protected boolean isRightType(int fileType, IHostFile node)
|
||||
{
|
||||
switch (fileType)
|
||||
|
@ -104,12 +106,12 @@ public abstract class AbstractFileService implements IFileService
|
|||
case IFileService.FILE_TYPE_FILES:
|
||||
if (node.isFile())
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case IFileService.FILE_TYPE_FOLDERS:
|
||||
if (node.isDirectory())
|
||||
{
|
||||
|
@ -121,7 +123,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
}
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,7 +142,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
*/
|
||||
public boolean downloadMultiple(String[] remoteParents, String[] remoteFiles,
|
||||
File[] localFiles, boolean[] isBinaries, String[] hostEncodings,
|
||||
IProgressMonitor monitor) throws SystemMessageException
|
||||
IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
boolean result = true;
|
||||
for (int i = 0; i < remoteParents.length && result == true; i++)
|
||||
|
@ -161,7 +163,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
public boolean uploadMultiple(File[] localFiles, String[] remoteParents,
|
||||
String[] remoteFiles, boolean[] isBinaries, String[] srcEncodings,
|
||||
String[] hostEncodings, IProgressMonitor monitor)
|
||||
throws SystemMessageException
|
||||
throws SystemMessageException
|
||||
{
|
||||
boolean result = true;
|
||||
for (int i = 0; i < localFiles.length && result == true; i++)
|
||||
|
@ -169,7 +171,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
File localFile = localFiles[i];
|
||||
String remoteParent = remoteParents[i];
|
||||
String remoteFile = remoteFiles[i];
|
||||
|
||||
|
||||
boolean isBinary = isBinaries[i];
|
||||
String srcEncoding = srcEncodings[i];
|
||||
String hostEncoding = hostEncodings[i];
|
||||
|
@ -177,7 +179,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the local platform encoding by default. Subclasses should override to return the actual remote encoding.
|
||||
* @see org.eclipse.rse.services.files.IFileService#getEncoding(org.eclipse.core.runtime.IProgressMonitor)
|
||||
|
@ -196,15 +198,18 @@ public abstract class AbstractFileService implements IFileService
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the output stream to write/append to a remote file.
|
||||
* The default implementation returns <code>null</code>.
|
||||
* Clients can override to return an output stream to the file.
|
||||
* @deprecated
|
||||
* Gets the output stream to write/append to a remote file. The default
|
||||
* implementation returns <code>null</code>. Clients can override to
|
||||
* return an output stream to the file.
|
||||
*
|
||||
* @deprecated use
|
||||
* {@link #getOutputStream(String, String, int, IProgressMonitor)}
|
||||
* instead
|
||||
*/
|
||||
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the output stream to write/append to a remote file.
|
||||
* The default implementation returns <code>null</code>.
|
||||
|
@ -219,7 +224,7 @@ public abstract class AbstractFileService implements IFileService
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The default implementation returns false. Clients should override this method if they make use
|
||||
* of IFileServiceCodePageConverter to do conversion during download and upload.
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="Author" content="Martin Oberhuber (Wind River)">
|
||||
<meta name="Copyright" content="Copyright (c) 2008 Wind River Systems, Inc. and others.">
|
||||
<meta name="License" content="Made available under the terms of the Eclipse Public License v1.0.">
|
||||
<title>Package-level Javadoc</title>
|
||||
</head>
|
||||
<body>
|
||||
Application programming interface for the RSE Services Layer.
|
||||
<h2>
|
||||
Package Specification</h2>
|
||||
<p>
|
||||
The RSE Services layer provides interfaces and basic utility classes
|
||||
for remote operations. There is no restriction whatsoever about the
|
||||
kind of those operations, and actually there isn't even a need for
|
||||
remote systems to be involved. The Services defined here provide
|
||||
basic functionality for RSE to operate on.
|
||||
</p><p>
|
||||
The RSE Services layer is designed to have only minimal dependency into
|
||||
Eclipse core APIs, such that Services can eventually be re-used in
|
||||
environments outside Eclipse. This can be done today by providing a library
|
||||
with mock objects for the few Eclipse interfaces that Services currently use:
|
||||
<code>IAdaptable</code>, <code>IProgressMonitor</code>,
|
||||
<code>IStatus</code>, <code>NLS</code>, <code>PlatformObject</code>
|
||||
and few others related to the Eclipse Extension Registry, which are only
|
||||
used in the Activator and can thus be replaced easily by a different
|
||||
mechanisms for providing extensions.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,31 +1,37 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.processes;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.AbstractService;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessage;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.clientserver.processes.HostProcessFilterImpl;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcess;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
|
||||
|
||||
public abstract class AbstractProcessService implements IProcessService
|
||||
/**
|
||||
* Abstract base class for RSE Process Service.
|
||||
*/
|
||||
public abstract class AbstractProcessService extends AbstractService implements IProcessService
|
||||
{
|
||||
public IHostProcess[] listAllProcesses(String exeNameFilter, String userNameFilter, String stateFilter, IProgressMonitor monitor) throws SystemMessageException
|
||||
public IHostProcess[] listAllProcesses(String exeNameFilter, String userNameFilter, String stateFilter, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
|
||||
rpfs.setName(exeNameFilter);
|
||||
|
@ -34,7 +40,7 @@ public abstract class AbstractProcessService implements IProcessService
|
|||
return listAllProcesses(rpfs, monitor);
|
||||
}
|
||||
|
||||
public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException
|
||||
public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
|
||||
return listAllProcesses(rpfs, monitor);
|
||||
|
@ -42,51 +48,53 @@ public abstract class AbstractProcessService implements IProcessService
|
|||
|
||||
/**
|
||||
* Return a single IHostProcess object for the 'init' process with pid 1.
|
||||
*
|
||||
* @param monitor Progress monitor
|
||||
* @return Array with 1 element, the IHostProcess object for the root process
|
||||
* @throws SystemMessageException
|
||||
* @return Array with 1 element, the IHostProcess object for the root
|
||||
* process
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
* @see org.eclipse.rse.services.processes.IProcessService#listRootProcesses(org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IHostProcess[] listRootProcesses(IProgressMonitor monitor) throws SystemMessageException
|
||||
public IHostProcess[] listRootProcesses(IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
IHostProcess[] roots = new IHostProcess[1];
|
||||
roots[0] = getProcess(1, monitor);
|
||||
return roots;
|
||||
}
|
||||
|
||||
public IHostProcess[] listChildProcesses(long parentPID, IProgressMonitor monitor) throws SystemMessageException
|
||||
public IHostProcess[] listChildProcesses(long parentPID, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
String pPidString = "" + parentPID; //$NON-NLS-1$
|
||||
HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
|
||||
rpfs.setPpid(pPidString);
|
||||
|
||||
|
||||
return listAllProcesses(rpfs, monitor);
|
||||
}
|
||||
|
||||
public IHostProcess[] listChildProcesses(long parentPID, IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException
|
||||
|
||||
public IHostProcess[] listChildProcesses(long parentPID, IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
String pPidString = "" + parentPID; //$NON-NLS-1$
|
||||
filter.setPpid(pPidString);
|
||||
|
||||
|
||||
return listAllProcesses(filter, monitor);
|
||||
}
|
||||
|
||||
public IHostProcess getParentProcess(long pid, IProgressMonitor monitor) throws SystemMessageException
|
||||
public IHostProcess getParentProcess(long pid, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
return getProcess(getProcess(pid, monitor).getPPid(), monitor);
|
||||
}
|
||||
|
||||
public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException
|
||||
public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException
|
||||
{
|
||||
String pidString = "" + pid; //$NON-NLS-1$
|
||||
HostProcessFilterImpl rpfs = new HostProcessFilterImpl();
|
||||
rpfs.setPid(pidString);
|
||||
|
||||
|
||||
IHostProcess[] results = listAllProcesses(rpfs, monitor);
|
||||
if ((results == null) || (results.length == 0)) return null;
|
||||
else return results[0];
|
||||
}
|
||||
|
||||
|
||||
public SystemMessage getMessage(String messageID)
|
||||
{
|
||||
return null;
|
||||
|
|
|
@ -1,121 +1,144 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.processes;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.IService;
|
||||
import org.eclipse.rse.services.clientserver.messages.SystemMessageException;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcess;
|
||||
import org.eclipse.rse.services.clientserver.processes.IHostProcessFilter;
|
||||
|
||||
/**
|
||||
* An IProcessService is an abstraction of a process service that runs over some sort of connection.
|
||||
* It can be shared among multiple instances of a subsystem. Each
|
||||
* subsystem is currently responsible for layering an abstraction over whatever it
|
||||
* wants to construct as a service.
|
||||
* An IProcessService is an abstraction of a process service that runs over some
|
||||
* sort of connection. It can be shared among multiple instances of a subsystem.
|
||||
* Each subsystem is currently responsible for layering an abstraction over
|
||||
* whatever it wants to construct as a service.
|
||||
* <p>
|
||||
* Implementers of this interface will have to either be instantiated, initialized, or
|
||||
* somehow derive a connection as part of its state.
|
||||
* Implementers of this interface will have to either be instantiated,
|
||||
* initialized, or somehow derive a connection as part of its state.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* Process service implementations must subclass
|
||||
* {@link AbstractProcessService} rather than implementing this
|
||||
* interface directly.
|
||||
*/
|
||||
public interface IProcessService extends IService
|
||||
{
|
||||
/**
|
||||
* Return a list of all processes on the remote system.
|
||||
*
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return List of all processes
|
||||
* @throws SystemMessageException
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess[] listAllProcesses(IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Return a filtered list of all processes on the remote system.
|
||||
*
|
||||
* @param filter An object to filter results by
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return Filtered list of processes
|
||||
* @throws SystemMessageException
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess[] listAllProcesses(IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Return a filtered list of all processes on the remote system.
|
||||
* @param exeNameFilter The executable name to filter results by, or null if no exeName filtering
|
||||
* @param userNameFilter The user name to filter results by, or null if no userName filtering
|
||||
* @param stateFilter The state code to filter results by, or null if no state filtering
|
||||
*
|
||||
* @param exeNameFilter The executable name to filter results by, or null if
|
||||
* no exeName filtering
|
||||
* @param userNameFilter The user name to filter results by, or null if no
|
||||
* userName filtering
|
||||
* @param stateFilter The state code to filter results by, or null if no
|
||||
* state filtering
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return Filtered list of processes
|
||||
* @throws SystemMessageException
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess[] listAllProcesses(String exeNameFilter, String userNameFilter, String stateFilter, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
/**
|
||||
* Returns root processes on the remote system
|
||||
*
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return List of root processes
|
||||
* @throws SystemMessageException
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess[] listRootProcesses(IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
/**
|
||||
* Return a list of all remote child processes of the given parent process on the remote system
|
||||
* @param parentPID The ID of the parent process whose children are to be listed
|
||||
* Return a list of all remote child processes of the given parent process
|
||||
* on the remote system
|
||||
*
|
||||
* @param parentPID The ID of the parent process whose children are to be
|
||||
* listed
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return List of child processes
|
||||
* @throws SystemMessageException
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess[] listChildProcesses(long parentPID, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Return a filtered list of remote child processes of the given parent process on the remote system
|
||||
* @param parentPID The ID of the parent process whose children are to be listed
|
||||
* Return a filtered list of remote child processes of the given parent
|
||||
* process on the remote system
|
||||
*
|
||||
* @param parentPID The ID of the parent process whose children are to be
|
||||
* listed
|
||||
* @param filter A filter to narrow results by
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return Filtered list of child processes
|
||||
* @throws SystemMessageException
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess[] listChildProcesses(long parentPID, IHostProcessFilter filter, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
/**
|
||||
* Given a process, return its parent process object.
|
||||
*
|
||||
* @param pid the ID of the process to return parent of.
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return The parent process
|
||||
* @throws SystemMessageException
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess getParentProcess(long pid, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
|
||||
/**
|
||||
* Given a pid, return an IHostProcess object for it.
|
||||
*
|
||||
* @param pid The process ID of the desired process
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return IHostProcess object for the given pid
|
||||
* @throws SystemMessageException
|
||||
* @return IHostProcess object for the given pid
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
public IHostProcess getProcess(long pid, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Kills a process.
|
||||
* Kills a process.
|
||||
*
|
||||
* @param pid the ID of the process to be killed.
|
||||
* @param signal the signal to send to the process
|
||||
* @param monitor A progress monitor to which progress will be reported
|
||||
* @return <code>false</code> if the given process doesn't exist, else <code>true</code>.
|
||||
* Throws an exception if anything fails.
|
||||
* @throws SystemMessageException
|
||||
* @return <code>false</code> if the given process doesn't exist, else
|
||||
* <code>true</code>. Throws an exception if anything fails.
|
||||
* @throws SystemMessageException in case anything goes wrong
|
||||
*/
|
||||
public boolean kill(long pid, String signal, IProgressMonitor monitor) throws SystemMessageException;
|
||||
public boolean kill(long pid, String signal, IProgressMonitor monitor) throws SystemMessageException;
|
||||
|
||||
/**
|
||||
* Returns a list of the types of signals that can be sent to
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.search;
|
||||
|
@ -20,26 +21,31 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.AbstractService;
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
|
||||
|
||||
|
||||
public abstract class AbstractSearchService implements ISearchService
|
||||
/**
|
||||
* Abstract base class for RSE Search Service. A useful implementation should
|
||||
* ensure that only minimal data transfer is required between the remote system
|
||||
* and the local client.
|
||||
*/
|
||||
public abstract class AbstractSearchService extends AbstractService implements ISearchService
|
||||
{
|
||||
protected Map _searches;
|
||||
|
||||
|
||||
public AbstractSearchService()
|
||||
{
|
||||
_searches = new HashMap();
|
||||
}
|
||||
|
||||
|
||||
public final void search(IHostSearchResultConfiguration searchConfig, IFileService fileService, IProgressMonitor monitor)
|
||||
{
|
||||
{
|
||||
ISearchHandler handler = internalSearch(searchConfig, fileService, monitor);
|
||||
_searches.put(searchConfig, handler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public final void cancelSearch(IHostSearchResultConfiguration searchConfig, IProgressMonitor monitor)
|
||||
{
|
||||
ISearchHandler handler = (ISearchHandler)_searches.get(searchConfig);
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* {Name} (company) - description of contribution.
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.search;
|
||||
|
@ -24,18 +24,18 @@ import java.util.List;
|
|||
import java.util.Vector;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
|
||||
/**
|
||||
* A remote search result set represents a page in the Remote Search view.
|
||||
* A search result set contains multiple search configurations and their results.
|
||||
* This allows it to contain results from multiple connections, filters, and folders
|
||||
* This allows it to contain results from multiple connections, filters, and folders
|
||||
* (from different systems).
|
||||
*/
|
||||
public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable
|
||||
public class HostSearchResultSet extends PlatformObject implements IHostSearchResultSet, IAdaptable
|
||||
{
|
||||
|
||||
|
||||
protected Vector configurations;
|
||||
protected String name;
|
||||
|
||||
|
@ -106,48 +106,48 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable
|
|||
* @see org.eclipse.rse.services.search.IHostSearchResultSet#getAllResults()
|
||||
*/
|
||||
public Object[] getAllResults() {
|
||||
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
while (iter.hasNext())
|
||||
|
||||
while (iter.hasNext())
|
||||
{
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
|
||||
list.addAll(Arrays.asList(config.getResults()));
|
||||
|
||||
list.addAll(Arrays.asList(config.getResults()));
|
||||
}
|
||||
|
||||
|
||||
return list.toArray();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.search.IHostSearchResultSet#removeAllResults()
|
||||
*/
|
||||
public void removeAllResults() {
|
||||
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
config.removeResults();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.search.IHostSearchResultSet#getNumOfResults()
|
||||
*/
|
||||
public int getNumOfResults() {
|
||||
|
||||
|
||||
int resultSize = 0;
|
||||
|
||||
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
resultSize += config.getResultsSize();
|
||||
}
|
||||
|
||||
|
||||
return resultSize;
|
||||
}
|
||||
|
||||
|
@ -155,13 +155,13 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable
|
|||
* @see org.eclipse.rse.services.search.IHostSearchResultSet#cancel()
|
||||
*/
|
||||
public void cancel() {
|
||||
|
||||
|
||||
// cancel each config that is running
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
|
||||
|
||||
if (config.getStatus() == IHostSearchConstants.RUNNING) {
|
||||
config.cancel();
|
||||
}
|
||||
|
@ -173,60 +173,60 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable
|
|||
*/
|
||||
public void removeResult(Object result) {
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
config.removeResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.search.IHostSearchResultSet#removeAndAddResult(java.lang.Object, java.lang.Object)
|
||||
*/
|
||||
public void removeAndAddResult(Object oldResult, Object newResult) {
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
config.removeAndAddResult(oldResult, newResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.search.IHostSearchResultSet#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
|
||||
|
||||
// first cancel all configs that are still running
|
||||
cancel();
|
||||
|
||||
|
||||
// now dispose each configuration
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
config.dispose();
|
||||
}
|
||||
|
||||
|
||||
// remove all the configurations
|
||||
configurations.removeAllElements();
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.search.IHostSearchResultSet#isCancelled()
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
|
||||
|
||||
// if a config is not cancelled, the search is not cancelled
|
||||
if (config.getStatus() != IHostSearchConstants.CANCELED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -235,16 +235,16 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable
|
|||
*/
|
||||
public boolean isFinished() {
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
|
||||
|
||||
// if a config is not finished, the search is not finished
|
||||
if (config.getStatus() != IHostSearchConstants.FINISHED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -253,16 +253,16 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable
|
|||
*/
|
||||
public boolean isRunning() {
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
|
||||
|
||||
// if a config is running, the search is running
|
||||
if (config.getStatus() == IHostSearchConstants.RUNNING) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -271,23 +271,17 @@ public class HostSearchResultSet implements IHostSearchResultSet, IAdaptable
|
|||
*/
|
||||
public boolean isDisconnected() {
|
||||
Iterator iter = getSearchConfigurations();
|
||||
|
||||
|
||||
while (iter.hasNext()) {
|
||||
IHostSearchResultConfiguration config = (IHostSearchResultConfiguration)iter.next();
|
||||
|
||||
|
||||
// if a config is not disconnected, the search is not disconnected
|
||||
if (config.getStatus() != IHostSearchConstants.DISCONNECTED) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
public Object getAdapter(Class adapter) {
|
||||
return Platform.getAdapterManager().getAdapter(this, adapter);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,24 +1,34 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.search;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.files.IFileService;
|
||||
|
||||
/**
|
||||
* RSE Search Service Interface.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* Search service implementations must subclass
|
||||
* {@link AbstractSearchService} rather than implementing this
|
||||
* interface directly.
|
||||
*/
|
||||
public interface ISearchService
|
||||
{
|
||||
public void search(IHostSearchResultConfiguration searchConfig, IFileService fileService, IProgressMonitor monitor);
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 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:
|
||||
* Martin Oberhuber (Wind River) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.shells;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.AbstractService;
|
||||
|
||||
/**
|
||||
* Abstract base class for RSE Shell Service implementations.
|
||||
*/
|
||||
public abstract class AbstractShellService extends AbstractService implements IShellService {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.shells.IShellService#getHostEnvironment()
|
||||
*/
|
||||
public String[] getHostEnvironment() {
|
||||
// not implemented by default
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.shells.IShellService#launchShell(java.lang.String, java.lang.String[], org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor) {
|
||||
return launchShell(initialWorkingDirectory, null, environment, monitor);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.rse.services.shells.IShellService#runCommand(java.lang.String, java.lang.String, java.lang.String[], org.eclipse.core.runtime.IProgressMonitor)
|
||||
*/
|
||||
public IHostShell runCommand(String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor) {
|
||||
return runCommand(initialWorkingDirectory, command, null, environment, monitor);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +1,122 @@
|
|||
/********************************************************************************
|
||||
* Copyright (c) 2006, 2007 IBM Corporation and others. All rights reserved.
|
||||
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
|
||||
* available at http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
*
|
||||
* Initial Contributors:
|
||||
* The following IBM employees contributed to the Remote System Explorer
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* component that contains this file: David McKnight, Kushal Munir,
|
||||
* Michael Berger, David Dykstal, Phil Coulthard, Don Yantzi, Eric Simpson,
|
||||
* Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley.
|
||||
*
|
||||
*
|
||||
* Contributors:
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
********************************************************************************/
|
||||
|
||||
package org.eclipse.rse.services.shells;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
import org.eclipse.rse.services.IService;
|
||||
|
||||
/**
|
||||
* IShellService is an abstraction for running shells and
|
||||
* shell commands
|
||||
* IShellService is an abstraction for running shells and shell commands.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
* Search service implementations must subclass
|
||||
* {@link AbstractShellService} rather than implementing this
|
||||
* interface directly.
|
||||
*/
|
||||
public interface IShellService extends IService
|
||||
{
|
||||
/**
|
||||
* Launch a new shell in the specified directory
|
||||
* @param initialWorkingDirectory
|
||||
* @param environment Array of environment variable Strings of the form "var=text"
|
||||
* @param monitor
|
||||
* @return the shell object
|
||||
* Launch a new shell in the specified directory with a default encoding.
|
||||
*
|
||||
* This is a convenience method, passing <code>null</code> as encoding
|
||||
* into {@link #launchShell(String, String, String[], IProgressMonitor)}.
|
||||
*/
|
||||
public IHostShell launchShell(String initialWorkingDirectory, String[] environment, IProgressMonitor monitor);
|
||||
|
||||
|
||||
/**
|
||||
* Launch a new shell in the specified directory
|
||||
* @param initialWorkingDirectory
|
||||
* @param encoding
|
||||
* @param environment Array of environment variable Strings of the form "var=text"
|
||||
* @param monitor
|
||||
* @return the shell object
|
||||
* Launch a new shell in the specified directory.
|
||||
*
|
||||
* @param initialWorkingDirectory initial working directory or
|
||||
* <code>null</code> if not relevant. The remote shell will
|
||||
* launch in a directory of its own choice in that case
|
||||
* (typically a user's home directory).
|
||||
* @param encoding Stream encoding to use, or <code>null</code> to fall
|
||||
* back to a default encoding. The Shell Service will make
|
||||
* efforts to determine a proper default encoding on the remote
|
||||
* side but this is not guaranteed to be correct.
|
||||
* @param environment Array of environment variable Strings of the form
|
||||
* "var=text". Since not all shell implementations support the
|
||||
* passing of environment variables, there is no guarantee that
|
||||
* the created shell will actually have the specified environment
|
||||
* set.
|
||||
* @param monitor Progress Monitor for monitoring and cancellation
|
||||
* @return the shell object. Note that the shell may not actually be usable
|
||||
* in case an error occurred or the operation was canceled. In this
|
||||
* case, {@link IHostShell#isActive()} returns <code>false</code>
|
||||
* on the created Shell object.
|
||||
*/
|
||||
public IHostShell launchShell(String initialWorkingDirectory, String encoding, String[] environment, IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* Run a command in it's own shell
|
||||
* @param initialWorkingDirectory
|
||||
* @param command
|
||||
* @param environment Array of environment variable Strings of the form "var=text"
|
||||
* @param monitor
|
||||
* @return the shell object for getting output and error streams
|
||||
*
|
||||
* Run a single command in it's own shell with a default encoding.
|
||||
*
|
||||
* This is a convenience method, passing <code>null</code> as encoding
|
||||
* into
|
||||
* {@link #runCommand(String, String, String, String[], IProgressMonitor)}.
|
||||
*/
|
||||
public IHostShell runCommand(String initialWorkingDirectory, String command, String[] environment, IProgressMonitor monitor);
|
||||
|
||||
|
||||
/**
|
||||
* Run a command in it's own shell
|
||||
* @param initialWorkingDirectory
|
||||
* @param command
|
||||
* @param encoding
|
||||
* @param environment Array of environment variable Strings of the form "var=text"
|
||||
* @param monitor
|
||||
* @return the shell object for getting output and error streams
|
||||
* Run a single command in it's own shell.
|
||||
*
|
||||
* This method is similar to
|
||||
* {@link #launchShell(String, String, String[], IProgressMonitor)} but
|
||||
* immediately executes a specified command rather than just opening a
|
||||
* shell. There is no guarantee that after the host shell will accept any
|
||||
* subsequent commands after the initial command has been executed; there
|
||||
* is, however, also no guarantee that the host shell will terminate the
|
||||
* connection automatically. Clients need to call {@link IHostShell#exit()}
|
||||
* in case the shell remains active after the initial command is completed.
|
||||
*
|
||||
* @param initialWorkingDirectory initial working directory or
|
||||
* <code>null</code> if not relevant. The remote shell will
|
||||
* launch in a directory of its own choice in that case
|
||||
* (typically a user's home directory).
|
||||
* @param encoding Stream encoding to use, or <code>null</code> to fall
|
||||
* back to a default encoding. The Shell Service will make
|
||||
* efforts to determine a proper default encoding on the remote
|
||||
* side but this is not guaranteed to be correct.
|
||||
* @param environment Array of environment variable Strings of the form
|
||||
* "var=text". Since not all shell implementations support the
|
||||
* passing of environment variables, there is no guarantee that
|
||||
* the created shell will actually have the specified environment
|
||||
* set.
|
||||
* @param monitor Progress Monitor for monitoring and cancellation
|
||||
* @return the shell object for getting output and error streams. Note that
|
||||
* the shell may not actually be usable in case an error occurred or
|
||||
* the operation was canceled. In this case,
|
||||
* {@link IHostShell#isActive()} returns <code>false</code> on the
|
||||
* created Shell object.
|
||||
*/
|
||||
public IHostShell runCommand(String initialWorkingDirectory, String command, String encoding, String[] environment, IProgressMonitor monitor);
|
||||
|
||||
/**
|
||||
* Return an array of environment variables that describe the environment on the host.
|
||||
* Each String returned is of the format "var=text": Everything up to the
|
||||
* first equals sign is the name of the given environment variable, everything
|
||||
* after the equals sign is its contents.
|
||||
* @return Array of environment variable Strings of the form "var=text"
|
||||
* Return an array of environment variables that describe the environment on
|
||||
* the remote system. Each String returned is of the format "var=text":
|
||||
* Everything up to the first equals sign is the name of the given
|
||||
* environment variable, everything after the equals sign is its contents.
|
||||
*
|
||||
* @return Array of environment variable Strings of the form "var=text" if
|
||||
* supported by a shell service implementation. May return
|
||||
* <code>null</code> in case environment variable retrieval is not
|
||||
* supported on a particular shell service implementation.
|
||||
*/
|
||||
public String[] getHostEnvironment();
|
||||
}
|
|
@ -1,15 +1,16 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2007 MontaVista Software, 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:
|
||||
* Copyright (c) 2006, 2008 MontaVista Software, 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:
|
||||
* Yu-Fen Kuo (MontaVista) - initial API and implementation
|
||||
* Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere
|
||||
* Martin Oberhuber (Wind River) - [refactor] "shell" instead of "ssh" everywhere
|
||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||
* David McKnight (IBM) - [175308] Need to use a job to wait for shell to exit
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable and add Javadoc
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.rse.internal.subsystems.processes.shell.linux;
|
||||
|
@ -36,7 +37,7 @@ import org.eclipse.rse.subsystems.shells.core.subsystems.servicesubsystem.IShell
|
|||
|
||||
/**
|
||||
* class to fetch remote linux target's process info
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class LinuxShellProcessService extends AbstractProcessService {
|
||||
|
||||
|
@ -54,7 +55,7 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
|||
|
||||
/**
|
||||
* constructor
|
||||
*
|
||||
*
|
||||
* @param host the connection to work on
|
||||
*/
|
||||
public LinuxShellProcessService(final IHost host) {
|
||||
|
@ -167,11 +168,11 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
|||
} catch (IOException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
|
||||
|
||||
// Wait for remote process to exit.
|
||||
WaiterJob waiter = new WaiterJob(p);
|
||||
waiter.schedule();
|
||||
|
||||
|
||||
return (IHostProcess[]) hostProcessList
|
||||
.toArray(new IHostProcess[hostProcessList.size()]);
|
||||
}
|
||||
|
@ -185,14 +186,12 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
|||
}
|
||||
|
||||
public void initService(final IProgressMonitor monitor) {
|
||||
super.initService(monitor);
|
||||
linuxProcessHelper = new LinuxProcessHelper();
|
||||
// initialize username /uid hashmap before getting any process
|
||||
linuxProcessHelper.populateUsernames(host);
|
||||
}
|
||||
|
||||
public void uninitService(final IProgressMonitor monitor) {
|
||||
}
|
||||
|
||||
private boolean progressWorked(final IProgressMonitor monitor,
|
||||
final int work) {
|
||||
boolean cancelRequested = false;
|
||||
|
@ -207,7 +206,7 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
|||
* Returns a list of the signal types supported by the 'kill' command on
|
||||
* this system. Signal Types will be used in the Kill dialog for user to
|
||||
* choose which signal they want to use for killing a process.
|
||||
*
|
||||
*
|
||||
* @return a list of the signal types or null if there are none or there is
|
||||
* an error in executing the kill command.
|
||||
*/
|
||||
|
@ -253,7 +252,7 @@ public class LinuxShellProcessService extends AbstractProcessService {
|
|||
} catch (IOException e) {
|
||||
Activator.log(e);
|
||||
}
|
||||
|
||||
|
||||
// Wait for remote process to exit.
|
||||
WaiterJob waiter = new WaiterJob(p);
|
||||
waiter.schedule();
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Radoslav Gerganov - derived from SftpFileService and LocalFileService
|
||||
* Martin Oberhuber (Wind River) - [226262] Make IService IAdaptable
|
||||
*******************************************************************************/
|
||||
package org.eclipse.rse.internal.services.wince.files;
|
||||
|
||||
|
@ -41,11 +42,11 @@ import org.eclipse.tm.rapi.RapiFindData;
|
|||
public class WinCEFileService extends AbstractFileService implements IWinCEService {
|
||||
|
||||
IRapiSessionProvider sessionProvider;
|
||||
|
||||
|
||||
public WinCEFileService(IRapiSessionProvider sessionProvider) {
|
||||
this.sessionProvider = sessionProvider;
|
||||
}
|
||||
|
||||
|
||||
String concat(String parentDir, String fileName) {
|
||||
String result = parentDir;
|
||||
if (!result.endsWith("\\")) { //$NON-NLS-1$
|
||||
|
@ -54,7 +55,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
result += fileName;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected IHostFile[] internalFetch(String parentPath, String fileFilter,
|
||||
int fileType, IProgressMonitor monitor) throws SystemMessageException {
|
||||
if (fileFilter == null) {
|
||||
|
@ -71,7 +72,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
try {
|
||||
IRapiSession session = sessionProvider.getSession();
|
||||
RapiFindData[] foundFiles = session.findAllFiles(concat(parentPath,"*"), //$NON-NLS-1$
|
||||
Rapi.FAF_NAME | Rapi.FAF_ATTRIBUTES | Rapi.FAF_LASTWRITE_TIME |
|
||||
Rapi.FAF_NAME | Rapi.FAF_ATTRIBUTES | Rapi.FAF_LASTWRITE_TIME |
|
||||
Rapi.FAF_SIZE_HIGH | Rapi.FAF_SIZE_LOW);
|
||||
for (int i = 0 ; i < foundFiles.length ; i++) {
|
||||
String fileName = foundFiles[i].fileName;
|
||||
|
@ -104,11 +105,11 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
}
|
||||
return (attr & Rapi.FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||
}
|
||||
|
||||
|
||||
private boolean exist(IRapiSession session, String fileName) {
|
||||
return session.getFileAttributes(fileName) != -1;
|
||||
}
|
||||
|
||||
|
||||
public boolean copy(String srcParent, String srcName, String tgtParent,
|
||||
String tgtName, IProgressMonitor monitor) throws SystemMessageException {
|
||||
String srcFullPath = concat(srcParent, srcName);
|
||||
|
@ -158,7 +159,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
String fullPath = concat(remoteParent, fileName);
|
||||
IRapiSession session = sessionProvider.getSession();
|
||||
try {
|
||||
int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, Rapi.FILE_SHARE_READ,
|
||||
int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE, Rapi.FILE_SHARE_READ,
|
||||
Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL);
|
||||
session.closeHandle(handle);
|
||||
RapiFindData findData = new RapiFindData();
|
||||
|
@ -203,14 +204,14 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
}
|
||||
} catch (RapiException e) {
|
||||
//FIXME error handling
|
||||
throw new RemoteFileException(e.getMessage());
|
||||
throw new RemoteFileException(e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean download(String remoteParent, String remoteFile, File localFile, boolean isBinary, String hostEncoding,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
|
||||
|
||||
if (!localFile.exists()) {
|
||||
File localParentFile = localFile.getParentFile();
|
||||
if (!localParentFile.exists()) {
|
||||
|
@ -222,7 +223,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
int handle = Rapi.INVALID_HANDLE_VALUE;
|
||||
BufferedOutputStream bos = null;
|
||||
try {
|
||||
handle = session.createFile(fullPath, Rapi.GENERIC_READ,
|
||||
handle = session.createFile(fullPath, Rapi.GENERIC_READ,
|
||||
Rapi.FILE_SHARE_READ, Rapi.OPEN_EXISTING, Rapi.FILE_ATTRIBUTE_NORMAL);
|
||||
bos = new BufferedOutputStream(new FileOutputStream(localFile));
|
||||
// don't increase the buffer size! the native functions sometimes fail with large buffers, 4K always work
|
||||
|
@ -288,14 +289,14 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName,
|
||||
public boolean move(String srcParent, String srcName, String tgtParent, String tgtName,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
boolean ok = copy(srcParent, srcName, tgtParent, tgtName, monitor);
|
||||
ok = ok && delete(srcParent, srcName, monitor);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public boolean rename(String remoteParent, String oldName, String newName,
|
||||
public boolean rename(String remoteParent, String oldName, String newName,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
String oldFullPath = concat(remoteParent, oldName);
|
||||
String newFullPath = concat(remoteParent, newName);
|
||||
|
@ -309,7 +310,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile,
|
||||
public boolean rename(String remoteParent, String oldName, String newName, IHostFile oldFile,
|
||||
IProgressMonitor monitor) throws SystemMessageException {
|
||||
boolean retVal = rename(remoteParent, oldName, newName, monitor);
|
||||
String newFullPath = concat(remoteParent, newName);
|
||||
|
@ -332,7 +333,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
String fullPath = concat(remoteParent, remoteFile);
|
||||
int handle = Rapi.INVALID_HANDLE_VALUE;
|
||||
try {
|
||||
handle = session.createFile(fullPath, Rapi.GENERIC_WRITE,
|
||||
handle = session.createFile(fullPath, Rapi.GENERIC_WRITE,
|
||||
Rapi.FILE_SHARE_READ, Rapi.CREATE_ALWAYS, Rapi.FILE_ATTRIBUTE_NORMAL);
|
||||
// don't increase the buffer size! the native functions sometimes fail with large buffers, 4K always work
|
||||
byte[] buffer = new byte[4 * 1024];
|
||||
|
@ -366,7 +367,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary,
|
||||
public boolean upload(File localFile, String remoteParent, String remoteFile, boolean isBinary,
|
||||
String srcEncoding, String hostEncoding, IProgressMonitor monitor) throws SystemMessageException {
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
|
@ -384,7 +385,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
String fullPath = concat(remoteParent, remoteFile);
|
||||
IRapiSession session = sessionProvider.getSession();
|
||||
try {
|
||||
int handle = session.createFile(fullPath, Rapi.GENERIC_READ,
|
||||
int handle = session.createFile(fullPath, Rapi.GENERIC_READ,
|
||||
Rapi.FILE_SHARE_READ, Rapi.OPEN_EXISTING, Rapi.FILE_ATTRIBUTE_NORMAL);
|
||||
return new BufferedInputStream(new WinCEInputStream(session, handle));
|
||||
} catch (RapiException e) {
|
||||
|
@ -404,7 +405,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
} else {
|
||||
cd = Rapi.OPEN_EXISTING;
|
||||
}
|
||||
int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE,
|
||||
int handle = session.createFile(fullPath, Rapi.GENERIC_WRITE,
|
||||
Rapi.FILE_SHARE_READ, cd, Rapi.FILE_ATTRIBUTE_NORMAL);
|
||||
return new BufferedOutputStream(new WinCEOutputStream(session, handle));
|
||||
} catch (RapiException e) {
|
||||
|
@ -421,22 +422,16 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
return Messages.WinCEFileService_1;
|
||||
}
|
||||
|
||||
public void initService(IProgressMonitor monitor) {
|
||||
}
|
||||
|
||||
public void uninitService(IProgressMonitor monitor) {
|
||||
}
|
||||
|
||||
private static class WinCEInputStream extends InputStream {
|
||||
|
||||
private int handle;
|
||||
private IRapiSession session;
|
||||
|
||||
|
||||
public WinCEInputStream(IRapiSession session, int handle) {
|
||||
this.handle = handle;
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
|
||||
public int read() throws IOException {
|
||||
byte[] b = new byte[1];
|
||||
try {
|
||||
|
@ -462,19 +457,19 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static class WinCEOutputStream extends OutputStream {
|
||||
|
||||
private int handle;
|
||||
private IRapiSession session;
|
||||
|
||||
|
||||
public WinCEOutputStream(IRapiSession session, int handle) {
|
||||
this.session = session;
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
|
||||
public void write(int b) throws IOException {
|
||||
try {
|
||||
session.writeFile(handle, new byte[] {(byte)b});
|
||||
|
@ -490,7 +485,7 @@ public class WinCEFileService extends AbstractFileService implements IWinCEServi
|
|||
throw new IOException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
session.closeHandle(handle);
|
||||
|
|
Loading…
Add table
Reference in a new issue