1 17 package org.apache.avalon.excalibur.component.test; 18 19 import org.apache.avalon.excalibur.pool.Poolable; 20 import org.apache.avalon.excalibur.pool.Recyclable; 21 import org.apache.avalon.framework.activity.Disposable; 22 import org.apache.avalon.framework.activity.Initializable; 23 import org.apache.avalon.framework.component.Component; 24 import org.apache.avalon.framework.logger.Logger; 25 26 32 public class PoolableTestObject 33 implements PoolableTestObjectInterface, Initializable, Recyclable, Disposable, Poolable 34 { 35 36 private static Object m_semaphore = new Object (); 37 38 39 private static int m_instanceCounter = 0; 40 41 private static Logger m_logger; 42 43 44 private int m_instanceId; 45 46 49 public PoolableTestObject() 50 { 51 synchronized( m_semaphore ) 52 { 53 m_instanceCounter++; 54 m_instanceId = m_instanceCounter; 55 } 56 } 57 58 61 64 public static void resetInstanceCounter() 65 { 66 synchronized( m_semaphore ) 67 { 68 m_instanceCounter = 0; 69 } 70 } 71 72 75 public static void setStaticLoggger( Logger logger ) 76 { 77 m_logger = logger; 78 } 79 80 83 86 public void initialize() 87 { 88 m_logger.debug( "PoolableTestObject #" + m_instanceId + " initialized." ); 89 } 90 91 94 97 public void recycle() 98 { 99 m_logger.debug( "PoolableTestObject #" + m_instanceId + " recycled." ); 100 } 101 102 105 108 public void dispose() 109 { 110 m_logger.debug( "PoolableTestObject #" + m_instanceId + " disposed." ); 111 } 112 } 113 114 | Popular Tags |