- * private SystemMutex fooMutex = new SystemMutex();
+ * A reentrant Exclusion Lock for Threads that need to access a resource in a
+ * serialized manner. If the request for the lock is running on the same thread
+ * who is currently holding the lock, it will "borrow" the lock, and the call to
+ * waitForLock() will go through. A SystemOperationMonitor is accepted in order
+ * to support cancellation when waiting for the Mutex. This is a clone of
+ * {@link org.eclipse.rse.services.Mutex} with some modification to make sure the
+ * sequential calls to waitForLock() method in the same thread will not be
+ * blocked.
+ *
+ * Usage Example:
+ * private SystemReentrantMutex fooMutex = new SystemReentrantMutex();
* boolean doFooSerialized()(ISystemOperationMonitor monitor) {
- * int mutexLockStatus = SystemMutex.LOCK_STATUS_NOLOCK;
+ * int mutexLockStatus = SystemReentrantMutex.LOCK_STATUS_NOLOCK;
* mutexLockStatus = fooMutex.waitForLock(monitor, 1000);
- * if (SystemMutex.LOCK_STATUS_NOLOCK != mutexLockStatus) {
+ * if (mutexLockStatus != SystemReentrantMutex.LOCK_STATUS_NOLOCK) {
* try {
* return doFoo();
* } finally {
* //We only release the mutex if we acquire it, not borrowed it.
- * if (SystemMutex.LOCK_STATUS_AQUIRED == mutexLockStatus)
- * {
- * fooMutex.release();
- * }
+ * if (mutexLockStatus == SystemReentrantMutex.LOCK_STATUS_AQUIRED)
+ * {
+ * fooMutex.release();
+ * }
* }
* }
* return false;
* }
*
- *
+ *
+ * @since 3.0
*/
public class SystemReentrantMutex {
diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java
index 318edf4bb43..6cce710c07f 100644
--- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java
+++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/archiveutils/SystemTgzHandler.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* 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:
+ * 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:
* Johnson Ma (Wind River) - initial API and implementation
*******************************************************************************/
package org.eclipse.rse.services.clientserver.archiveutils;
@@ -19,7 +19,9 @@ import java.util.zip.GZIPOutputStream;
import org.eclipse.rse.internal.services.clientserver.archiveutils.TgzFile;
/**
- * handler class for .tar.gz and .tgz files
+ * Handler class for .tar.gz and .tgz files.
+ *
+ * @since 3.0
*/
public class SystemTgzHandler extends SystemTarHandler {
@@ -30,25 +32,25 @@ public class SystemTgzHandler extends SystemTarHandler {
public SystemTgzHandler(File file) throws IOException {
super(file);
}
-
+
/**
* Gets a tar.gz file from the underlying file.
* @return the tar file, or null
if the tar file does not exist.
*/
protected TarFile getTarFile() {
-
+
TarFile tarFile = null;
-
+
try {
tarFile = new TgzFile(file);
}
catch (IOException e) {
// TODO: log error
}
-
+
return tarFile;
}
-
+
protected TarOutputStream getTarOutputStream(File outputFile) throws FileNotFoundException {
GZIPOutputStream zipOutputStream = null;
try{
diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java
index 807a94aacdc..cc89d0e304c 100644
--- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java
+++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/CommonMessages.java
@@ -17,7 +17,10 @@ package org.eclipse.rse.services.clientserver.messages;
import org.eclipse.osgi.util.NLS;
-
+/**
+ * Externalized Strings for common messages that all clients can use.
+ * @since 3.0
+ */
public class CommonMessages extends NLS {
private static String BUNDLE_NAME = "org.eclipse.rse.services.clientserver.messages.CommonMessages";//$NON-NLS-1$
diff --git a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java
index 84a2a44b3cd..0e309513e48 100644
--- a/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java
+++ b/rse/plugins/org.eclipse.rse.services/clientserver/org/eclipse/rse/services/clientserver/messages/SimpleSystemMessage.java
@@ -21,7 +21,11 @@ import java.io.StringWriter;
import org.eclipse.core.runtime.IStatus;
-
+/**
+ * An RSE SystemMessage that can be created from Strings (without XML parsing).
+ *
+ * @since 3.0
+ */
public class SimpleSystemMessage extends SystemMessage {
private String _pluginId;
@@ -47,13 +51,13 @@ public class SimpleSystemMessage extends SystemMessage {
/**
* Creates a String based System Message with severity, ID and String
* message details.
- *
+ *
* This allows using the RSE Messaging Framework based on simple String
* messages and IDs, rather than using XML Message files from
* {@link SystemMessageFile} along with the
* org.eclipse.rse.ui.SystemBasePlugin#loadMessageFile()
and
* org.eclipse.rse.ui.SystemBasePlugin#getMessage()
methods.
- *
+ *
* Clients can use either globally unique RSE message IDs or plugin-specific
* local IDs. RSE-global message IDs are of the form:
* RSE<subcomponent><number>, where the subcomponent is a single
@@ -65,17 +69,17 @@ public class SimpleSystemMessage extends SystemMessage {
* "C" for Communications
*
* and the number is a four digit number.
- *
+ *
* Some RSE-global message IDs are predefined in {@link ICommonMessageIds}.
* When used in a SimpleSystemMessage, these common message IDs must be used
* along with the matching message Strings from {@link CommonMessages}, in
* order to be consistent to the user. For example:
- *
+ *
*
* msg = new SimpleSystemMessage(Activator.PLUGIN_ID, ICommonMessageIds.MSG_COMM_AUTH_FAILED, IStatus.ERROR, CommonMessages.MSG_COMM_AUTH_FAILED, NLS.bind(
* CommonMessages.MSG_COMM_AUTH_FAILED_DETAILS, getHost().getAliasName()));
*
- *
+ *
* Plugin-specific local IDs are totally free to be defined by the
* plugin that creates a specific message, as long as they are not prefixed
* by "RSE". It is recommended that plugins define unique IDs for various
@@ -83,7 +87,7 @@ public class SimpleSystemMessage extends SystemMessage {
* users; but it is not a requirement. Local ID's are specific to the plugin
* ID: relative IDs are qualified by the specified plugin ID, so they live
* in the plugin ID namespace.
- *
+ *
* @param pluginId the id of the originating plugin
* @param messageId the RSE-global unique ID or plugin-specific local ID of
* the message
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java
index 949ce1f6c45..9cb68ec59cc 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/shells/AbstractHostShellOutputReader.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) - [197848] Fix shell terminated state when remote dies
* Martin Oberhuber (Wind River) - [217429] Make registering multiple output listeners thread-safe
@@ -27,16 +27,16 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
protected List _listeners;
protected int _waitIncrement = 2;
protected boolean _keepRunning = true;
-
+
protected List _linesOfOutput;
protected int _consumerOffset;
protected IHostShell _hostShell;
protected boolean _isErrorReader = false;
-
-
+
+
protected long _timeOfLastEvent = 0;
protected int _sizeAtLastEvent = 0;
-
+
public AbstractHostShellOutputReader(IHostShell hostShell, boolean isErrorReader)
{
_hostShell = hostShell;
@@ -46,17 +46,17 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
_isErrorReader = isErrorReader;
_timeOfLastEvent = System.currentTimeMillis();
}
-
+
public boolean isErrorReader()
{
return _isErrorReader;
}
-
+
public IHostShell getHostShell()
{
return _hostShell;
}
-
+
public void setWaitTime(int value)
{
_waitIncrement = value;
@@ -82,20 +82,20 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
finish();
_keepRunning = false;
}
-
+
}
-
+
protected void addLine(IHostOutput line)
- {
+ {
_linesOfOutput.add(line);
int sizenow = _linesOfOutput.size();
int deltaSize = sizenow - _sizeAtLastEvent;
-
+
long timenow = System.currentTimeMillis();
//if ((timenow - _timeOfLastEvent) > 10 || deltaSize > 2)
{
-
-
+
+
// notify listeners
HostShellChangeEvent event = new HostShellChangeEvent(_hostShell, this, _sizeAtLastEvent, deltaSize);
fireOutputChanged(event);
@@ -103,30 +103,31 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
_sizeAtLastEvent = sizenow;
}
}
-
+
+ /** @since 3.0 */
protected final synchronized void startIfNotAlive() {
if (!isAlive()) {
start();
}
}
-
+
public IHostOutput readLine()
{
if (!isAlive())
{
internalReadLine();
- startIfNotAlive();
+ startIfNotAlive();
}
- return (IHostOutput)_linesOfOutput.get(_consumerOffset++);
+ return (IHostOutput)_linesOfOutput.get(_consumerOffset++);
}
-
+
public IHostOutput readLine(int lineNumber)
{
- return (IHostOutput)_linesOfOutput.get(lineNumber);
+ return (IHostOutput)_linesOfOutput.get(lineNumber);
}
-
-
-
+
+
+
public void setLineOffset(int lineNumber)
{
_consumerOffset = lineNumber;
@@ -147,12 +148,12 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
if (!_keepRunning)
dispose();
}
-
+
public void dispose()
{
_listeners.clear();
}
-
+
public boolean isFinished()
{
return !_keepRunning;
@@ -166,7 +167,7 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
//dispose();
}
}
-
+
public void run()
{
while (_keepRunning)
@@ -189,7 +190,7 @@ public abstract class AbstractHostShellOutputReader extends Thread implements I
fireOutputChanged(event);
}
}
-
+
protected abstract IHostOutput internalReadLine();
}