/** * Increment the lease requests. */ void incrementLeaseRequests() { m_leaseRequestsInstrument.increment(); }
m_getsInstrument = new CounterInstrument( INSTRUMENT_GETS_NAME ); m_putsInstrument = new CounterInstrument( INSTRUMENT_PUTS_NAME ); m_blocksInstrument = new CounterInstrument( INSTRUMENT_BLOCKS_NAME ); m_createsInstrument = new CounterInstrument( INSTRUMENT_CREATES_NAME ); m_decommissionsInstrument = new CounterInstrument( INSTRUMENT_DECOMMISSIONS_NAME );
/** * Increments the Instrument. This method is optimized to be extremely * light weight when an InstrumentManager is not present and there are no * registered CounterInstrumentListeners. */ public void increment() { InstrumentProxy proxy = getInstrumentProxy(); if( proxy != null ) { proxy.increment( 1 ); } }
/** * Return a reference of the desired Component * @param component the component */ public void put( final Object component ) { if ( !m_prepared ) { final String message = "You cannot put a component in an uninitialized holder"; throw new IllegalStateException( message ); } if ( m_release.isActive() ) { m_release.increment(); } doPut( component ); }
/** * Get a reference of the desired Component * @return the component */ public Object get() throws Exception { if ( !m_prepared ) { prepareHandler(); } if ( m_disposed ) { final String message = "You cannot get a component from a disposed holder"; throw new IllegalStateException( message ); } if ( m_request.isActive() ) { m_request.increment(); } return doGet(); }
m_putsInstrument.increment(); m_referencesInstrument.setValue( m_references );
/** * Disposal of the supplied component instance. * @param component the component to dispose of * @exception Exception if a disposal error occurs */ public final void dispose( final Object component ) throws Exception { if ( getLogger().isDebugEnabled() ) { final String message = "ComponentFactory decommissioning instance of " + getCreatedClass().getName() + "."; getLogger().debug( message ); } if ( getCreatedClass().equals( component.getClass() ) ) { ContainerUtil.shutdown( component ); m_extManager.executeDestructionExtensions( component, m_context ); if ( m_dispose.isActive() ) { m_dispose.increment(); } } else { final String message = "The object given to be disposed does " + "not come from this ObjectFactory"; throw new IllegalArgumentException( message ); } }
/** * Creates a new ComponentHandler. */ public ComponentHandler() { // Initialize the Instrumentable elements. setInstrumentableName( ExcaliburComponentManager.INSTRUMENTABLE_NAME + ".unnamed handler" ); addInstrument( m_referencesInstrument = new ValueInstrument( "references" ) ); addInstrument( m_getsInstrument = new CounterInstrument( "gets" ) ); addInstrument( m_putsInstrument = new CounterInstrument( "puts" ) ); }
/** * Increments the Instrument by a specified count. This method is * optimized to be extremely light weight when an InstrumentManager is not * present and there are no registered CounterInstrumentListeners. * * @param count A positive integer to increment the counter by. * * @throws IllegalArgumentException If the count is not positive. */ public void increment( int count ) { // Check the count if( count <= 0 ) { throw new IllegalArgumentException( "Count must be a positive value." ); } InstrumentProxy proxy = getInstrumentProxy(); if( proxy != null ) { proxy.increment( count ); } } }
/** * Get an instance of the type of component handled by this handler. * <p> * Subclasses should not extend this method but rather the doGet method below otherwise * reference counts will not be supported. * <p> * This method is not final to make the class backwards compatible. * * @return a <code>Component</code> * @exception Exception if an error occurs */ public Component get() throws Exception { Component component = doGet(); synchronized( m_referenceSemaphore ) { m_references++; } // Notify the instrument manager m_getsInstrument.increment(); m_referencesInstrument.setValue( m_references ); return component; }
/** * Create a new AbstractComponentManagerServlet. * * @param referenceName A name which does not include any spaces or periods * that will be used to name the logger category and * instrumentable which represents this servlet. */ public AbstractComponentManagerServlet( String referenceName ) { //System.out.println( "AbstractComponentManagerServlet( " + referenceName + " )" ); m_referenceName = referenceName; // Set up Instrumentable like AbstractInstrumentable m_registered = false; m_instrumentList = new ArrayList(); m_childList = new ArrayList(); // Create the instruments setInstrumentableName( referenceName ); addInstrument( m_instrumentRequests = new CounterInstrument( "requests" ) ); addInstrument( m_instrumentTime = new ValueInstrument( "time" ) ); }
/** * Create a new AbstractServiceManagerServlet. * * @param referenceName A name which does not include any spaces or periods * that will be used to name the logger category and * instrumentable which represents this servlet. */ public AbstractServiceManagerServlet( String referenceName ) { //System.out.println( "AbstractServiceManagerServlet( " + referenceName + " )" ); m_referenceName = referenceName; // Set up Instrumentable like AbstractInstrumentable m_registered = false; m_instrumentList = new ArrayList(); m_childList = new ArrayList(); // Create the instruments setInstrumentableName( referenceName ); addInstrument( m_instrumentRequests = new CounterInstrument( "requests" ) ); addInstrument( m_instrumentTime = new ValueInstrument( "time" ) ); }
m_instrumentRequests.increment();
/** * Creates a new DefaultInstrumentManagerImpl. */ public DefaultInstrumentManagerImpl() { // Initialize the Instrumentable elements. m_totalMemoryInstrument = new ValueInstrument( "total-memory" ); m_freeMemoryInstrument = new ValueInstrument( "free-memory" ); m_memoryInstrument = new ValueInstrument( "memory" ); m_activeThreadCountInstrument = new ValueInstrument( "active-thread-count" ); m_registrationsInstrument = new CounterInstrument( "instrumentable-registrations" ); m_instrumentablesInstrument = new ValueInstrument( "instrumentables" ); m_instrumentsInstrument = new ValueInstrument( "instruments" ); m_samplesInstrument = new ValueInstrument( "samples" ); m_leasedSamplesInstrument = new ValueInstrument( "leased-samples" ); m_leaseRequestsInstrument = new CounterInstrument( "lease-requests" ); m_stateSavesInstrument = new CounterInstrument( "state-saves" ); m_stateSaveTimeInstrument = new ValueInstrument( "state-save-time" ); }
m_instrumentRequests.increment();
m_componentLogger = aquireLogger(); m_newInstance = new CounterInstrument( "creates" ); m_dispose = new CounterInstrument( "destroys" );
/** * Create a new poolable instance by by calling the newInstance method * on the pool's ObjectFactory. * <p> * This is the method to override when you need to enforce creational * policies. * <p> * This method is only called by threads that have m_semaphore locked. */ protected Poolable newPoolable() throws Exception { Object obj = m_factory.newInstance(); // Notify the InstrumentManager m_createsInstrument.increment(); // The size is incremented after this call in case an error is thrown. m_sizeInstrument.setValue( getSize() + 1 ); return (Poolable)obj; }