rendsite.tools
Class SystemInterfaceStubBase

java.lang.Object
  extended by rendsite.tools.SystemInterfaceStubBase
All Implemented Interfaces:
things.thinger.SystemInterface, things.thinger.SystemSuperInterface
Direct Known Subclasses:
SystemInterfaceStub

public abstract class SystemInterfaceStubBase
extends java.lang.Object
implements things.thinger.SystemSuperInterface

Stub out the system interface (like the test.things does). We'll put the NOP methods here and implemented methods in subclasses.

Author:
erich Version History
 10NOV09 - EPG - First package release.
 

Field Summary
 
Fields inherited from interface things.thinger.SystemInterface
DEFAULT_REPORTING_THRESHOLD
 
Constructor Summary
SystemInterfaceStubBase()
           
 
Method Summary
 void deathNotice(things.common.ThingsException te)
          Typically, this is how a process will tell the kernel it is dying, so that the kernel can clear resources.
 void flingException(things.common.ThingsException te)
          Typically, this is a last ditch way for a process or module to pass info to the kernel when something very bad is happening.
 things.data.ThingsPropertyView getConfigPropertiesWritable()
          Get the configuration properties that are writable.
 things.data.ThingsPropertyView getGlobalProperties()
          Get system global property view.
 things.data.ThingsPropertyView getLocalProperties(java.lang.String id)
          Get local property view for the given id.
 things.thinger.io.FileSystemLocator getLogLocal(java.lang.String id)
          Get a local reference to the log if possible.
 things.thinger.kernel.ProcessInterface getProcessInterface(java.lang.String id)
          Get a process interface.
 things.thinger.kernel.ThingsState getProcessState(java.lang.String id)
          Get the state of a specific process.
 things.universe.Universe getUniverse(java.lang.String name)
          Get a universe by the local name.
 things.data.ThingsPropertyView getUserGlobalProperties()
          Get user global property view.
 things.thing.MODULE loadModule(java.lang.String name)
          Load a module but don't do anything with it.
 things.thing.THING loadThing(java.lang.String name)
          Load a thing but don't run it.
 void registerProcess(things.thinger.kernel.PCB processPCB, things.thinger.kernel.Clearance processClearance)
          Register a ready-made PCB.
 void requestQuit()
          Ask the server to quit.
 things.thinger.SystemSuperInterface requestSuperSystemInterface()
          Ask the kernel for a SuperSystemInterface.
 java.lang.String runThing(java.lang.String name)
          Load and run a thing in a new process.
 java.lang.String runThing(java.lang.String name, things.thinger.ExpressionInterface parentExpressor)
          Load and run a thing in a new process, giving an expression parent.
 java.lang.String runThing(java.lang.String name, things.thinger.ExpressionInterface parentExpressor, things.data.ThingsPropertyView properties)
          Load and run a thing in a new process, giving an expression parent.
 things.common.WhoAmI startProcess(things.thinger.kernel.ThingsProcess processObject, things.data.ThingsPropertyView properties)
          Start the passed process.
 things.common.WhoAmI startProcess(things.thinger.kernel.ThingsProcess processObject, things.data.ThingsPropertyView properties, things.thinger.kernel.Clearance processClearance)
          Start the passed process.
 void waitProcessDone(java.lang.String id)
          Wait until the named process if done (meaning any state that satisfies ProcessInterface.ThingsState.isDeadOrDying()==true).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface things.thinger.SystemSuperInterface
getSystemConduits
 
Methods inherited from interface things.thinger.SystemInterface
getCallingProcessId, getConfigProperties, getLocalProperties, getLocalPropertiesImplementation, getNamedExpressor, getNamedLogger, getProcessList, getSharedProperties, getSystemLogger
 

Constructor Detail

SystemInterfaceStubBase

public SystemInterfaceStubBase()
Method Detail

getGlobalProperties

public things.data.ThingsPropertyView getGlobalProperties()
                                                   throws things.thinger.SystemException
Get system global property view. This is primarily for system work.

Specified by:
getGlobalProperties in interface things.thinger.SystemSuperInterface
Returns:
a property view
Throws:
things.thinger.SystemException

getUserGlobalProperties

public things.data.ThingsPropertyView getUserGlobalProperties()
                                                       throws things.thinger.SystemException
Get user global property view. These properties are copied into a user process as local properties when the process is created. It's a snapshot, updated to the original global properties and the new local properties will not affect each other.

Specified by:
getUserGlobalProperties in interface things.thinger.SystemSuperInterface
Returns:
a property view
Throws:
things.thinger.SystemException

getConfigPropertiesWritable

public things.data.ThingsPropertyView getConfigPropertiesWritable()
                                                           throws things.thinger.SystemException
