Package gnu.cajo.utils.extra
Class Nice
- java.lang.Object
-
- gnu.cajo.utils.extra.Nice
-
- All Implemented Interfaces:
Invoke
,java.io.Serializable
,java.rmi.Remote
public final class Nice extends java.lang.Object implements Invoke
This class wraps an object, and dynamically alters the priority of the invocation thread at runtime. Normally, the thread is moved to lowest priority, to reduce the burden on the serving JVM for methods requiring a lot of processing resources. However the wrapper can also be used escalate the invocation thread to maximum priority, for time critical tasks.- Version:
- 1.0, 07-Mar-09
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Nice(java.lang.Object item, boolean fast)
The constuctor wraps an object reference, and allows invocations to execute at either minumum or maximum priority.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
invoke(java.lang.String method, java.lang.Object args)
This method intercepts the remote invocation thread, and alters its priority from normal.
-
-
-
Constructor Detail
-
Nice
public Nice(java.lang.Object item, boolean fast)
The constuctor wraps an object reference, and allows invocations to execute at either minumum or maximum priority.- Parameters:
item
- The object reference to be invokedfast
- True to execute invocations at maximum priority, false to invoke at minimum priorty.
-
-
Method Detail
-
invoke
public java.lang.Object invoke(java.lang.String method, java.lang.Object args) throws java.lang.Exception
This method intercepts the remote invocation thread, and alters its priority from normal. Typically the invocation thread is set to minimum priority, but can also be used to evelate the thread to maximum priority, if desired. When the invocation is complete, the thread will be restored to its original priority, to prevent potential side affects if an invocation is local.- Specified by:
invoke
in interfaceInvoke
- Parameters:
method
- The name of the method to invoke on the wrapped objectargs
- The data relevant to the invocation. It can be a single object, an array, or null- Returns:
- The method result defined by a wrapped object's implementation, if any
- Throws:
java.lang.Exception
- As needed by the object, also, a java.rmi.RemoteException can be thrown for network related reasons, also a SecurityException can be thrown, if the codebase does not have permission from the SecurityManager to alter thread priority.
-
-