things.thinger.kernel
Class ResourceManager

java.lang.Object
  extended by things.thinger.kernel.ResourceManager
All Implemented Interfaces:
ThingsReportingThreshold, Verbose

public class ResourceManager
extends java.lang.Object
implements Verbose, ThingsReportingThreshold

A resource manager. It will manage a single resource.

Note that the resource listeners will be given a chance to respond to resource revocation. However, the Kernel may interrupt the thread at its whim. This manager will catch the interruptions.

Version:
1.0

Version History

EPG - Initial - 26 FEB 06
 
Author:
Erich P. Gatejen

Constructor Summary
ResourceManager(ResourceInterface resource)
          Constructor.
 
Method Summary
 void addListener(ResourceListener listener)
          Add listener for this resource.
 void dispose()
          Dispose the resource.
 WhoAmI getId()
          Get the id.
 ResourceInterface getResource()
          Get the resource.
 boolean isVerbose()
          Is it set to verbose?
 void revokeListener(ResourceListener listener)
          Remove listener for this resource.
 void screech(java.lang.String message)
          Post a verbose message if verbose mode is on.
 void set(int threshold)
          It will set the threshold for reporting.
 void verboseOff()
          Turn it off
 void verboseOn(StringPoster poster)
          Turn on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceManager

public ResourceManager(ResourceInterface resource)
                throws SystemException
Constructor. It will put the resource under management.

Parameters:
resource - The resource to put under management.
Throws:
SystemException
See Also:
ResourceInterface
Method Detail

getResource

public ResourceInterface getResource()
Get the resource.

Returns:
The resource.

getId

public WhoAmI getId()
Get the id.

Returns:
The id.

addListener

public void addListener(ResourceListener listener)
                 throws SystemException
Add listener for this resource. It will throw a SystemException is the resource is disposed.

Parameters:
listener - A listener implementation.
Throws:
SystemException

revokeListener

public void revokeListener(ResourceListener listener)
                    throws SystemException
Remove listener for this resource. It will attempt to call the revocation calls for the listener, both resourceRevocation and resourceRevoked, but it will not fail if anything bad happens.

Parameters:
listener - A listener implementation.
Throws:
SystemException

dispose

public void dispose()
             throws SystemException
Dispose the resource. This is death of the resource. It will revoke all listeners too.
If any listener fails revocation, it will try to finish the others before throwing an exception, if the threshold warrants.

Throws:
SystemException

verboseOn

public void verboseOn(StringPoster poster)
               throws ThingsException
Turn on. It will test the poster and will throw a ThingsException if it has a problem.

Specified by:
verboseOn in interface Verbose
Parameters:
poster - StringPoster where to put the debug info
Throws:
ThingsException

verboseOff

public void verboseOff()
Turn it off

Specified by:
verboseOff in interface Verbose

screech

public void screech(java.lang.String message)
Post a verbose message if verbose mode is on. It will never throw an exception. The implementation may find a way to report exceptions.

Specified by:
screech in interface Verbose
Parameters:
message - The message.

isVerbose

public boolean isVerbose()
Is it set to verbose?

Specified by:
isVerbose in interface Verbose
Returns:
true if it is verbose, otherwise false.

set

public void set(int threshold)
It will set the threshold for reporting. What this means to the components may be different, but any internal exceptions below the threshold will likely be propagated out of the component.

Specified by:
set in interface ThingsReportingThreshold
Parameters:
threshold - Threshold level. This should be a numeric value from ThingsCodes. The one word levels should be good enough, such as WARNING, ERROR, etc.
See Also:
ThingsCodes


Things.