1 17 18 package org.apache.avalon.fortress.impl.extensions; 19 20 import org.apache.avalon.framework.context.Context; 21 import org.apache.avalon.lifecycle.AbstractCreator; 22 import org.apache.excalibur.instrument.InstrumentManageable; 23 import org.apache.excalibur.instrument.InstrumentManager; 24 import org.apache.excalibur.instrument.Instrumentable; 25 26 30 public final class InstrumentableCreator extends AbstractCreator 31 { 32 private final InstrumentManager m_instrumentManager; 33 private final boolean m_instrumentEnabled; 34 35 public InstrumentableCreator( final InstrumentManager instrumentManager ) 36 { 37 m_instrumentManager = instrumentManager; 38 m_instrumentEnabled = instrumentManager != null; 39 } 40 41 44 public void create( final Object object, final Context context ) throws Exception 45 { 46 if ( m_instrumentEnabled && object instanceof Instrumentable ) 47 { 48 final String instrumentableName = (String ) context.get( "component.name" ); 49 final Instrumentable instrumentable = (Instrumentable) object; 50 instrumentable.setInstrumentableName( instrumentableName ); 51 52 m_instrumentManager.registerInstrumentable( 54 instrumentable, instrumentable.getInstrumentableName() ); 55 56 } 57 58 if ( m_instrumentEnabled && object instanceof InstrumentManageable ) 59 { 60 ( (InstrumentManageable) object ).setInstrumentManager( m_instrumentManager ); 61 } 62 63 } 64 } 65 | Popular Tags |