/** * A lifecycle method that initializes the Monitor. All monitor implementations must call this * methods before setting any attributes on themselves. * <p> * * After this method returns, the monitor will have had any implicitly inherited and global * attributes applied. * * @param monitor the monitor to initialize. */ public void initMonitor(final Monitor monitor) { initMonitor(monitor, true); }
/** * Used to invoke the monitor lifecycle methods MonitoringEngine.initMonitor and * MonitoringEngine.monitorCreated on this monitor. * * @param name the name of the monitor * @param inheritedAttributes the collection of inherited attributes */ protected void init(String name, final Map<String, Object> inheritedAttributes) { MonitoringEngine.getInstance().initMonitor(this); if (name != null) { for (int i = 0; i < name.length(); i++) { if (invalidCharSet.contains(Character.valueOf(name.charAt(i)))) { name = CharSetUtils.delete(name, invalidCharacters); break; } } } set(Attribute.NAME, name); setInheritedAttributes(inheritedAttributes); MonitoringEngine.getInstance().monitorCreated(this); }
/** * Optionally allows for inheritable attributes. * * @param name the name of the monitor * @param value the value * @param includeInheritables set to true if this monitor should support inheritables * @param monitoringLevel monitoring level */ public ValueMonitor(String name, double value, boolean includeInheritables, MonitoringLevel monitoringLevel) { // note we are calling this specific constructor on AbstractMonitor to avoid // the call to init() on AbstractMonitor super(); this.monitoringLevel = monitoringLevel; // perform standard monitor initialization optionally ommitting inheritable // attributes - this is a performance optimization targeted towards a potentially // costly step in monitor construction (inheritable attributes) MonitoringEngine.getInstance().initMonitor(this, includeInheritables); // also intentionally skip the created lifecycle step as this is not a // meaningful event/unnecessary overhead for ValueMonitor //MonitoringEngine.getInstance().monitorCreated(this); set(Attribute.NAME, name).lock(); set(Attribute.VALUE, value).lock(); }