true
if the character is a special character, false
otherwise.
*/
protected boolean isSpecialChar(char c) {
-
+
if ((c == '$') || (c == '`') || (c == '"') || (c == '\\')) {
return true;
}
@@ -1659,15 +1658,15 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
DataStore ds = getDataStore();
String srcRemotePath = srcParent + getSeparator(srcParent) + srcName;
DataElement srcDE = getElementFor(srcRemotePath);
-
+
DataElement tgtDE = getElementFor(tgtParent);
if (tgtDE.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
{
dsQueryCommand(tgtDE, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor);
}
-
+
DataElement cpCmd = getCommandDescriptor(tgtDE, IUniversalDataStoreConstants.C_COPY);
-
+
if (cpCmd != null)
{
ArrayList args = new ArrayList();
@@ -1675,21 +1674,21 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
DataElement nameObj = ds.createObject(null, "name", tgtName); //$NON-NLS-1$
args.add(nameObj);
DataElement status = ds.command(cpCmd, args, tgtDE, true);
-
+
try
{
getStatusMonitor(ds).waitForUpdate(status, monitor);
-
+
if (status.getAttribute(DE.A_SOURCE).equals(IServiceConstants.FAILED)) {
String msgTxt = NLS.bind(ServiceResources.FILEMSG_COPY_FILE_FAILED, srcName);
String msgDetails = ServiceResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
- SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
+ SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_COPY_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
-
- throw new SystemMessageException(msg);
+
+ throw new SystemMessageException(msg);
}
}
catch (InterruptedException e)
@@ -1697,9 +1696,9 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
if (monitor != null && monitor.isCanceled())
{
//This operation has been canceled by the user.
- throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
+ throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
ICommonMessageIds.MSG_OPERATION_CANCELED,
- IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED));
+ IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED));
}
// cancel monitor if it's still not canceled
if (monitor != null && !monitor.isCanceled())
@@ -1715,12 +1714,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
public boolean copyBatch(String[] srcParents, String[] srcNames, String tgtParent, IProgressMonitor monitor) throws SystemMessageException
{
DataStore ds = getDataStore();
-
+
DataElement tgtDE = getElementFor(tgtParent);
if (tgtDE.getType().equals(IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR))
{
// get the property queried object
- dsQueryCommand(tgtDE, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor);
+ dsQueryCommand(tgtDE, IUniversalDataStoreConstants.C_QUERY_GET_REMOTE_OBJECT, monitor);
}
DataElement cpCmd = getCommandDescriptor(tgtDE, IUniversalDataStoreConstants.C_COPY_BATCH);
@@ -1738,16 +1737,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
try
{
getStatusMonitor(ds).waitForUpdate(status, monitor);
-
+
if (status.getAttribute(DE.A_SOURCE).equals(IServiceConstants.FAILED)) {
-
+
String msgTxt = NLS.bind(ServiceResources.FILEMSG_COPY_FILE_FAILED, srcNames[0]);
String msgDetails = ServiceResources.FILEMSG_COPY_FILE_FAILED_DETAILS;
- SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
+ SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_COPY_FILE_FAILED,
IStatus.ERROR, msgTxt, msgDetails);
-
- throw new SystemMessageException(msg);
+
+ throw new SystemMessageException(msg);
}
}
catch (InterruptedException e)
@@ -1755,16 +1754,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
if (monitor != null && monitor.isCanceled())
{
//This operation has been canceled by the user.
- throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
+ throw new SystemMessageException(new SimpleSystemMessage(Activator.PLUGIN_ID,
ICommonMessageIds.MSG_OPERATION_CANCELED,
- IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED));
+ IStatus.CANCEL, CommonMessages.MSG_OPERATION_CANCELED));
}
// 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
}
@@ -1776,17 +1775,17 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
for (int i = 0; i < srcParents.length && result; i++){
String parent = srcParents[i];
String name = srcNames[i];
- result = copy(parent, name, tgtParent, name, monitor);
+ result = copy(parent, name, tgtParent, name, monitor);
}
return result;
-
+
}
}
-
+
public IHostFile[] getRoots(IProgressMonitor monitor)
{
if (!isInitialized())
@@ -1795,14 +1794,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
}
DataStore ds = getDataStore();
DataElement universaltemp = getMinerElement();
-
+
// create filter descriptor
DataElement deObj = ds.createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, "", "", "", false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
DataElement[] results = dsQueryCommand(deObj, IUniversalDataStoreConstants.C_QUERY_ROOTS, monitor);
-
+
return convertToHostFiles(results, "*"); //$NON-NLS-1$
}
-
+
private String getQueryString(int fileType)
{
String queryString = null;
@@ -1811,19 +1810,19 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
case IFileService.FILE_TYPE_FILES:
queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_FILES;
break;
-
+
case IFileService.FILE_TYPE_FOLDERS:
queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_FOLDERS;
break;
-
+
case IFileService.FILE_TYPE_FILES_AND_FOLDERS:
- default:
+ default:
queryString = IUniversalDataStoreConstants.C_QUERY_VIEW_ALL;
break;
}
return queryString;
}
-
+
private String[] getQueryStrings(int[] fileTypes)
{
String[] queryStrings = new String[fileTypes.length];
@@ -1834,13 +1833,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
case IFileService.FILE_TYPE_FILES:
queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_FILES;
break;
-
+
case IFileService.FILE_TYPE_FOLDERS:
queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_FOLDERS;
break;
-
+
case IFileService.FILE_TYPE_FILES_AND_FOLDERS:
- default:
+ default:
queryStrings[i] = IUniversalDataStoreConstants.C_QUERY_VIEW_ALL;
break;
}
@@ -1850,26 +1849,26 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
public IHostFile[] list(String remoteParent, String fileFilter, int fileType, IProgressMonitor monitor)
{
- String queryString = getQueryString(fileType);
+ String queryString = getQueryString(fileType);
return fetch(remoteParent, fileFilter, queryString, monitor);
}
-
+
public IHostFile[] listMultiple(String[] remoteParents,
String[] fileFilters, int[] fileTypes, IProgressMonitor monitor)
- throws SystemMessageException
+ throws SystemMessageException
{
String[] queryStrings = getQueryStrings(fileTypes);
return fetchMulti(remoteParents, fileFilters, queryStrings, monitor);
}
-
+
public IHostFile[] listMultiple(String[] remoteParents,
String[] fileFilters, int fileType, IProgressMonitor monitor)
- throws SystemMessageException
+ throws SystemMessageException
{
String queryString = getQueryString(fileType);
-
+
// create array of the same query string
String[] queryStrings = new String[remoteParents.length];
for (int i = 0; i < remoteParents.length; i++)
@@ -1879,7 +1878,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
return fetchMulti(remoteParents, fileFilters, queryStrings, monitor);
}
-
+
protected String[] getPathsFor(String[] remoteParents, String[] remoteFiles)
{
String[] results = new String[remoteParents.length];
@@ -1892,37 +1891,37 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{
sep = getSeparator(remoteParent);
}
-
+
results[i] = remoteParent + sep + remoteFile;
}
return results;
}
-
+
protected DataElement[] getElementsFor(String[] paths)
{
DataElement[] results = new DataElement[paths.length];
for (int i = 0; i < paths.length; i++)
{
- results[i] = getElementFor(paths[i]);
+ results[i] = getElementFor(paths[i]);
}
return results;
}
-
+
protected DataElement getElementFor(String path)
{
if (!isInitialized())
{
waitForInitialize(null);
}
-
+
DataStore ds = getDataStore();
-
- // with 207095, it's possible to get here when disconnected and no dstore
+
+ // with 207095, it's possible to get here when disconnected and no dstore
if (ds == null){
return null;
}
-
+
String normalizedPath = PathUtility.normalizeUnknown(path);
DataElement element = (DataElement)_fileElementMap.get(normalizedPath);
if (element != null && element.isDeleted())
@@ -1937,8 +1936,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
}
return element;
}
-
-
+
+
/**
* Get a dstore IHostFile object for the given absolute path, provided
* that the file object has been accessed before and is available in our
@@ -1950,7 +1949,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{
return (IHostFile)_dstoreFileMap.get(path);
}
-
+
protected IHostFile[] fetch(String remoteParent, String fileFilter, String queryType, IProgressMonitor monitor)
{
DataStore ds = getDataStore();
@@ -1958,7 +1957,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{
return new IHostFile[0];
}
-
+
// create filter descriptor
DataElement deObj = getElementFor(remoteParent);
if (deObj == null)
@@ -1966,18 +1965,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
DataElement universaltemp = getMinerElement();
ds.createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, remoteParent, remoteParent, "", false); //$NON-NLS-1$
}
-
+
DataElement attributes = getAttributes(fileFilter, true);
ArrayList args = new ArrayList(1);
args.add(attributes);
-
- DataElement[] results = dsQueryCommand(deObj, args, queryType, monitor);
+
+ DataElement[] results = dsQueryCommand(deObj, args, queryType, monitor);
return convertToHostFiles(results, fileFilter);
}
-
+
/**
* Fetch multiple results (for different parents an filters
- *
+ *
* @param remoteParents the parents to query
* @param fileFilters the filters for each parent to query
* @param queryTypes the type of queries (for each parent) - files, folders, both, etc
@@ -1991,10 +1990,10 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{
return new IHostFile[0];
}
-
+
ArrayList[] argses = new ArrayList[remoteParents.length];
DataElement subjects[] = new DataElement[remoteParents.length];
-
+
for (int i = 0; i < remoteParents.length; i++)
{
// create filter descriptor
@@ -2005,14 +2004,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
deObj = ds.createObject(universaltemp, IUniversalDataStoreConstants.UNIVERSAL_FILTER_DESCRIPTOR, remoteParents[i], remoteParents[i], "", false); //$NON-NLS-1$
}
subjects[i] = deObj;
-
+
DataElement attributes = getAttributes(fileFilters[i], true);
ArrayList args = new ArrayList(1);
args.add(attributes);
argses[i] = args;
}
-
- List consolidatedResults = dsQueryCommandMulti(subjects, argses, queryTypes, monitor);
+
+ List consolidatedResults = dsQueryCommandMulti(subjects, argses, queryTypes, monitor);
List convertedResults = new ArrayList();
for (int r = 0; r < consolidatedResults.size(); r++)
{
@@ -2022,7 +2021,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
convertedResults.add(results[c]);
}
}
-
+
return (IHostFile[])convertedResults.toArray(new IHostFile[consolidatedResults.size()]);
}
@@ -2032,7 +2031,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
}
public boolean setLastModified(String parent, String name,
- long timestamp, IProgressMonitor monitor) throws SystemMessageException
+ long timestamp, IProgressMonitor monitor) throws SystemMessageException
{
String remotePath = parent + getSeparator(parent) + name;
DataElement de = getElementFor(remotePath);
@@ -2048,12 +2047,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
return true;
}
}
-
+
return false;
}
public boolean setReadOnly(String parent, String name,
- boolean readOnly, IProgressMonitor monitor) throws SystemMessageException
+ boolean readOnly, IProgressMonitor monitor) throws SystemMessageException
{
String remotePath = parent + getSeparator(parent) + name;
DataElement de = getElementFor(remotePath);
@@ -2072,7 +2071,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
}
catch (Exception e)
{
-
+
}
return true;
}
@@ -2086,14 +2085,14 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
* @since 2.0
*/
public String getEncoding(IProgressMonitor monitor) throws SystemMessageException {
-
+
if (remoteEncoding == null) {
-
+
DataStore ds = getDataStore();
if (ds != null)
{
DataElement encodingElement = ds.createObject(null, IUniversalDataStoreConstants.UNIVERSAL_TEMP_DESCRIPTOR, ""); //$NON-NLS-1$
-
+
DataElement queryCmd = ds.localDescriptorQuery(encodingElement.getDescriptor(),IUniversalDataStoreConstants.C_SYSTEM_ENCODING);
DataElement status = ds.command(queryCmd, encodingElement, true);
@@ -2103,7 +2102,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
}
catch (Exception e) {
}
-
+
remoteEncoding = encodingElement.getValue();
}
}
@@ -2114,7 +2113,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
/* (non-Javadoc)
* @see org.eclipse.rse.services.files.IFileService#getInputStream(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, boolean)
*/
- public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException
+ public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException
{
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
int mode;
@@ -2138,7 +2137,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
return getOutputStream(remoteParent, remoteFile, options, monitor);
}
-
+
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
@@ -2152,11 +2151,11 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
{
mode = IUniversalDataStoreConstants.TEXT_MODE;
}
-
+
DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, options);
return outputStream;
}
-
+
/**
* Sets whether this is a Unix-style file system or a Windows-style file system. The
* default is Windows if this is not called. The creator of this class should call this to set the type of the file system.
@@ -2165,12 +2164,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
public void setIsUnixStyle(boolean isUnixStyle) {
this.unixStyle = isUnixStyle;
}
-
+
public boolean supportsEncodingConversion(){
return true;
}
-
+
public IHostFilePermissions getFilePermissions(IHostFile rfile, IProgressMonitor monitor)
throws SystemMessageException {
DStoreHostFile file = (DStoreHostFile)rfile;
@@ -2183,41 +2182,41 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
file.setPermissions(result);
}
*/
-
+
DataElement remoteFile = file.getDataElement();
-
+
DataElement status = dsStatusCommand(remoteFile, IUniversalDataStoreConstants.C_QUERY_FILE_PERMISSIONS, monitor);
- if (status != null) {
+ if (status != null) {
int permissionsInt = 0;
-
+
// access string in the form super.initService(monitor)
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 super.uninitService(monitor)
as the last
+ * call in their implementation.
+ */
+ public void uninitService(IProgressMonitor monitor) {
+ // Do nothing by default
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/IService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/IService.java
index d000941f91c..0dfd75c7b47 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/IService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/IService.java
@@ -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);
}
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java
index 52e652bd5dd..2510aa50702 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java
@@ -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 null
.
- * 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 null
. 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 null
.
@@ -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.
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html
new file mode 100644
index 00000000000..f2afc79f665
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/package.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+ +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. +
+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:
+IAdaptable
, IProgressMonitor
,
+IStatus
, NLS
, PlatformObject
+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.
+
- * 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 false
if the given process doesn't exist, else true
.
- * Throws an exception if anything fails.
- * @throws SystemMessageException
+ * @return false
if the given process doesn't exist, else
+ * true
. 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
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchService.java
index 486bf42816b..509f13d8ab7 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/AbstractSearchService.java
@@ -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);
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/HostSearchResultSet.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/HostSearchResultSet.java
index 70754b9d0bf..8a734215993 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/HostSearchResultSet.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/HostSearchResultSet.java
@@ -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);
- }
+
}
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchService.java
index cd43259db68..db46e3d4fc4 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/search/ISearchService.java
@@ -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);
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java
new file mode 100644
index 00000000000..256c2515e0b
--- /dev/null
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractShellService.java
@@ -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);
+ }
+
+}
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IShellService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IShellService.java
index e2b6b5b76f9..28bb4a62823 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IShellService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/IShellService.java
@@ -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 null
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
+ * null
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 null
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 false
+ * 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 null
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
+ * null
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 null
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 false
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
+ * null
in case environment variable retrieval is not
+ * supported on a particular shell service implementation.
*/
public String[] getHostEnvironment();
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java
index b7212dfadd8..9e9716c180e 100644
--- a/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java
+++ b/rse/plugins/org.eclipse.rse.subsystems.processes.shell.linux/src/org/eclipse/rse/internal/subsystems/processes/shell/linux/LinuxShellProcessService.java
@@ -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();
diff --git a/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java b/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java
index ce2c533e88f..8a90b973d52 100644
--- a/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java
+++ b/wince/org.eclipse.rse.subsystems.wince/src/org/eclipse/rse/internal/services/wince/files/WinCEFileService.java
@@ -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);