Get the configuration properties that are writable. Anything that has access to the SSI can touch these.

Specified by:
getConfigPropertiesWritable in interface things.thinger.SystemSuperInterface
Returns:
a property view
Throws:
things.thinger.SystemException

getLocalProperties

public things.data.ThingsPropertyView getLocalProperties(java.lang.String id)
                                                  throws things.thinger.SystemException
Get local property view for the given id.

Specified by:
getLocalProperties in interface things.thinger.SystemSuperInterface
Parameters:
id - String id of the process.
Returns:
a property view or null if the id doesn't identify any known process.
Throws:
things.thinger.SystemException

flingException

public void flingException(things.common.ThingsException te)
Typically, this is a last ditch way for a process or module to pass info to the kernel when something very bad is happening. There is no feedback loop.

Specified by:
flingException in interface things.thinger.SystemSuperInterface
Parameters:
te - a Things exception
Throws:
things.thinger.SystemException
See Also:
WhoAmI

deathNotice

public void deathNotice(things.common.ThingsException te)
Typically, this is how a process will tell the kernel it is dying, so that the kernel can clear resources. This really should be the LAST thing a process does before exiting run(). If can be used instead of flingException.

Specified by:
deathNotice in interface things.thinger.SystemSuperInterface
Parameters:
te - a Things exception that indicates the reason for the death. It may be null if it was normal termination.
Throws:
things.thinger.SystemException
See Also:
WhoAmI

requestQuit

public void requestQuit()
Ask the server to quit.

Specified by:
requestQuit in interface things.thinger.SystemSuperInterface

startProcess

public things.common.WhoAmI startProcess(things.thinger.kernel.ThingsProcess processObject,
                                         things.data.ThingsPropertyView properties)
                                  throws things.common.ThingsException
Start the passed process. Assume a loader will be doing this. The process should be loaded, constructed, but not initialized. If the state is not STATE_CONSTRUCTION, it will throw an exception.
All processes started with this will have DEFAULT_USER_CLEARANCE.

Specified by:
startProcess in interface things.thinger.SystemSuperInterface
Parameters:
processObject - This will be a ThingsProcess or subclass.
properties - These are properties to add (or supplant) to the processes specific view before starting the process. It is ok to pass null if there are none.
Returns:
the ID of the started process.
Throws:
things.thinger.ThingsException
things.common.ThingsException
See Also:
WhoAmI

startProcess

public things.common.WhoAmI startProcess(things.thinger.kernel.ThingsProcess processObject,
                                         things.data.ThingsPropertyView properties,
                                         things.thinger.kernel.Clearance processClearance)
                                  throws java.lang.Throwable
Start the passed process. Assume a loader will be doing this. The process should be loaded, constructed, but not initialized. If the state is not STATE_CONSTRUCTION, it will throw an exception.

Specified by:
startProcess in interface things.thinger.SystemSuperInterface
Parameters:
processObject - This will be a ThingsProcess or subclass.
properties - These are properties to add (or supplant) to the processes specific view before starting the process. It is ok to pass null if there are none.
processClearance - specify the process clearance level. This must be at or lower than the calling process's clearance.
Returns:
the ID of the started process.
Throws:
java.lang.Throwable
See Also:
WhoAmI

registerProcess

public void registerProcess(things.thinger.kernel.PCB processPCB,
                            things.thinger.kernel.Clearance processClearance)
                     throws things.common.ThingsException
Register a ready-made PCB. It'll allows you to set the clearance level. The kernel may choose to deny the operation. So normally, use startProcess instead. The process will not be given standard property paths and initialization, as you get with the startProcess method. This exists mostly for debugging and testing, but may be useful for processes that live outside the normal processing framework.

Specified by:
registerProcess in interface things.thinger.SystemSuperInterface
Parameters:
processPCB - This will be a ready-made PCB.
processClearance - The clearance level. This will be immutable.
Throws:
things.common.ThingsException

getProcessState

public things.thinger.kernel.ThingsState getProcessState(java.lang.String id)
                                                  throws things.thinger.SystemException
Get the state of a specific process.

If the process is not found, the state is ProcessInterface.ThingsState.STATE_INVALID.

NO CLEARANCE REQUIRED.

Specified by:
getProcessState in interface things.thinger.SystemInterface
Parameters:
id - String id of the process.
Returns:
The state.
Throws:
things.thinger.SystemException
See Also:
ProcessInterface

getProcessInterface

public things.thinger.kernel.ProcessInterface getProcessInterface(java.lang.String id)
                                                           throws things.thinger.SystemException
Get a process interface. You can only get a process of equal or less clearance.

