List of usage examples for org.apache.commons.pool BasePoolableObjectFactory BasePoolableObjectFactory
BasePoolableObjectFactory
From source file:com.github.chrishantha.microbenchmark.objectpool.StackObjectPoolBenchmark.java
@Override public void setupObjectPool() { objectPool = new StackObjectPool<>(new BasePoolableObjectFactory<TestObject>() { @Override// www. j a va 2 s. co m public TestObject makeObject() throws Exception { return new TestObject(true); } }, poolSize, poolSize); }
From source file:com.github.chrishantha.microbenchmark.objectpool.CommonsPoolGenericObjectPoolBenchmark.java
@Override public void setupObjectPool() { objectPool = new GenericObjectPool<>(new BasePoolableObjectFactory<TestObject>() { @Override/*from ww w .java 2 s. c om*/ public TestObject makeObject() throws Exception { return new TestObject(true); } }, poolSize); }
From source file:com.github.chrishantha.microbenchmark.objectpool.CommonsPoolSoftReferenceObjectPoolBenchmark.java
@Override public void setupObjectPool() { objectPool = new SoftReferenceObjectPool<>(new BasePoolableObjectFactory<TestObject>() { @Override//from ww w . j a va 2 s .c o m public TestObject makeObject() throws Exception { return new TestObject(true); } }); }
From source file:com.lfv.yada.net.PacketPool.java
private PacketPool() { // Create a logger for this class log = LogFactory.getLog(getClass()); pool = new StackObjectPool(new BasePoolableObjectFactory() { public Object makeObject() throws Exception { return new Packet(PACKET_LENGTH); }/*from www . j a va 2s . c o m*/ }); //debugList = new LinkedList<DebugEntry>(); }
From source file:com.cyberway.issue.io.arc.ARCWriterPool.java
/** * Constructor//from ww w. j ava 2 s . c o m * * @param serial Used to generate unique filename sequences * @param settings Settings for this pool. * @param poolMaximumActive * @param poolMaximumWait */ public ARCWriterPool(final AtomicInteger serial, final WriterPoolSettings settings, final int poolMaximumActive, final int poolMaximumWait) { super(serial, new BasePoolableObjectFactory() { public Object makeObject() throws Exception { return new ARCWriter(serial, settings.getOutputDirs(), settings.getPrefix(), settings.getSuffix(), settings.isCompressed(), settings.getMaxSize(), settings.getMetadata()); } public void destroyObject(Object arcWriter) throws Exception { ((WriterPoolMember) arcWriter).close(); super.destroyObject(arcWriter); } }, settings, poolMaximumActive, poolMaximumWait); }
From source file:com.thoughtworks.studios.shine.cruise.stage.details.LazyStageGraphLoader.java
LazyStageGraphLoader(StageResourceImporter importer, StageStorage stageStorage, int transformerRegistryPoolSize) { this.importer = importer; this.stageStorage = stageStorage; transformerRegistryPool = new GenericObjectPool(new BasePoolableObjectFactory() { @Override/*from ww w .ja va 2 s .c om*/ public Object makeObject() throws Exception { return new XSLTTransformerRegistry(); } @Override public void activateObject(Object obj) throws Exception { XSLTTransformerRegistry registry = (XSLTTransformerRegistry) obj; registry.reset(); } }, transformerRegistryPoolSize, GenericObjectPool.WHEN_EXHAUSTED_GROW, GenericObjectPool.DEFAULT_MAX_WAIT); }
From source file:com.cyberway.issue.io.warc.WARCWriterPool.java
/** * Constructor/* w ww .j a v a 2 s. co m*/ * @param serial Used to generate unique filename sequences * @param settings Settings for this pool. * @param poolMaximumActive * @param poolMaximumWait */ public WARCWriterPool(final AtomicInteger serial, final WriterPoolSettings settings, final int poolMaximumActive, final int poolMaximumWait) { super(serial, new BasePoolableObjectFactory() { public Object makeObject() throws Exception { return new WARCWriter(serial, settings.getOutputDirs(), settings.getPrefix(), settings.getSuffix(), settings.isCompressed(), settings.getMaxSize(), settings.getMetadata()); } public void destroyObject(Object writer) throws Exception { ((WriterPoolMember) writer).close(); super.destroyObject(writer); } }, settings, poolMaximumActive, poolMaximumWait); }
From source file:dk.statsbiblioteket.doms.radiotv.extractor.transcoder.ProcessorChainThreadPool.java
/** * Singleton.//w w w . j a v a 2 s . c om */ private ProcessorChainThreadPool(ServletConfig config) { theQueue = new LinkedBlockingQueue<ProcessorChainThread>(); //theQueue = new PriorityBlockingQueue(1000, new ThreadComparator()); maxActiveProcesses = Integer.parseInt(Util.getInitParameter(config, Constants.MAX_ACTIVE_PROCESSING)); log.info("Creating thread pool with max active processes = " + maxActiveProcesses); thePool = new GenericObjectPool(new BasePoolableObjectFactory() { @Override public Object makeObject() throws Exception { return new Object(); } }, maxActiveProcesses); }
From source file:chatserver.ChatData.java
public PoolableObjectFactory getPoolableObjectFactory() { return new BasePoolableObjectFactory() { public Object makeObject() { return new ChatData(); }//from ww w . ja v a2s . c om public void passivateObject(Object obj) { ChatData ed = (ChatData) obj; ed.clean(); } public void destroyObject(Object obj) { if (obj == null) return; passivateObject(obj); obj = null; } public boolean validateObject(Object obj) { if (obj == null) return false; else return true; } }; }
From source file:ftpserver.Data.java
public PoolableObjectFactory getPoolableObjectFactory() { return new BasePoolableObjectFactory() { public Object makeObject() { return new Data(); }/*from w ww .j av a2 s . c om*/ public void passivateObject(Object obj) { Data ed = (Data) obj; ed.clean(); } public void destroyObject(Object obj) { if (obj == null) return; passivateObject(obj); obj = null; } public boolean validateObject(Object obj) { if (obj == null) return false; else return true; } }; }