1 50 package org.apache.avalon.excalibur.monitor; 51 52 import org.apache.avalon.framework.activity.Startable; 53 import org.apache.avalon.framework.configuration.Configurable; 54 import org.apache.avalon.framework.configuration.Configuration; 55 import org.apache.avalon.framework.configuration.ConfigurationException; 56 import org.apache.avalon.framework.logger.LogEnabled; 57 import org.apache.avalon.framework.logger.Logger; 58 import org.apache.avalon.framework.thread.ThreadSafe; 59 60 85 public class ActiveMonitor 86 extends org.apache.avalon.excalibur.monitor.impl.ActiveMonitor 87 implements LogEnabled, Configurable, Startable, ThreadSafe 88 { 89 private Logger m_logger; 90 91 public void enableLogging( final Logger logger ) 92 { 93 m_logger = logger; 94 } 95 96 99 public final void configure( final Configuration config ) 100 throws ConfigurationException 101 { 102 final Configuration thread = config.getChild( "thread" ); 103 final long frequency = 104 thread.getAttributeAsLong( "frequency", 1000L * 60L ); 105 final int priority = 106 thread.getAttributeAsInteger( "priority", Thread.MIN_PRIORITY ); 107 108 setFrequency( frequency ); 109 setPriority( priority ); 110 111 if( m_logger.isDebugEnabled() ) 112 { 113 m_logger.debug( "Active monitor will sample all resources every " + 114 frequency + " milliseconds with a thread priority of " + 115 priority + "(Minimum = " + Thread.MIN_PRIORITY + 116 ", Normal = " + Thread.NORM_PRIORITY + 117 ", Maximum = " + Thread.MAX_PRIORITY + ")." ); 118 } 119 120 final Configuration[] resourcesConfig = 121 config.getChild( "init-resources" ).getChildren( "resource" ); 122 final Resource[] resources = 123 MonitorUtil.configureResources( resourcesConfig, m_logger ); 124 addResources( resources ); 125 } 126 } 127 | Popular Tags |