Specified by:
getProcessInterface in interface things.thinger.SystemInterface
Parameters:
id - String id of the process.
Returns:
The interface
Throws:
things.thinger.SystemException
See Also:
ProcessInterface

waitProcessDone

public void waitProcessDone(java.lang.String id)
                     throws things.thinger.SystemException,
                            java.lang.InterruptedException
Wait until the named process if done (meaning any state that satisfies ProcessInterface.ThingsState.isDeadOrDying()==true).

If the process is not found, it will quietly return.

NO CLEARANCE REQUIRED.

Specified by:
waitProcessDone in interface things.thinger.SystemInterface
Parameters:
id - String id of the process.
Throws:
things.thinger.SystemException - for general errors or InterruptedException for thread control. Always let the InterruptedException out.
java.lang.InterruptedException
See Also:
ProcessInterface

getLogLocal

public things.thinger.io.FileSystemLocator getLogLocal(java.lang.String id)
                                                throws things.thinger.SystemException,
                                                       java.lang.InterruptedException
Get a local reference to the log if possible. This is totally up to the implementation. It may be the whole log, a snippet, or null (no log at all).

NO CLEARANCE REQUIRED.

Specified by:
getLogLocal in interface things.thinger.SystemInterface
Parameters:
id - String id of the process.
Returns:
log file locator or null
Throws:
things.thinger.SystemException - for general errors or InterruptedException for thread control. Always let the InterruptedException out.
java.lang.InterruptedException
See Also:
ProcessInterface, FileSystemLocator

loadThing

public things.thing.THING loadThing(java.lang.String name)
                             throws things.thinger.SystemException
Load a thing but don't run it. It will only construct. It's up to initialize and call it. Typically, the user should call .init() and then .call_chain(). This is mostly so that THINGs can calll other THINGs, so perhaps it is best to just use THING.CALL instead--if you can.

Specified by:
loadThing in interface things.thinger.SystemInterface
Returns:
The constructed thing.
Throws:
things.thinger.SystemException

loadModule

public things.thing.MODULE loadModule(java.lang.String name)
                               throws things.thinger.SystemException
Load a module but don't do anything with it. It will only construct. It's up to the user to initialize it.

Specified by:
loadModule in interface things.thinger.SystemInterface
Parameters:
name - the name that the loader can use to find it. Typically, the full class name.
Returns:
The constructed MODUKE
Throws:
things.thinger.SystemException

runThing

public java.lang.String runThing(java.lang.String name)
                          throws things.thinger.SystemException
Load and run a thing in a new process.

Specified by:
runThing in interface things.thinger.SystemInterface
Returns:
The name of the thing.
Throws:
things.thinger.SystemException

runThing

public java.lang.String runThing(java.lang.String name,
                                 things.thinger.ExpressionInterface parentExpressor)
                          throws things.thinger.SystemException
Load and run a thing in a new process, giving an expression parent. All expressions will go to the parent, plus whatever local mechanism the kernel decides.

Specified by:
runThing in interface things.thinger.SystemInterface
Parameters:
name - the resolvable name of the thing.
parentExpressor - the parent expressor.
Returns:
The name of the thing.
Throws:
things.thinger.SystemException

runThing

public java.lang.String runThing(java.lang.String name,
                                 things.thinger.ExpressionInterface parentExpressor,
                                 things.data.ThingsPropertyView properties)
                          throws things.thinger.SystemException
Load and run a thing in a new process, giving an expression parent. All expressions will go to the parent, plus whatever local mechanism the kernel decides. This will let you add properties to the THING's view before it starts.

Specified by:
runThing in interface things.thinger.SystemInterface
Parameters:
name - the resolvable name of the thing.
parentExpressor - the parent expressor. Set to null if there is no parent.
properties - properties to add to the THING processes specific view.
Returns:
The name of the thing.
Throws:
things.thinger.SystemException

requestSuperSystemInterface

public things.thinger.SystemSuperInterface requestSuperSystemInterface()
                                                                throws things.thinger.SystemException
Ask the kernel for a SuperSystemInterface. If you can't have it, you'll get a SystemException. Generally, only services are allowed to have it.

Specified by:
requestSuperSystemInterface in interface things.thinger.SystemInterface
Returns:
The super system interface.
Throws:
things.thinger.SystemException

getUniverse

public things.universe.Universe getUniverse(java.lang.String name)
                                     throws things.thinger.SystemException
Get a universe by the local name.

The stub version will only yield universe_testing. ever.

Specified by:
getUniverse in interface things.thinger.SystemInterface
Parameters:
name - the local name for the universe
Returns:
The universe.
Throws:
things.thinger.SystemException
See Also:
Universe


rendsite.