[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/pool IDRSPool.java,1.1,1.2 RepPool.java,1.1,1.2
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2003-03-17 14:05:35
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool
In directory sc8-pr-cvs1:/tmp/cvs-serv25653/dev/src/net/sourceforge/idrs/pool
Modified Files:
IDRSPool.java RepPool.java DbPool.java ScriptPool.java
ScriptContextPool.java JDBCPool.java
Log Message:
Added Initial EJB Support
Index: IDRSPool.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool/IDRSPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** IDRSPool.java 22 Aug 2002 20:06:36 -0000 1.1
--- IDRSPool.java 17 Mar 2003 14:05:01 -0000 1.2
***************
*** 1,30 ****
! package net.sourceforge.idrs.pool;
! import java.util.*;
!
! /**
! * This interface acts as a connection between the IDRS and a
! * pooling implementation
! */
!
! public interface IDRSPool {
! /**
! *Retrieves an object from the pool, does not define failure condition
! */
! public Object getObj() throws Exception;
!
! /**
! *Returns an object to the pool, does not define failure conditions
! */
!
! public void returnObj(Object obj) throws Exception;
!
!
!
! /**
! *Deinitializes the pool
! */
! public void close() throws Exception;
!
!
!
}
--- 1,30 ----
! package net.sourceforge.idrs.pool;
! import java.util.*;
!
! /**
! * This interface acts as a connection between the IDRS and a
! * pooling implementation
! */
!
! public interface IDRSPool {
! /**
! *Retrieves an object from the pool, does not define failure condition
! */
! public Object getObj() throws Exception;
!
! /**
! *Returns an object to the pool, does not define failure conditions
! */
!
! public void returnObj(Object obj) throws Exception;
!
!
!
! /**
! *Deinitializes the pool
! */
! public void close() throws Exception;
!
!
!
}
Index: RepPool.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool/RepPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RepPool.java 22 Aug 2002 20:06:37 -0000 1.1
--- RepPool.java 17 Mar 2003 14:05:01 -0000 1.2
***************
*** 1,44 ****
! package net.sourceforge.idrs.pool;
!
! import net.sourceforge.idrs.core.report.*;
! import java.sql.*;
!
! /**
! * Defines the basis for a Report pool, must be exteded
! */
! public abstract class RepPool implements IDRSPool {
!
! String poolname;
! int min;
! int limit;
! int idleTime;
! long sleepTime;
! String logPath;
! IDRSRep rep;
!
! public void build(int objectMin, int objectLimit, IDRSRep rep, long sleepTime, String path,int trys) throws Exception {
! this.rep = rep;
! this.min = objectMin;
! this.limit=objectLimit;
! this.sleepTime = sleepTime;
! this.logPath = path;
!
! }
!
! /**
! *Retrieves a Report
! */
! public IDRSRep getReport() throws Exception {
! return (IDRSRep) getObj();
! }
!
! /**
! *Returns a Report
! */
! public void returnReport(IDRSRep rep) throws Exception {
! returnObj(rep);
! }
!
!
!
}
--- 1,44 ----
! package net.sourceforge.idrs.pool;
!
! import net.sourceforge.idrs.core.report.*;
! import java.sql.*;
!
! /**
! * Defines the basis for a Report pool, must be exteded
! */
! public abstract class RepPool implements IDRSPool {
!
! String poolname;
! int min;
! int limit;
! int idleTime;
! long sleepTime;
! String logPath;
! IDRSRep rep;
!
! public void build(int objectMin, int objectLimit, IDRSRep rep, long sleepTime, String path,int trys) throws Exception {
! this.rep = rep;
! this.min = objectMin;
! this.limit=objectLimit;
! this.sleepTime = sleepTime;
! this.logPath = path;
!
! }
!
! /**
! *Retrieves a Report
! */
! public IDRSRep getReport() throws Exception {
! return (IDRSRep) getObj();
! }
!
! /**
! *Returns a Report
! */
! public void returnReport(IDRSRep rep) throws Exception {
! returnObj(rep);
! }
!
!
!
}
Index: DbPool.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool/DbPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DbPool.java 22 Aug 2002 20:06:36 -0000 1.1
--- DbPool.java 17 Mar 2003 14:05:01 -0000 1.2
***************
*** 1,47 ****
! package net.sourceforge.idrs.pool;
!
! import java.sql.*;
! import net.sourceforge.idrs.jdbc.*;
! /**
! * Defines the basis for a DB pool, must be exteded
! */
! public abstract class DbPool implements IDRSPool {
! JDBCInfo info;
! String poolname;
! int min;
! int limit;
! int idleTime;
! long sleepTime;
! String logpath;
!
!
! public void build(String poolname, String drivername, String url,
! String username, String password, int min, int limit,
! long daysOpen, long sleep, String path) throws Exception {
! info = new JDBCInfo(poolname, drivername, url, username, password);
!
! }
!
! /**
! *Retrieves a connection
! */
! public Connection getConnection() throws Exception {
! return (Connection) getObj();
! }
!
! /**
! *Returns a connection
! */
! public void returnConnection(Connection con) throws Exception {
! returnObj(con);
! }
!
! /**
! *Returns the jdbcinfo object
! */
! public JDBCInfo getInfo() {
! return info;
! }
!
!
}
--- 1,49 ----
! package net.sourceforge.idrs.pool;
!
! import java.sql.*;
! import net.sourceforge.idrs.jdbc.*;
! /**
! * Defines the basis for a DB pool, must be exteded
! */
! public abstract class DbPool implements IDRSPool {
! JDBCInfo info;
! String poolname;
! int min;
! int limit;
! int idleTime;
! long sleepTime;
! String logpath;
!
!
! public void build(String poolname, String drivername, String url,
! String username, String password, int min, int limit,
! long daysOpen, long sleep, String path) throws Exception {
! //System.out.println("building pool " + poolname);
! info = new JDBCInfo(poolname, drivername, url, username, password);
! //System.out.println("built pool " + poolname);
!
! }
!
! /**
! *Retrieves a connection
! */
! public Connection getConnection() throws Exception {
! return (Connection) getObj();
! }
!
! /**
! *Returns a connection
! */
! public void returnConnection(Connection con) throws Exception {
! returnObj(con);
! }
!
! /**
! *Returns the jdbcinfo object
! */
! public JDBCInfo getInfo() {
! return info;
! }
!
!
}
Index: ScriptPool.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool/ScriptPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ScriptPool.java 22 Aug 2002 20:06:37 -0000 1.1
--- ScriptPool.java 17 Mar 2003 14:05:01 -0000 1.2
***************
*** 1,45 ****
! package net.sourceforge.idrs.pool;
!
! import java.sql.*;
! import net.sourceforge.idrs.script.embedable.*;
!
! /**
! * Defines the basis for a Report pool, must be exteded
! */
! public abstract class ScriptPool implements IDRSPool {
!
! String poolname;
! int min;
! int limit;
! int idleTime;
! long sleepTime;
! String logPath;
! String scriptClass;
!
! public void build(int objectMin, int objectLimit, String scriptClass, long sleepTime, String path,int trys) throws Exception {
!
! this.min = objectMin;
! this.limit=objectLimit;
! this.sleepTime = sleepTime;
! this.logPath = path;
! this.scriptClass = scriptClass;
!
! }
!
! /**
! *Retrieves a Conetext
! */
! public IDRSScriptLanguage getContext() throws Exception {
! return (IDRSScriptLanguage) getObj();
! }
!
! /**
! *Returns a Context
! */
! public void returnContext(IDRSScriptLanguage script) throws Exception {
! returnObj(script);
! }
!
!
!
}
--- 1,45 ----
! package net.sourceforge.idrs.pool;
!
! import java.sql.*;
! import net.sourceforge.idrs.script.embedable.*;
!
! /**
! * Defines the basis for a Report pool, must be exteded
! */
! public abstract class ScriptPool implements IDRSPool {
!
! String poolname;
! int min;
! int limit;
! int idleTime;
! long sleepTime;
! String logPath;
! String scriptClass;
!
! public void build(int objectMin, int objectLimit, String scriptClass, long sleepTime, String path,int trys) throws Exception {
!
! this.min = objectMin;
! this.limit=objectLimit;
! this.sleepTime = sleepTime;
! this.logPath = path;
! this.scriptClass = scriptClass;
!
! }
!
! /**
! *Retrieves a Conetext
! */
! public IDRSScriptLanguage getContext() throws Exception {
! return (IDRSScriptLanguage) getObj();
! }
!
! /**
! *Returns a Context
! */
! public void returnContext(IDRSScriptLanguage script) throws Exception {
! returnObj(script);
! }
!
!
!
}
Index: ScriptContextPool.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool/ScriptContextPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ScriptContextPool.java 22 Aug 2002 20:06:37 -0000 1.1
--- ScriptContextPool.java 17 Mar 2003 14:05:01 -0000 1.2
***************
*** 1,66 ****
! package net.sourceforge.idrs.pool;
!
! import org.apache.commons.pool.*;
! import org.apache.commons.*;
! import org.apache.commons.pool.impl.*;
! import org.apache.commons.*;
! import net.sourceforge.idrs.script.embedable.*;
!
!
! public class ScriptContextPool extends ScriptPool {
!
! ObjectPool pool;
!
! public void build(int objectMin, int objectLimit, String scriptClass, long sleepTime, String path,int trys) throws Exception {
! super.build(objectMin,objectLimit,scriptClass,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 ScriptFactory(scriptClass),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 ScriptFactory implements PoolableObjectFactory {
! String scriptClass;
!
! public ScriptFactory(String scriptClass) {
! this.scriptClass = scriptClass;
! }
!
! public void activateObject(Object obj) throws Exception {
!
! }
!
! public void destroyObject(Object obj) throws Exception {
!
! }
!
! public Object makeObject() throws Exception {
! return Class.forName(scriptClass).newInstance();
! }
!
! public void passivateObject(Object obj) throws Exception {
!
! }
!
! public boolean validateObject(Object obj) {
! return obj != null;
! }
! }
--- 1,66 ----
! package net.sourceforge.idrs.pool;
!
! import org.apache.commons.pool.*;
! import org.apache.commons.*;
! import org.apache.commons.pool.impl.*;
! import org.apache.commons.*;
! import net.sourceforge.idrs.script.embedable.*;
!
!
! public class ScriptContextPool extends ScriptPool {
!
! ObjectPool pool;
!
! public void build(int objectMin, int objectLimit, String scriptClass, long sleepTime, String path,int trys) throws Exception {
! super.build(objectMin,objectLimit,scriptClass,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 ScriptFactory(scriptClass),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 ScriptFactory implements PoolableObjectFactory {
! String scriptClass;
!
! public ScriptFactory(String scriptClass) {
! this.scriptClass = scriptClass;
! }
!
! public void activateObject(Object obj) throws Exception {
!
! }
!
! public void destroyObject(Object obj) throws Exception {
!
! }
!
! public Object makeObject() throws Exception {
! return Class.forName(scriptClass).newInstance();
! }
!
! public void passivateObject(Object obj) throws Exception {
!
! }
!
! public boolean validateObject(Object obj) {
! return obj != null;
! }
! }
Index: JDBCPool.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/pool/JDBCPool.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** JDBCPool.java 22 Aug 2002 20:06:36 -0000 1.1
--- JDBCPool.java 17 Mar 2003 14:05:01 -0000 1.2
***************
*** 1,72 ****
! package net.sourceforge.idrs.pool;
!
! import org.apache.commons.pool.*;
! import org.apache.commons.pool.impl.*;
! import net.sourceforge.idrs.jdbc.*;
! import java.sql.*;
!
! public class JDBCPool extends DbPool {
! ObjectPool pool;
!
! public void build(String poolname, String drivername, String url,
! String username, String password, int min, int limit,
! long daysOpen, long sleep, String path) throws Exception {
! super.build(poolname,drivername,url,username,password,min,limit,daysOpen,sleep,path);
! 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 JDBCFactory(info),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 JDBCFactory implements PoolableObjectFactory {
! JDBCInfo jdbcInfo;
!
! public JDBCFactory(JDBCInfo jdbc) {
! this.jdbcInfo = jdbc;
! }
!
! public void activateObject(Object obj) throws Exception {
!
! }
!
! public void destroyObject(Object obj) throws Exception {
! ((Connection) obj).close();
! }
!
! public Object makeObject() throws Exception {
! return jdbcInfo.build();
! }
!
! public void passivateObject(Object obj) throws Exception {
!
! }
!
! public boolean validateObject(Object obj) {
! try {
! return obj != null && ! ((Connection) obj).isClosed();
! }
! catch (Exception e) {
! return false;
! }
! }
! }
--- 1,77 ----
! package net.sourceforge.idrs.pool;
!
! import org.apache.commons.pool.*;
! import org.apache.commons.pool.impl.*;
! import net.sourceforge.idrs.jdbc.*;
! import java.sql.*;
!
! public class JDBCPool extends DbPool {
! ObjectPool pool;
!
! public void build(String poolname, String drivername, String url,
! String username, String password, int min, int limit,
! long daysOpen, long sleep, String path) throws Exception {
! super.build(poolname,drivername,url,username,password,min,limit,daysOpen,sleep,path);
! 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 JDBCFactory(info),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 JDBCFactory implements PoolableObjectFactory {
! JDBCInfo jdbcInfo;
!
! public JDBCFactory(JDBCInfo jdbc) {
! this.jdbcInfo = jdbc;
! //System.out.println("new factory : " + jdbc.getPoolname());
! }
!
! public void activateObject(Object obj) throws Exception {
!
! }
!
! public void destroyObject(Object obj) throws Exception {
! ((Connection) obj).close();
! }
!
! public Object makeObject() throws Exception {
! //System.out.println("building an instance of " + this.jdbcInfo.getPoolname());
! Connection con = jdbcInfo.build();
! //System.out.println("built an instance of " + this.jdbcInfo.getPoolname());
! return con;
! }
!
! public void passivateObject(Object obj) throws Exception {
!
! }
!
! public boolean validateObject(Object obj) {
! try {
! return obj != null && ! ((Connection) obj).isClosed();
! }
! catch (Exception e) {
! e.printStackTrace();
! return false;
! }
! }
! }
|