Package jfun.yan.monitoring

Source Code of jfun.yan.monitoring.MonitoringContainer

package jfun.yan.monitoring;

import jfun.yan.Component;
import jfun.yan.Registrar;
import jfun.yan.containers.SimpleContainer;
import jfun.yan.containers.SimpleRegistrar;

/**
* <p>
* A container implementation that adds monitoring support
* for constructors and methods registered using
* registerConstructor(), registerStaticMethod() and registerMethod().
* </p>
* <p>
* Components registered with registerComponent() are not automatically
* monitored.
* </p>
* <p>
* Only components directly registerd with the registerConstructor(),
* registerMethod(), registerStaticMethod() are monitored.
* Parameters of the components are not monitored.<br>
* Use {@link Monitors} to add monitoring support.
* </p>
* @author Michelle Lei
*
*/
public class MonitoringContainer extends SimpleContainer {
  private final Monitors mon;
  private void defaultRegister(Object key, Component c){
    registerComponent(key, defaultTransform(c));
  }
  private void defaultRegister(Component c){
    registerComponent(defaultTransform(c));
  }
  /**
   * To create a MonitoringContainer object.
   * @param target the Registrar object that does the registration.
   * @param mon the ComponentMonitor object.
   */
  public MonitoringContainer(Registrar target, ComponentMonitor mon) {
    super(target);
    this.mon = new Monitors(mon);
  }
  /**
   * To create a MonitoringContainer object.
   * @param mon the ComponentMonitor object.
   */
  public MonitoringContainer(ComponentMonitor mon){
    this(new SimpleRegistrar(), mon);
  }
  public void registerConstructor(Object key, Class c, Class[] param_types) {
    defaultRegister(key, mon.ctor(c, param_types));
  }

  public void registerConstructor(Object key, Class c) {
    defaultRegister(key, mon.ctor(c));
  }

  public void registerStaticMethod(Class c, String name, Class[] param_types) {
    defaultRegister(mon.static_method(c, name, param_types));
  }

  public void registerStaticMethod(Class c, String name) {
    defaultRegister(mon.static_method(c, name));
  }

  public void registerStaticMethod(Object key, Class c, String name, Class[] param_types) {
    defaultRegister(key, mon.static_method(c, name, param_types));
  }

  public void registerStaticMethod(Object key, Class c, String name) {
    defaultRegister(key, mon.static_method(c, name));
  }
  public void registerMethod(Object key, Object obj, String name, Class[] param_types){
    defaultRegister(key, mon.method(obj, name, param_types));
  }
  public void registerMethod(Object key, Object obj, String name){
    defaultRegister(key, mon.method(obj, name));
  }
  public void registerMethod(Object obj, String name, Class[] param_types){
    defaultRegister(mon.method(obj, name, param_types));
  }
  public void registerMethod(Object obj, String name){
    defaultRegister(mon.method(obj, name));
  }
}
TOP

Related Classes of jfun.yan.monitoring.MonitoringContainer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.