Skip to end of metadata
Go to start of metadata

Yan provides a simple implementation of component monitoring.

Monitor Events

The following events can be monitored currently:

  • Before Constructor
  • After Constructor
  • Constructor Failed
  • Before Method
  • After Method
  • Method Failed
  • Before Java Bean Getter
  • After Java Bean Getter
  • Java Bean Getter Failed
  • Before Java Bean Setter
  • After Java Bean Setter
  • Java Bean Setter Failed

Several monitor interfaces are available. The most important three monitor interfaces are:

Monitor Individual Component

Granularity of Yan's monitor support is as fine as the component level. You can add monintoring support for any individual component you want.
For example:

  • ComponentMonitor is the monitor object. It is notified when any of the monitored events happens.
  • new Monitors(monitor) creates a Monitors object that helps creating monitored components.
  • monitors.ctor(MyClass.class) creates a Component based on the constructor of MyClass and monitored by monitor.

Container That Monitors

For convenience, the MonitoringContainer class automatically monitors constructors and methods registered in it.
For example:

  • new MonitoringContainer(monitor) creates a Container that will automatically monitor constructors and methods.
  • A.class is registered using constructor, it is automatically monitored by the container.
  • B.class is registered using a static method, it is also automatically monitored.

Empty Monitor

NopComponentMonitor is an empty implementation of ComponentMonitor. It can be used as a base class. Subclasses can then only override methods of interest.

Monitor Queue

ComponentMonitorQueue class encapsulates a queue of various monitors such as ComponentMonitor, CtorMonitor, MethodMonitor. The following code creates a ComponentMonitor object that distribute events to every monitor object in the queue:

Labels: