/** * Initializes the attribute map and global attributes. Subclasses will need to call init(String) * themselves. */ protected AbstractMonitor() { attributes = createAttributeMap(); processed = false; }
/** * Initializes the attribute map, global attributes, monitoring level, sets the provided inherited * attributes and calls init(String). * * @param name the name of the monitor * @param monitoringLevel the monitoring level * @param inheritedAttributes the collection of inherited attributes */ public AbstractMonitor(final String name, final MonitoringLevel monitoringLevel, final Map<String, Object> inheritedAttributes) { this(); this.monitoringLevel = monitoringLevel; init(name, inheritedAttributes); }
/** * 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); }
/** * Used to set the inherited attributes on this monitor. * * @param inheritedAttributes the collection of inherited attributes */ protected void setInheritedAttributes(final Map<String, Object> inheritedAttributes) { if (inheritedAttributes != null) { for (final Map.Entry<String, Object> entry : inheritedAttributes.entrySet()) { final String key = entry.getKey(); Object value = entry.getValue(); if (value != null && AttributeHolder.class.isAssignableFrom(value.getClass())) { value = ((AttributeHolder)value).getValue(); } set(key, value).lock(); } } }
/** * Process this composite monitor. Delegates to AbstractMonitor.process(). */ @Override protected void process() { MonitoringEngine.getInstance().compositeMonitorCompleted(this); super.process(); }