ConnectionPool.java
-----------------------
package com.gtom.database;
import java.io.*;
import java.sql.*;
import java.util.*;
public class ConnectionPool implements Serializable{
/* the period the scaner run once,default is 10 minute*/
private long scanPeriod=1000*60*10L;//1000*60*30l;
/* the period we think the active connection is overdue, default is 5
minute */
private long overdurPeriod=1000*60*5L;//1000*60*60l;
/* the period the scaner should do a test to check inactive
connection*/
private long testPeriod = scanPeriod;
/* the SQL command the test should excute */
private String testCommand="select * from t_cms_tree";
private int maxPoolSize; //���ӳص��������
private int initPoolSize; //���ӳصij�ʼ��С
public ConnectionPool (){}
/**�õ����ӳصij�ʼ������
* @return �õ����ӳصij�ʼ������
* */
public int getInitPoolSize() {
return (initPoolSize);
}
/**�õ����ӳص����������
* @return �õ����ӳص����������
* */
public int getMaxPoolSize() {
return (maxPoolSize);
}
public void setMaxPoolSize(int maxPoolSize) {
this.maxPoolSize = maxPoolSize;
}
public long getOverdurPeriod() {
return overdurPeriod;
}
public void setOverdurPeriod(long overdurPeriod) {
this.overdurPeriod = overdurPeriod;
}
public long getScanPeriod() {
return scanPeriod;
}
public void setScanPeriod(long scanPeriod) {
this.scanPeriod = scanPeriod;
}
public String getTestCommand() {
return testCommand;
}
public void setTestCommand(String testCommand) {
this.testCommand = testCommand;
}
public void setTestPeriod(long testPeriod) {
this.testPeriod = testPeriod;
}
public long getTestPeriod() {
return testPeriod;
}
public String toString()
{
return super.toString() +
"[scanPeriod=" + scanPeriod + ", overdurPeriod=" + overdurPeriod+
",maxPoolSize=" + maxPoolSize + ",initPoolSize=" + initPoolSize
+
",testPeriod=" + testPeriod + ",testCommand=" + testCommand +
"]";
}
}
ConnectionPool.betwix
<?xml version="1.0" encoding="gb2312" ?>
<info>
<element name="connection-pool">
<attribute name="ScanInterval" property="scanPeriod"/>
<attribute name="OverdurInterval" property="overdurPeriod"/>
<attribute name="MaxPoolSize" property="maxPoolSize"/>
<attribute name="InitPoolSize" property="initPoolSize"/>
<element name="test">
<attribute name="interval" property="testPeriod"/>
<attribute name="command" property="testCommand"/>
</element>
</element>
</info>
connectionpool.xml
----------------------------
<?xml version="1.0" encoding="gb2312"?>
<connection-pool ScanInterval="10*60*1000" OverdurInterval="5*60*1000"
MaxPoolSize="20" InitPoolSize="1" CapacityIncrement="2">
<test interval="10*60*1000" command="select count(*) from
maxids"/>
</connection-pool>
TestConnectionPool
--------------------------
package com.gtom.database;
import junit.framework.*;
import java.sql.Connection;
import org.apache.commons.betwixt.io.BeanReader;
import java.io.FileReader;
import org.apache.log4j.*;
public class TestConnectionPool extends TestCase
{
public TestConnectionPool(String s)
{
super(s);
}
protected void setUp()
{
PropertyConfigurator.configure("log4j.cfg");
}
protected void tearDown()
{
}
public void testConnection()
{
try {
BeanReader reader = new BeanReader();
reader.registerBeanClass( ConnectionPool.class );
ConnectionPool pool = (ConnectionPool) reader.parse(new
FileReader("connectionpool.xml"));
System.out.println(pool);
}
catch(Exception e) {
System.err.println("Exception thrown: "+e);
assertTrue(false);
}
}
}
use commons-betwixt-1.0-beta-1.jar
Thank you very much!
regards
IMCaptor
-----�ʼ�ԭ��-----
������: Michael Davey [mailto:[EMAIL PROTECTED]]
����ʱ��: 2002��11��19�� 15:47
�ռ���: Jakarta Commons Users List
����: Re: beatwix map problem
Bob,
Please could you post a sourecode testcase? Either a standalone
testcase or as modifications to the betwixt testcases. Also, what OS,
JRE, betwixt and digester versions are you using?
Cheers,
--
Michael
IMCaptor wrote:
> Hello All:
> I have a problem when I use beatwix,
> Because my legacy code have fix the xml schema like this
> <connection-pool >
> <test interval="600000" command="select count(*) from MAXIDS"/>
> </connection-pool>
> in the sample, I want map the class's attribute
> "testPeriod" and "testCommand" to "interval" and "command",
> so I write the betwixt file like below
>
> <info>
> <element name="connection-pool">
> <element name="test">
> <attribute name="interval" property="testPeriod"/>
> <attribute name="command" property="testCommand"/>
> </element>
> </element>
> </info>
> but it doesn't work, who can help me
> Thank u!
>
> Bob Wang
> Regards
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>