things.thinger.kernel
Class ProcessCoordinator

java.lang.Object
  extended by things.thinger.kernel.ProcessCoordinator

public class ProcessCoordinator
extends java.lang.Object

A process coordinator. This is mostly a helper for the Kernel.

Version:
1.0

Version History

 EPG - Initial - 13FEB06
 EPG - Change to use Clearance - 1 Dec 06
 
Author:
Erich P. Gatejen

Field Summary
static java.lang.String PROCESS_TABLE_ENTRY1_TAG
           
static java.lang.String PROCESS_TABLE_ENTRY2_ID
           
static java.lang.String PROCESS_TABLE_ENTRY3_CLEARANCE
           
static java.lang.String PROCESS_TABLE_ENTRY4_RUNTIME
           
static java.lang.String PROCESS_TABLE_ENTRY5_NAME
           
static java.lang.String PROCESS_TABLE_ENTRY6_STATE
           
static java.lang.String PROCESS_TABLE_ENTRY7_STATE_NUMERIC
           
 
Constructor Summary
ProcessCoordinator(WhoAmI id)
          Constructor.
 
Method Summary
 WhoAmI callerId()
          Get the calling processes ID.
 boolean checkClearance(Clearance requiredLevel)
          Check the clearance.
 void dumpProcessTable(Table<java.lang.String> target)
          Get a process table.
 PCB getProcess(java.lang.String id)
          Get a process by String ID.
 PCB getProcess(WhoAmI id)
          Get a process by WhoAmID.
 java.util.Collection<PCB> getProcesses()
          Get the processes registered with the coordinator.
 PCB getProcessOrganic(java.lang.String organicId)
          Get a process by its organic ID.
 void registerProcess(PCB aPCB, Clearance processClearance)
          Register a process as a ready PCB.
 PCB registerProcess(ThingsProcess aProcess, Clearance processClearance, ThingsPropertyView localProperties, ThingsPropertyViewReader configProperties)
          Register process.
 void removeProcess(java.lang.String id)
          Remove a processes by String ID.
 void removeProcess(WhoAmI id)
          Remove a processes by String ID.
 WhoAmI requireClearance(Clearance requiredLevel, java.lang.String operationName)
          Require Clearance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROCESS_TABLE_ENTRY1_TAG

public static final java.lang.String PROCESS_TABLE_ENTRY1_TAG
See Also:
Constant Field Values

PROCESS_TABLE_ENTRY2_ID

public static final java.lang.String PROCESS_TABLE_ENTRY2_ID
See Also:
Constant Field Values

PROCESS_TABLE_ENTRY3_CLEARANCE

public static final java.lang.String PROCESS_TABLE_ENTRY3_CLEARANCE
See Also:
Constant Field Values

PROCESS_TABLE_ENTRY4_RUNTIME

public static final java.lang.String PROCESS_TABLE_ENTRY4_RUNTIME
See Also:
Constant Field Values

PROCESS_TABLE_ENTRY5_NAME

public static final java.lang.String PROCESS_TABLE_ENTRY5_NAME
See Also:
Constant Field Values

PROCESS_TABLE_ENTRY6_STATE

public static final java.lang.String PROCESS_TABLE_ENTRY6_STATE
See Also:
Constant Field Values

PROCESS_TABLE_ENTRY7_STATE_NUMERIC

public static final java.lang.String PROCESS_TABLE_ENTRY7_STATE_NUMERIC
See Also:
Constant Field Values
Constructor Detail

ProcessCoordinator

public ProcessCoordinator(WhoAmI id)
                   throws SystemException
Constructor. Create the coordinator.

Parameters:
id - The ID of the ResourceCoordinator.
Throws:
SystemException
See Also:
WhoAmI
Method Detail

registerProcess

public PCB registerProcess(ThingsProcess aProcess,
                           Clearance processClearance,
                           ThingsPropertyView localProperties,
                           ThingsPropertyViewReader configProperties)
                    throws SystemException
Register process.

Parameters:
aProcess - The process to register.
processClearance - The clearance level. This will be immutable.
localProperties - properties visible to this process.
configProperties - configuration properties visible to this process.
Returns:
a PCB container for the process.
Throws:
SystemException
See Also:
ThingsPropertyView, ThingsPropertyViewReader

registerProcess

public void registerProcess(PCB aPCB,
                            Clearance processClearance)
                     throws SystemException
Register a process as a ready PCB. For consistancy sake, it is best to use the other registerProcess

Parameters:
aPCB - The process to register.
processClearance - The clearance level. This will be immutable.
Throws:
SystemException

getProcesses

public java.util.Collection<PCB> getProcesses()
                                       throws SystemException
Get the processes registered with the coordinator.

Returns:
a collection of PCBs
Throws:
SystemException
See Also:
PCB

getProcess

public PCB getProcess(WhoAmI id)
               throws SystemException
Get a process by WhoAmID.

Parameters:
id - The WhoAmI ID of the process.
Returns:
the PCB for the process.
Throws:
SystemException
See Also:
PCB

getProcess

public PCB getProcess(java.lang.String id)
               throws SystemException
Get a process by String ID. This will usually be the same as WhoAmI.String(), but it isn't guaranteed. It will throw a SystemException.PROCESS_ERROR_NOT_FOUND if it isn't found.

Parameters:
id - The String representation of the ID.
Returns:
the PCB for the process. It will never return a null.
Throws:
SystemException
See Also:
PCB

removeProcess

public void removeProcess(WhoAmI id)
Remove a processes by String ID. This will usually be the same as WhoAmI.String(), but it isn't guaranteed. If the processes is not registered, it will quietly return.

Parameters:
id - The WhoAmI ID of the process.

removeProcess

public void removeProcess(java.lang.String id)
Remove a processes by String ID. This will usually be the same as WhoAmI.String(), but it isn't guaranteed. If the processes is not registered, it will quietly return.

Parameters:
id - The String representation of the ID.

getProcessOrganic

public PCB getProcessOrganic(java.lang.String organicId)
                      throws SystemException
Get a process by its organic ID.

Parameters:
organicId - the organic ID.
Returns:
the PCB for the process.
Throws:
SystemException
See Also:
PCB

dumpProcessTable

public void dumpProcessTable(Table<java.lang.String> target)
                      throws SystemException
Get a process table. You provide the table and it will fill it.

Parameters:
target - A table to full.
Throws:
SystemException

callerId

public WhoAmI callerId()
                throws SystemException
Get the calling processes ID.

Returns:
The ID of the calling process.
Throws:
SystemException

checkClearance

public boolean checkClearance(Clearance requiredLevel)
                       throws SystemException
Check the clearance.

Parameters:
requiredLevel - The level required by the calling thread to allow the operation.
Returns:
true if this processes can pass teh clearance check, otherwise false.
Throws:
SystemException

requireClearance

public WhoAmI requireClearance(Clearance requiredLevel,
                               java.lang.String operationName)
                        throws SystemException
Require Clearance. Failure will throw an exception.

Parameters:
requiredLevel - The level required by the calling thread to allow the operation.
operationName - The name of the operation. This is used to identify an error should the clearance fail.
Returns:
The ID of the calling process.
Throws:
SystemException


Things.