Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.subsystems.qsys.api
Class SystemCommunicationsDaemon

java.lang.Object
  extended by java.lang.Thread
      extended by com.ibm.etools.iseries.subsystems.qsys.api.SystemCommunicationsDaemon
All Implemented Interfaces:
Runnable

public class SystemCommunicationsDaemon
extends Thread

Communications daemon that can be used by other functions for receiving incoming socket requests. Functions need to implement the ICommunicationsDaemonHandler interface and register a unique 4 byte id (as an integer) which the server sends across the socket to let the daemon know which local function to pass the socket off to.


Nested Class Summary
protected  class SystemCommunicationsDaemon.CommunicationHandlerThread
          Inner class for running ICommunicationHandlers on a new thread.
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
static String copyright
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
 boolean addCommunicationsDaemonHandler(ISystemCommunicationsDaemonHandler handler, int requestKey)
          Add a new CommunicationsDaemonHandler
static void addDaemonListener(ISystemCommunicationsDaemonListener listener)
          Add an ISystemCommunicationsDaemonListener listener to receive state change events from the SystemCommunicationsDaemon.
static SystemCommunicationsDaemon getInstance()
          Returns the singleton instance of this class.
static int getNextKey()
          getNextKey() can be called to generated a dynamic key used by any communications handler.
 int getPort()
          Returns the port the daemon is currently running on, or zero if the daemon is not running.
static boolean isAutoStart()
          Returns the user preference for auto-starting the communications daemon when the Workbench starts.
 boolean isRunning()
          Check to see if the iSeries communications daemon is running
 void removeCommunicationsDaemonHandler(int requestKey)
          Remove a CommunicationsDaemonHandler
static void removeDaemonListener(ISystemCommunicationsDaemonListener listener)
          Remove the ISystemCommunicationsDaemonListener listener.
 void run()
           
 void startDaemon()
          Start the communications daemon if it is not already running
 void startDaemon(boolean displayErrors)
          Start the communications daemon if it is not already running
 void stopDaemon()
          Stops the communications daemon if it is running
 
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, 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

copyright

public static final String copyright
See Also:
Constant Field Values
Method Detail

getInstance

public static SystemCommunicationsDaemon getInstance()
Returns the singleton instance of this class. If the an instance has already been created then it is returned, otherwise a new instance is created and returned.


run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Thread.run()

startDaemon

public void startDaemon()
Start the communications daemon if it is not already running


startDaemon

public void startDaemon(boolean displayErrors)
Start the communications daemon if it is not already running

Parameters:
displayErrors - true if error messages should be displayed, false if they should be not be displayed.

stopDaemon

public void stopDaemon()
Stops the communications daemon if it is running


getPort

public int getPort()
Returns the port the daemon is currently running on, or zero if the daemon is not running.


isRunning

public boolean isRunning()
Check to see if the iSeries communications daemon is running

Returns:
true if the communications daemon is running, false if it is not running

isAutoStart

public static boolean isAutoStart()
Returns the user preference for auto-starting the communications daemon when the Workbench starts.


addCommunicationsDaemonHandler

public boolean addCommunicationsDaemonHandler(ISystemCommunicationsDaemonHandler handler,
                                              int requestKey)
Add a new CommunicationsDaemonHandler

Parameters:
requestKey - The request key must be four byte integer key used by this handler. This is the first thing that much be sent over the socket from the corresponding client / server when connecting to the RSE communications daemon. The daemon when then compare this integer against all registered handlers and pass off the socket connection (via the handleRequest method) to the first match. Use the SystemCommunicationsDaemon.getInstance().addCommunicationsDaemonHandler(...) method to register with the daemon. There is also a corresponding remove method. Known handlers: RSEInteractiveJobHandler 0x67DF7A14 CODECommIntegrationHandler 0xA387E2CD iSeries DebugEngine The range of integers from 0xD0000000 to 0xFFFFFFFF is reserved for dyanmically generated kes.
Returns:
true if the handler was registered, false it the handler was not registered because the requestKey is already being used
See Also:
ISystemCommunicationsDaemonHandler

removeCommunicationsDaemonHandler

public void removeCommunicationsDaemonHandler(int requestKey)
Remove a CommunicationsDaemonHandler

See Also:
ISystemCommunicationsDaemonHandler

getNextKey

public static int getNextKey()
getNextKey() can be called to generated a dynamic key used by any communications handler. They generated key is guaranteed to be unique. Callers still need to call the addCommunicationsDaemonHandler() method to register their handler.


addDaemonListener

public static void addDaemonListener(ISystemCommunicationsDaemonListener listener)
Add an ISystemCommunicationsDaemonListener listener to receive state change events from the SystemCommunicationsDaemon.


removeDaemonListener

public static void removeDaemonListener(ISystemCommunicationsDaemonListener listener)
Remove the ISystemCommunicationsDaemonListener listener.


Rational Developer for Power Systems Software
V7.6

Copyright © 2011 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.