[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/pool IDRSRepPool.java,1.1,1.2
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2003-01-08 06:01:40
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool
In directory sc8-pr-cvs1:/tmp/cvs-serv32140/dev/src/net/sourceforge/idrs/pool
Modified Files:
IDRSRepPool.java
Log Message:
Added new validation capabilities, and all idrs object are given access to the idrs script oject without it being passed in as a parameter. Also fixed a security bug and setup for more memory effecient pooling. Finally add a new configuration file to simplify deployments.
Index: IDRSRepPool.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool/IDRSRepPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IDRSRepPool.java 22 Aug 2002 20:06:36 -0000 1.1
--- IDRSRepPool.java 8 Jan 2003 06:01:38 -0000 1.2
***************
*** 1,64 ****
! package net.sourceforge.idrs.pool;
!
! import org.apache.commons.pool.*;
! import org.apache.commons.pool.impl.*;
! import net.sourceforge.idrs.core.report.*;
!
! public class IDRSRepPool extends net.sourceforge.idrs.pool.RepPool {
! ObjectPool pool;
!
! public void build(int objectMin, int objectLimit, IDRSRep rep, long sleepTime, String path,int trys) throws Exception {
! super.build(objectMin,objectLimit,rep,sleepTime,path,trys);
! GenericObjectPool.Config conf = new GenericObjectPool.Config();
!
! conf.maxActive = limit;
! conf.maxWait = sleepTime;
! conf.testOnBorrow = true;
! conf.timeBetweenEvictionRunsMillis = 100000;
! conf.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
!
! pool = new GenericObjectPool(new ReportFactory(rep),conf);
!
! }
!
!
! public Object getObj() throws Exception {
! return pool.borrowObject();
! }
!
! public void returnObj(Object obj) throws Exception {
! pool.returnObject(obj);
! }
!
! public void close() throws Exception {
! pool.close();
! }
! }
!
! class ReportFactory implements PoolableObjectFactory {
! IDRSRep rep;
!
! public ReportFactory(IDRSRep rep) {
! this.rep = rep;
! }
!
! public void activateObject(Object obj) throws Exception {
!
! }
!
! public void destroyObject(Object obj) throws Exception {
!
! }
!
! public Object makeObject() throws Exception {
! return rep.clone();
! }
!
! public void passivateObject(Object obj) throws Exception {
!
! }
!
! public boolean validateObject(Object obj) {
! return obj != null;
! }
! }
--- 1,69 ----
! package net.sourceforge.idrs.pool;
!
! import org.apache.commons.pool.*;
! import org.apache.commons.pool.impl.*;
! import net.sourceforge.idrs.core.report.*;
!
! public class IDRSRepPool extends net.sourceforge.idrs.pool.RepPool {
! ObjectPool pool;
! IDRSRep rep;
!
! public void build(int objectMin, int objectLimit, IDRSRep rep, long sleepTime, String path,int trys) throws Exception {
! super.build(objectMin,objectLimit,rep,sleepTime,path,trys);
! GenericObjectPool.Config conf = new GenericObjectPool.Config();
!
! conf.maxActive = limit;
! conf.maxWait = sleepTime;
! conf.testOnBorrow = true;
! conf.timeBetweenEvictionRunsMillis = 100000;
! conf.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_BLOCK;
! this.rep = rep;
! pool = new GenericObjectPool(new ReportFactory(rep),conf);
!
! }
!
!
! public Object getObj() throws Exception {
! return new IDRSRep((IDRSHead) pool.borrowObject(), this.rep.getBody());
! }
!
! public void returnObj(Object obj) throws Exception {
! pool.returnObject(((IDRSRep) obj).getHead());
! }
!
! public void close() throws Exception {
! pool.close();
! }
! }
!
! class ReportFactory implements PoolableObjectFactory {
! IDRSRep rep;
! IDRSHead head;
! IDRSBody body;
!
! public ReportFactory(IDRSRep rep) {
! this.rep = rep;
! this.head = rep.getHead();
! this.body = rep.getBody();
! }
!
! public void activateObject(Object obj) throws Exception {
!
! }
!
! public void destroyObject(Object obj) throws Exception {
!
! }
!
! public Object makeObject() throws Exception {
! return head.clone();
! }
!
! public void passivateObject(Object obj) throws Exception {
!
! }
!
! public boolean validateObject(Object obj) {
! return obj != null;
! }
! }
|