1 6 7 package org.jfox.pool; 8 9 import org.jfox.ioc.common.AbstractComponent; 10 11 16 17 public abstract class AbstractObjectPool extends AbstractComponent implements ObjectPool { 18 19 protected ObjectFactory factory = null; 20 21 public AbstractObjectPool(ObjectFactory factory) { 22 if(factory == null) throw new NullPointerException ("factory is null."); 24 this.factory = factory; 25 } 26 27 public AbstractObjectPool(Class factoryClass, Class poolableClass) { 28 try { 30 factory = (ObjectFactory) factoryClass.getConstructor(new Class []{java.lang.Class .class}).newInstance(new Object []{poolableClass}); 31 } 32 catch(NoSuchMethodException e) { 33 logger.fatal("No such constructor" + e); 34 } 35 catch(Exception e) { 36 logger.fatal("ObjectFactory " + factoryClass.getName() + " instantiator error" + e); 37 } 38 } 39 40 public ObjectFactory getObjectFactory() { 41 return factory; 42 } 43 44 49 public String getObjectClass() { 50 return factory.getObjectClass().getName(); 51 } 52 53 56 public void clear() { 57 throw new UnsupportedOperationException ("clear"); 58 } 59 60 protected void doInit() throws Exception { 61 62 } 63 64 protected void doDestroy() throws Exception { 65 66 } 67 68 73 public int getWorking() { 74 throw new UnsupportedOperationException ("getWorking"); 75 } 76 77 82 public int getRest() { 83 throw new UnsupportedOperationException ("getRest"); 84 } 85 86 public int getInitNum() { 87 throw new UnsupportedOperationException ("getInitNum"); 88 } 89 90 public int getMaxRest() { 91 throw new UnsupportedOperationException ("getMaxRest"); 92 } 93 } 94 | Popular Tags |