Class AuditorItem

java.lang.Object
gnu.cajo.utils.extra.AuditorItem
All Implemented Interfaces:
Invoke, Serializable, Remote

public class AuditorItem extends 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:
  • Field Details

    • auditor

      public final 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.
      The arguments the preprocess method returns will then be passed on to the audited item for processing. The result of this operation will be passed to the auditing item's postprocess method. Again, it has the similiar three options; to change, approve, or reject the returned data. It is declared as public to allow the reference of the AuditorItem, and its auditor object, from a single instance of AuditorItem.
    • item

      public final 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 Details

    • AuditorItem

      public AuditorItem(Object item, 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 Details

    • invoke

      public Object invoke(String method, Object args) throws 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 interface Invoke
      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.