com.tivoli.twg.libs
Class ServiceThread

java.lang.Object
  extended byjava.lang.Thread
      extended bycom.tivoli.twg.libs.ServiceThread
All Implemented Interfaces:
java.lang.Runnable

public class ServiceThread
extends java.lang.Thread

This class is intended to accomplish several key behaviors in a JVM application : create and use a special ThreadGroup under that of the "main" thread and create a thread under that thread group to continue the processing of the main thread. The new thread group will have an alternate handler for unhandled exceptions, which will log the exceptions and terminate the JVM (as opposed to the default handler, which only terminates the thread).


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ServiceThread(java.lang.Runnable run)
          Create thread in service thread group
ServiceThread(java.lang.Runnable run, java.lang.String str)
          Create thread in service thread group
ServiceThread(java.lang.String str)
          Create thread in service thread group
ServiceThread(java.lang.ThreadGroup tg, java.lang.Runnable run)
          Create thread in service thread group
ServiceThread(java.lang.ThreadGroup tg, java.lang.Runnable run, java.lang.String str)
          Create thread in service thread group
 
Method Summary
static void dumpThreadDebugObjects(java.io.PrintStream out)
          Dump all thread debug information to given writer
static void dumpThreadDebugObjects(java.io.Writer out)
          Dump all thread debug information to given writer
 Vect generateDebugStack()
          Generate debug message stack for all objects current obj debug stack
static java.lang.String getApplicationName()
          Get name of application in this JVM.
static java.lang.Object popDebugObject()
          Pop last object on debug stack of current thread (only if current thread is ServiceThread)
 java.lang.Object popDebugObjectFromThread()
          Pop last object on debug stack
static void popDebugObjectsUpToIndex(int index)
          Pop all debug object up to and including given index
 void popDebugObjectsUpToIndexFromThread(int index)
          Pop all debug object up to and including given index
static void popPushDebugObjects(java.lang.Object new_obj)
          Pop last object and push new object onto debug stack
 void popPushDebugObjectsOnThread(java.lang.Object new_obj)
          Pop last object and push new object onto debug stack
static int pushDebugObject(java.lang.Object debug_obj)
          Push object on to debug stack of current thread (only if current thread is ServiceThread)
 int pushDebugObjectToThread(java.lang.Object debug_obj)
          Push object on to debug stack
static void setApplicationName(java.lang.String n)
          Set name of application.
static void shutdown()
          Terminates anything running under the service thread
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, 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
 

Constructor Detail

ServiceThread

public ServiceThread(java.lang.Runnable run)
Create thread in service thread group

Parameters:
run - - runnable object to use for thread

ServiceThread

public ServiceThread(java.lang.ThreadGroup tg,
                     java.lang.Runnable run)
Create thread in service thread group

Parameters:
tg - - thread group
run - - runnable object to use for thread

ServiceThread

public ServiceThread(java.lang.Runnable run,
                     java.lang.String str)
Create thread in service thread group

Parameters:
run - - runnable object to use for thread
str - - name of thread

ServiceThread

public ServiceThread(java.lang.ThreadGroup tg,
                     java.lang.Runnable run,
                     java.lang.String str)
Create thread in service thread group

Parameters:
tg - - thread group
run - - runnable object to use for thread
str - - name of thread

ServiceThread

public ServiceThread(java.lang.String str)
Create thread in service thread group

Parameters:
str - - name of thread
Method Detail

setApplicationName

public static void setApplicationName(java.lang.String n)
Set name of application. Used for log name and messages.

Parameters:
n - - application name

getApplicationName

public static java.lang.String getApplicationName()
Get name of application in this JVM.


shutdown

public static void shutdown()
Terminates anything running under the service thread


generateDebugStack

public Vect generateDebugStack()
Generate debug message stack for all objects current obj debug stack

Returns:
Vect of messages

pushDebugObjectToThread

public int pushDebugObjectToThread(java.lang.Object debug_obj)
Push object on to debug stack

Parameters:
debug_obj - - debug object
Returns:
index of object on stack

popDebugObjectFromThread

public java.lang.Object popDebugObjectFromThread()
Pop last object on debug stack

Returns:
object popped

popDebugObjectsUpToIndexFromThread

public void popDebugObjectsUpToIndexFromThread(int index)
Pop all debug object up to and including given index

Parameters:
index - - index of last object to pop (0=all objects on stack)

popPushDebugObjectsOnThread

public void popPushDebugObjectsOnThread(java.lang.Object new_obj)
Pop last object and push new object onto debug stack

Parameters:
new_obj - - new object to push

pushDebugObject

public static int pushDebugObject(java.lang.Object debug_obj)
Push object on to debug stack of current thread (only if current thread is ServiceThread)

Parameters:
debug_obj - - debug object
Returns:
index of object on stack

popDebugObject

public static java.lang.Object popDebugObject()
Pop last object on debug stack of current thread (only if current thread is ServiceThread)

Returns:
object popped

popDebugObjectsUpToIndex

public static void popDebugObjectsUpToIndex(int index)
Pop all debug object up to and including given index

Parameters:
index - - index of last object to pop (0=all objects on stack)

popPushDebugObjects

public static void popPushDebugObjects(java.lang.Object new_obj)
Pop last object and push new object onto debug stack

Parameters:
new_obj - - new object to push

dumpThreadDebugObjects

public static void dumpThreadDebugObjects(java.io.PrintStream out)
Dump all thread debug information to given writer

Parameters:
out - - output writer for debug info

dumpThreadDebugObjects

public static void dumpThreadDebugObjects(java.io.Writer out)
                                   throws java.io.IOException
Dump all thread debug information to given writer

Parameters:
out - - output writer for debug info
Throws:
java.io.IOException