Package gnu.cajo.utils.extra
Class AuditorItem
- java.lang.Object
-
- gnu.cajo.utils.extra.AuditorItem
-
- All Implemented Interfaces:
Invoke
,java.io.Serializable
,java.rmi.Remote
public class AuditorItem extends java.lang.Object implements Invoke
This class is used to transparently pre and post-pend audit functionality to any given object reference. It is typically used to check the integrity of the invocation arguments, or the authenticity of the invoking object. Likewise, it can review the invocation results, to augment, or delete certain components. The wrapped object is unaware, and need not be changed, to assist in this functionality. It can be used on local objects, for which the code is available, as easily as on remote object references, for which no code is available. It is ideal for use in debug, and development activities, as well as for security, in production environments. The technique is essentially an implementation of the Decorator design pattern.- Version:
- 1.0, 19-Sep-04 Initial release
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AuditorItem(java.lang.Object item, java.lang.Object auditor)
This creates the object, to audit the target object's use.
-
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 audits the incoming calls.
-
-
-
Field Detail
-
auditor
public final java.lang.Object auditor
The auditor object. This object's preprocess method will be invoked with the arguments to be provided to the audited object. It has the three options:- Change the arguments
- Approve the arguments, as is
- Reject the invocation, by throwing an Exception.
-
item
public final java.lang.Object item
This is the object to be audited. Since it has no knowlege of the audit it's structure need not be changed in any way to accomodate it. It is declared as public to allow the reference of the AuditorItem, and its wrapped object, from a single instance of AuditorItem.
-
-
Constructor Detail
-
AuditorItem
public AuditorItem(java.lang.Object item, java.lang.Object auditor)
This creates the object, to audit the target object's use. The class in not declared final, to allow no-arg auditing items to be easily created.- Parameters:
item
- The object to receive the client invocation. It can be local, remote, or even a proxy.auditor
- The object to receive the calls prior to, and following the audited item's operation. It can be local, remote, or even a proxy.
-
-
Method Detail
-
invoke
public java.lang.Object invoke(java.lang.String method, java.lang.Object args) throws java.lang.Exception
This method audits the incoming calls. If the auditor approves, or change the supplied arguments, they will be passed into the audited item for processing. The auditor will again review the returned data, or exception, and will likewise approve or change it. Note: this method can be called reentrantly. Also, if the audited item invocation results in an exception, and the auditor approves, it can simply return the exception, and the wrapper will throw it automatically.- Specified by:
invoke
in interfaceInvoke
- Parameters:
method
- The internal object's public method being called.args
- The arguments to pass to the internal object's method.- Returns:
- The sychronous audited data, if any, resulting from the invocation.
- Throws:
RemoteException
- For a network related failure.java.lang.NoSuchMethodException
- If the method/agruments signature cannot be matched to the internal object's public method interface.java.lang.Exception
- If the internal object's method rejects the invocation, or if it has been rejected by the auditor object.
-
-