things.thinger.kernel
Interface ResourceInterface

All Known Implementing Classes:
KernelBasic_WriterLogger, LocalCommander

public interface ResourceInterface

A resource interface.

Version:
1.0 Version History
EPG - Initial - 01FEB06
Author:
Erich P. Gatejen

Nested Class Summary
static class ResourceInterface.State
          The states are provided as a convenience.
 
Field Summary
static java.lang.String NULL_ID
           
 
Method Summary
 void disposeResource()
          This is how the system tells a resource he is about to be destroyed.
 WhoAmI getId()
          Get ID of the resource.
 ResourceInterface.State getState()
          Get the current state.
 void initResource(WhoAmI id)
          Initialize the resource.
 boolean lock()
          Lock an object.
 void unlock()
          This call is only meaningful if the thread holds the lock.
 

Field Detail

NULL_ID

static final java.lang.String NULL_ID
Method Detail

initResource

void initResource(WhoAmI id)
                  throws SystemException
Initialize the resource. This must be called before use. It should be called by the Kernel. The id must be immutable. If the id should change, it could cause mayhem for the Kernel. If the Kernel should ever detect a change, it should ruthlessly deregister and destroy the resource.

Parameters:
id - The id of the resource.
Throws:
SystemException
See Also:
WhoAmI

disposeResource

void disposeResource()
                     throws SystemException
This is how the system tells a resource he is about to be destroyed. Typically, the system will allow the resource some time to clean up, however the implementation should assume that the system can become impatient at any moment and summerily execute it.
This may be called asynchronously by the system at any time and by any thread, so a smart system would manage conflicts and thread issues.

Throws:
SystemException

lock

boolean lock()
             throws SystemException
Lock an object. This is blocking. Locks will prevent any other thread from accessing the resource. However, the resource may not allow locks, and it will return false if the lock was disallowed.

Returns:
true if the lock was completed, false if locks are not allowed.
Throws:
SystemException

unlock

void unlock()
            throws SystemException
This call is only meaningful if the thread holds the lock. The resource could choose to ignore it, but locking is not supported.
If locks are supported and the thread does not own the lock, the resource may throw an exception.

Throws:
SystemException

getId

WhoAmI getId()
             throws SystemException
Get ID of the resource. If the resource has not been initResource(), this must return a null. Return anything else than a null or the exact WhoAmI that was set during initResource() is likely to cause the Resource to be brutally killed by the Kernel.

Returns:
WhoAmI
Throws:
SystemException
See Also:
WhoAmI

getState

ResourceInterface.State getState()
                                 throws SystemException
Get the current state.

Returns:
State
Throws:
SystemException


Things.