com.sshtools.j2ssh
Class SshThread

java.lang.Object
  extended by java.lang.Thread
      extended by com.sshtools.j2ssh.SshThread
All Implemented Interfaces:
java.lang.Runnable

public class SshThread
extends java.lang.Thread

Enables the J2SSH application framework to execute threads in the context of a given session.

Since:
0.2.0
Version:
$Revision: 1.25 $
Author:
Lee David Painter

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  byte[] sessionId
          The raw session id generating during the first key exchange.
protected  java.lang.String sessionIdString
          A string representation of the session id.
protected  java.lang.String username
          The thread owner
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SshThread(java.lang.Runnable target, java.lang.String name, boolean daemon)
           Constructs an SshThread.
SshThread(java.lang.String name, boolean daemon)
           
 
Method Summary
 SshThread cloneThread(java.lang.Runnable target, java.lang.String name)
           Create's a cloned copy of this thread with the given target and name.
 boolean containsProperty(java.lang.String name)
           Determine if this thread contains the given property.
static java.lang.String getCurrentSessionId()
           Returns the session id of the current thread context.
static SshThread getCurrentThread()
           Returns the current SshThread.
static java.lang.String getCurrentThreadUser()
           Call to determine the username of the current thread context.
 java.lang.Object getProperty(java.lang.String name)
           Gets a property from this thread.
 java.lang.String getSessionIdString()
           Returns the session id string for this thread.
 java.lang.String getUsername()
           Gets the username for this thread.
static boolean hasUserContext()
           
 void setProperty(java.lang.String name, java.lang.Object value)
           Sets a property in the thread.
 void setSessionId(byte[] sessionId)
           Sets the session id for this thread.
 void setUsername(java.lang.String username)
           Set the username for this thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessionId

protected byte[] sessionId
The raw session id generating during the first key exchange.


sessionIdString

protected java.lang.String sessionIdString
A string representation of the session id.


username

protected java.lang.String username
The thread owner

Constructor Detail

SshThread

public SshThread(java.lang.Runnable target,
                 java.lang.String name,
                 boolean daemon)

Constructs an SshThread.

Parameters:
target - The target to execute
name - The name of the thread
daemon - run as a daemon thread?
Since:
0.2.0

SshThread

public SshThread(java.lang.String name,
                 boolean daemon)
Method Detail

setSessionId

public void setSessionId(byte[] sessionId)

Sets the session id for this thread.

Parameters:
sessionId - the session id created during the first key exchange.
Since:
0.2.0

getSessionIdString

public java.lang.String getSessionIdString()

Returns the session id string for this thread.

Returns:
a string representation of the session id
Since:
0.2.0

setUsername

public void setUsername(java.lang.String username)

Set the username for this thread.

Parameters:
username - the thread owner
Since:
0.2.0

getUsername

public java.lang.String getUsername()

Gets the username for this thread.

Returns:
the thread owner
Since:
0.2.0

cloneThread

public SshThread cloneThread(java.lang.Runnable target,
                             java.lang.String name)

Create's a cloned copy of this thread with the given target and name.

Parameters:
target - the target to execute
name - the thread name
Returns:
the cloned thread
Since:
0.2.0

setProperty

public void setProperty(java.lang.String name,
                        java.lang.Object value)

Sets a property in the thread.

Parameters:
name - the name of the property
value - the property value
Since:
0.2.0

getProperty

public java.lang.Object getProperty(java.lang.String name)

Gets a property from this thread.

Parameters:
name - the name of the property
Returns:
the property value
Since:
0.2.0

containsProperty

public boolean containsProperty(java.lang.String name)

Determine if this thread contains the given property.

Parameters:
name - the name of the property
Returns:
true if the property exists, otherwise false
Since:
0.2.0

getCurrentThreadUser

public static java.lang.String getCurrentThreadUser()
                                             throws SshRuntimeException

Call to determine the username of the current thread context.

This should be called when the caller is certain that the current thread is running in an SshThread context. If not a runtime exception is thrown.

Returns:
the owner of the current thread
Throws:
SshRuntimeException - if the current thread is not an SshThread
Since:
0.2.0

hasUserContext

public static boolean hasUserContext()

getCurrentSessionId

public static java.lang.String getCurrentSessionId()
                                            throws SshRuntimeException

Returns the session id of the current thread context.

This should be called when the caller is certain that the current thread is running in an SshThread context. If not a Runtime exception is thrown.

Returns:
the session id of the current thread
Throws:
SshRuntimeException - if the current thread is not an SshThread
Since:
0.2.0

getCurrentThread

public static SshThread getCurrentThread()
                                  throws SshRuntimeException

Returns the current SshThread.

This should be called when the caller is certain that the current thread is running in an SshThread context. If not a Runtime exception is thrown.

Returns:
the current SshThread
Throws:
SshRuntimeException - if the current thread is not an SshThread
Since:
0.2.0


Copyright © 2002-2003 Lee David Painter & Contributors. All Rights Reserved.