Intial import.
This commit is contained in:
parent
db614924ac
commit
7e5f191232
28 changed files with 3411 additions and 0 deletions
26
simplepool/build.properties
Normal file
26
simplepool/build.properties
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Project
|
||||
proj.name=simplepool
|
||||
proj.version=1.0
|
||||
|
||||
# Locations
|
||||
path.build=build
|
||||
path.src=src
|
||||
path.dist=dist
|
||||
path.lib=lib
|
||||
path.javadoc=javadoc
|
||||
|
||||
# Jar
|
||||
jar.name=${proj.name}
|
||||
|
||||
# Examples
|
||||
ex.name=${proj.name}-examples-${proj.version}
|
||||
path.ex=${proj.name}-examples
|
||||
|
||||
# Release
|
||||
release.name=${proj.name}-${proj.version}
|
||||
|
||||
# Javadoc
|
||||
javadoc.title=SimplePool API
|
||||
javadoc.api.link=http://java.sun.com/j2se/1.4.2/docs/api
|
||||
javadoc.servlet.link=http://java.sun.com/products/servlet/2.3/javadoc/
|
||||
javadoc.packages=net.java.dev.simplepool.*
|
88
simplepool/build.xml
Normal file
88
simplepool/build.xml
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project name="simplepool" default="build" basedir=".">
|
||||
<property file="${basedir}/build.properties" />
|
||||
<property name="path.jar.build" value="${path.build}/${jar.name}"/>
|
||||
<property name="path.ex.build" value="${path.build}/${ex.name}"/>
|
||||
<property name="path.rel.build" value="${path.build}/${release.name}"/>
|
||||
<path id="path.source">
|
||||
<pathelement location="${path.src}" />
|
||||
</path>
|
||||
<path id="path.class">
|
||||
<fileset dir="${path.lib}">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<target name="init">
|
||||
<tstamp />
|
||||
<mkdir dir="${path.build}"/>
|
||||
<mkdir dir="${path.dist}"/>
|
||||
<mkdir dir="${path.javadoc}"/>
|
||||
</target>
|
||||
<target name="compile" depends="init" description="Compiles sources">
|
||||
<mkdir dir="${path.jar.build}" />
|
||||
<javac sourcepathref="path.source" classpathref="path.class" destdir="${path.jar.build}" debug="off" deprecation="on">
|
||||
<src refid="path.source" />
|
||||
</javac>
|
||||
</target>
|
||||
<target name="build" depends="clean,compile,jar" description="Rebuilds project" />
|
||||
<target name="jar" depends="compile" description="Builds the JAR">
|
||||
<copy todir="${path.jar.build}">
|
||||
<fileset dir="${path.src}" includes="*.properties" />
|
||||
</copy>
|
||||
<jar destfile="${basedir}/${path.dist}/${jar.name}.jar" basedir="${path.jar.build}" excludes="**/.dependency-info/**" />
|
||||
</target>
|
||||
<target name="examples" depends="build" description="Builds the Examples WAR">
|
||||
<copy todir="${path.ex.build}">
|
||||
<fileset dir="${path.ex}"/>
|
||||
<filterset>
|
||||
<filter token="EX.NAME" value="${ex.name}"/>
|
||||
</filterset>
|
||||
</copy>
|
||||
<copy file="${path.dist}/${jar.name}.jar" todir="${path.ex.build}/WEB-INF/lib/"/>
|
||||
<touch>
|
||||
<fileset dir="${path.ex.build}"/>
|
||||
</touch>
|
||||
<jar jarfile="${path.dist}/${ex.name}.war" basedir="${path.ex.build}"/>
|
||||
</target>
|
||||
<target name="release" depends="build,javadoc" description="Builds the release archives">
|
||||
<mkdir dir="${path.rel.build}"/>
|
||||
<copy todir="${path.rel.build}">
|
||||
<fileset file="${path.dist}/${jar.name}.jar"/>
|
||||
<fileset dir="${basedir}" includes="${path.javadoc}/**"/>
|
||||
</copy>
|
||||
<touch>
|
||||
<fileset dir="${path.rel.build}"/>
|
||||
</touch>
|
||||
<zip destfile="${path.dist}/${release.name}.zip" basedir="${path.build}" includes="${release.name}/**"/>
|
||||
<tar tarfile="${path.dist}/${release.name}.tar.gz" compression="gzip">
|
||||
<tarfileset dir="${path.rel.build}" prefix="${release.name}" mode="644"/>
|
||||
</tar>
|
||||
</target>
|
||||
<target name="src" description="Builds the source archive">
|
||||
<tar tarfile="${path.dist}/${release.name}-src.tar.gz" compression="gzip">
|
||||
<tarfileset dir="${basedir}" prefix="${release.name}">
|
||||
<include name="${path.src}/**"/>
|
||||
<include name="${path.ex}/**"/>
|
||||
<include name="${path.lib}/**"/>
|
||||
<include name="build.*"/>
|
||||
</tarfileset>
|
||||
</tar>
|
||||
</target>
|
||||
<target name="javadoc" depends="init" description="Builds the Javadoc">
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${path.javadoc}" includes="*,*/**"/>
|
||||
</delete>
|
||||
<javadoc sourcepath="${path.src}" destdir="${path.javadoc}" packagenames="${javadoc.packages}" windowtitle="${javadoc.title}" verbose="false" failonerror="true" additionalparam="">
|
||||
<link href="${javadoc.api.link}"/>
|
||||
<link href="${javadoc.servlet.link}"/>
|
||||
<classpath refid="path.class"/>
|
||||
</javadoc>
|
||||
</target>
|
||||
<target name="clean" depends="init" description="Removes classses and javadoc">
|
||||
<delete quiet="true" includeEmptyDirs="true">
|
||||
<fileset dir="${path.build}" includes="*,*/**"/>
|
||||
<fileset dir="${path.dist}" includes="*,*/**"/>
|
||||
<fileset dir="${path.javadoc}" includes="*,*/**"/>
|
||||
</delete>
|
||||
</target>
|
||||
</project>
|
107
simplepool/conf/server.xml
Normal file
107
simplepool/conf/server.xml
Normal file
|
@ -0,0 +1,107 @@
|
|||
|
||||
|
||||
<Server port="8005" shutdown="SHUTDOWN" debug="0">
|
||||
|
||||
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" debug="0"/>
|
||||
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" debug="0"/>
|
||||
|
||||
<GlobalNamingResources>
|
||||
|
||||
<Resource name="UserDatabase" auth="Container" type="org.apache.catalina.UserDatabase"/>
|
||||
|
||||
<ResourceParams name="UserDatabase">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>pathname</name>
|
||||
<value>conf/tomcat-users.xml</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
|
||||
<Resource name="jdbc/PooledDS" type="javax.sql.DataSource" auth="Container"/>
|
||||
|
||||
<ResourceParams name="jdbc/PooledDS">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>net.java.dev.simplepool.SimplePoolDataSourceFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>driver</name>
|
||||
<value>com.mysql.jdbc.Driver</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>user</name>
|
||||
<value>dbuser</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>test</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jdbcUrl</name>
|
||||
<value>jdbc:mysql://localhost:3306/dbname</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>minConns</name>
|
||||
<value>8</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConns</name>
|
||||
<value>30</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConnTime</name>
|
||||
<value>1</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxCheckoutSeconds</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
|
||||
</ResourceParams>
|
||||
|
||||
</GlobalNamingResources>
|
||||
|
||||
<Service name="Catalina">
|
||||
|
||||
<Connector port="80"
|
||||
maxThreads="150"
|
||||
minSpareThreads="25"
|
||||
maxSpareThreads="75"
|
||||
enableLookups="false"
|
||||
redirectPort="8443"
|
||||
acceptCount="100"
|
||||
debug="0"
|
||||
connectionTimeout="20000"
|
||||
proxyPort="80"
|
||||
/>
|
||||
|
||||
|
||||
<Engine name="Catalina" defaultHost="www.waveblog.com" debug="0">
|
||||
|
||||
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
|
||||
debug="1" resourceName="UserDatabase"/>
|
||||
|
||||
<Host name="localhost"
|
||||
debug="1" appBase="webapps" unpackWARs="true" autoDeploy="true"
|
||||
xmlValidation="false" xmlNamespaceAware="false">
|
||||
|
||||
<Context path="" docBase="ROOT" debug="0" reloadable="true">
|
||||
<ResourceLink name="jdbc/PooledDS" global="jdbc/PooledDS" type="javax.sql.DataSource" />
|
||||
</Context>
|
||||
|
||||
<Valve className="org.apache.catalina.valves.AccessLogValve"
|
||||
directory="logs" prefix="waveblog" suffix=".log"
|
||||
pattern="combined" resolveHosts="false"/>
|
||||
|
||||
</Host>
|
||||
|
||||
|
||||
</Engine>
|
||||
|
||||
</Service>
|
||||
|
||||
</Server>
|
21
simplepool/conf/test.jsp
Normal file
21
simplepool/conf/test.jsp
Normal file
|
@ -0,0 +1,21 @@
|
|||
<% out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); %>
|
||||
<%@ page contentType="text/xml;charset=UTF-8"%>
|
||||
<%@ page session="false"%>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
|
||||
|
||||
<sql:setDataSource dataSource="jdbc/PooledDS" />
|
||||
|
||||
<sql:query var="page" maxRows="30">
|
||||
select * from entry
|
||||
</sql:query>
|
||||
|
||||
<document>
|
||||
<c:forEach var="row" items="${page.rows}" varStatus="counter">
|
||||
<entry>
|
||||
<count><c:out value="${counter.count}"/></count>
|
||||
<id><c:out value="${row.id}"/></id>
|
||||
<title><c:out value="${row.name}"/></title>
|
||||
</entry>
|
||||
</c:forEach>
|
||||
</document>
|
BIN
simplepool/lib/commons-logging-api.jar
Normal file
BIN
simplepool/lib/commons-logging-api.jar
Normal file
Binary file not shown.
BIN
simplepool/lib/servlet.jar
Normal file
BIN
simplepool/lib/servlet.jar
Normal file
Binary file not shown.
BIN
simplepool/simplepool-examples/WEB-INF/lib/jstl.jar
Normal file
BIN
simplepool/simplepool-examples/WEB-INF/lib/jstl.jar
Normal file
Binary file not shown.
BIN
simplepool/simplepool-examples/WEB-INF/lib/standard.jar
Normal file
BIN
simplepool/simplepool-examples/WEB-INF/lib/standard.jar
Normal file
Binary file not shown.
52
simplepool/simplepool-examples/WEB-INF/web.xml
Normal file
52
simplepool/simplepool-examples/WEB-INF/web.xml
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE web-app PUBLIC
|
||||
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
<web-app>
|
||||
<description>SimplePool Examples</description>
|
||||
|
||||
<!--
|
||||
<servlet>
|
||||
<servlet-name>SimplePoolServlet</servlet-name>
|
||||
<servlet-class>net.java.dev.simplepool.SimplePoolServlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>varName</param-name>
|
||||
<param-value>ServletPoolDS</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>driver</param-name>
|
||||
<param-value>com.mysql.jdbc.Driver</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>user</param-name>
|
||||
<param-value>dbuser</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>password</param-name>
|
||||
<param-value>dbpassword</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>jdbcUrl</param-name>
|
||||
<param-value>jdbc:mysql://localhost:3306/dbname</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>minConns</param-name>
|
||||
<param-value>8</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxConns</param-name>
|
||||
<param-value>30</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxConnTime</param-name>
|
||||
<param-value>1</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>maxCheckoutSeconds</param-name>
|
||||
<param-value>60</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
-->
|
||||
|
||||
</web-app>
|
62
simplepool/simplepool-examples/conf/server.xml
Normal file
62
simplepool/simplepool-examples/conf/server.xml
Normal file
|
@ -0,0 +1,62 @@
|
|||
<Server port="8005" shutdown="SHUTDOWN">
|
||||
<Service name="Catalina">
|
||||
<Connector port="80" />
|
||||
|
||||
<Engine name="Catalina" defaultHost="localhost">
|
||||
<Logger className="org.apache.catalina.logger.FileLogger" />
|
||||
|
||||
<Host name="localhost" appBase="webapps">
|
||||
|
||||
<!-- Define our application context -->
|
||||
<Context path="/@EX.NAME@" docBase="@EX.NAME@"
|
||||
debug="5" reloadable="true" crossContext="true">
|
||||
|
||||
<!-- Define our JDNI DataSource -->
|
||||
<Resource name="jdbc/JNDIPoolDS" type="javax.sql.DataSource" auth="Container"/>
|
||||
|
||||
<!-- Configure our JNDI DataSource -->
|
||||
<ResourceParams name="jdbc/JNDIPoolDS">
|
||||
<parameter>
|
||||
<name>factory</name>
|
||||
<value>net.java.dev.simplepool.SimplePoolDataSourceFactory</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>driver</name>
|
||||
<value>com.mysql.jdbc.Driver</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>user</name>
|
||||
<value>dbuser</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>password</name>
|
||||
<value>dbpassword</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>jdbcUrl</name>
|
||||
<value>jdbc:mysql://localhost:3306/dbname</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>minConns</name>
|
||||
<value>8</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConns</name>
|
||||
<value>30</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxConnTime</name>
|
||||
<value>1</value>
|
||||
</parameter>
|
||||
<parameter>
|
||||
<name>maxCheckoutSeconds</name>
|
||||
<value>60</value>
|
||||
</parameter>
|
||||
</ResourceParams>
|
||||
|
||||
</Context>
|
||||
|
||||
</Host>
|
||||
</Engine>
|
||||
</Service>
|
||||
</Server>
|
251
simplepool/simplepool-examples/includes/inst.css
Normal file
251
simplepool/simplepool-examples/includes/inst.css
Normal file
|
@ -0,0 +1,251 @@
|
|||
/* $Id: inst.css,v 1.1.1.1 2004-03-28 00:16:00 ethauvin Exp $
|
||||
|
||||
This file contains rules that extend or override the more basic formatting defined in tigris.css. Edit it to customize the look of applications using tigris.css (instances). You are responsible for maintaining your own set of (optional) deltas from tigris.css defaults; this file is intended as an example.
|
||||
|
||||
*/
|
||||
|
||||
/* colors, backgrounds, borders, link indication */
|
||||
#cn {
|
||||
background-image: url(../images/corporate_logo.gif);
|
||||
display: block;
|
||||
height: 17px;
|
||||
width: 138px;
|
||||
}
|
||||
|
||||
#poweredby {
|
||||
background-image: url(../images/poweredby_036.gif);
|
||||
display: block;
|
||||
height: 38px;
|
||||
width: 102px;
|
||||
}
|
||||
|
||||
#sc {
|
||||
background-image: url(../images/product_logo.gif);
|
||||
display: block;
|
||||
height: 25px;
|
||||
width: 138px;
|
||||
}
|
||||
|
||||
#toptabs td, #toptabs th {
|
||||
background-image: url(../images/nw_min_036.gif);
|
||||
}
|
||||
|
||||
.app h3, #banner, #banner td, #toptabs {
|
||||
background-color: #036;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
body #banner td a, .app h3 a, .app h4 a {
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
#banner {
|
||||
border-top: 1px solid #369;
|
||||
}
|
||||
|
||||
#mytools .label, #projecttools .label, #admintools .label, #communitytools .label {
|
||||
background-color: #ddd;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#mytools .body, #projecttools .body, #admintools .body, #communitytools .body {
|
||||
background-color: #fff;
|
||||
border-right: none;
|
||||
border-bottom: none;
|
||||
border-top: 1px solid #999;
|
||||
}
|
||||
|
||||
#mytools, #projecttools, #admintools, #communitytools {
|
||||
background-color: #ddd;
|
||||
border-right: 1px solid #666;
|
||||
border-bottom: 1px solid #666;
|
||||
}
|
||||
|
||||
#helptext {
|
||||
background-color: #ffc;
|
||||
}
|
||||
|
||||
#helptext .label {
|
||||
border-bottom: 1px solid #996;
|
||||
border-right: 1px solid #996;
|
||||
background-color: #cc9;
|
||||
}
|
||||
|
||||
#helptext .body {
|
||||
border-bottom: 1px solid #cc9;
|
||||
border-right: 1px solid #cc9;
|
||||
}
|
||||
|
||||
#topmodule {
|
||||
background-color: #ddd;
|
||||
border-top: 1px solid #fff;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#topmodule #issueid {
|
||||
border-right: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#login a:link, #login a:visited {
|
||||
color: white;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#banner a:active, #banner a:hover {
|
||||
color: #f90 !important;
|
||||
}
|
||||
|
||||
#toptabs td {
|
||||
border-bottom: 1px solid #666;
|
||||
border-right: 1px solid #333;
|
||||
border-left: 1px solid #036;
|
||||
}
|
||||
|
||||
#toptabs th {
|
||||
border-left: 1px solid #036;
|
||||
}
|
||||
|
||||
/* font and text properties, exclusive of link indication, alignment, text-indent */
|
||||
#bodycol h2 {
|
||||
font-family: Tahoma, Verdana, Helvetica, Arial, sans-serif;
|
||||
font-size: 1.5em;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* box properties (exclusive of borders), positioning, alignments, list types, text-indent */
|
||||
#toptabs {
|
||||
margin: 0;
|
||||
padding-top: .67em;
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
#topmodule {
|
||||
margin: -4px -4px 0 -4px;
|
||||
}
|
||||
|
||||
#topmodule td {
|
||||
vertical-align: middle;
|
||||
padding: 2px 8px;
|
||||
}
|
||||
|
||||
#navcolumn {
|
||||
margin-right: -4px;
|
||||
}
|
||||
|
||||
#mytools .body, #projecttools .body, #admintools .body, #communitytools .body {
|
||||
padding-top: .33em;
|
||||
}
|
||||
|
||||
#mytools, #projecttools, #admintools, #communitytools {
|
||||
padding: 0 6px 6px 6px;
|
||||
margin: -4px 0 6px -4px;
|
||||
}
|
||||
|
||||
#mytools .label, #projecttools .label, #admintools .label, #communitytools .label {
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* java.net dev stylesheet */
|
||||
|
||||
/* colors, backgrounds, borders, link indication */
|
||||
body {
|
||||
color: #333;
|
||||
}
|
||||
.app h3, .app h4, .functnbar {
|
||||
background-image: none;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
#toptabs td, #toptabs th {
|
||||
background-image: url(../images/nw_min.gif);
|
||||
}
|
||||
|
||||
|
||||
#navcolumn .body div, body.docs #toc li li {
|
||||
background-image: url(../images/strich.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: .5em .5em;
|
||||
}
|
||||
|
||||
#banner, #banner td, #toptabs {
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
}
|
||||
.app h3 {
|
||||
background-color: #594FBF;
|
||||
color: #fff;
|
||||
}
|
||||
#toptabs th {
|
||||
border-left: 1px solid #fff;
|
||||
}
|
||||
#toptabs td {
|
||||
border-right: 1px solid #333;
|
||||
border-left: 1px solid #fff;
|
||||
}
|
||||
#login, #banner {
|
||||
color: #333;
|
||||
}
|
||||
a:link, a:visited, #navcolumn a:visited, #navcolumn a:link,.app a:visited, .tasknav a:visited {
|
||||
color: #594FBF;
|
||||
}
|
||||
#mytools a:link, #banner a:link, #banner a:visited {
|
||||
border-bottom: none;
|
||||
}
|
||||
a:link.selfref, a:visited.selfref {
|
||||
color: #555 !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
#banner a:active, #banner a:hover {
|
||||
color: #f60 !important;
|
||||
}
|
||||
#login a:link, #login a:visited, #banner a:link, #banner a:visited {
|
||||
color: #594FBF !important;
|
||||
font-weight: bold;
|
||||
}
|
||||
#bannerbottom1 td, #bannerbottom2 td {
|
||||
background: #EFEFEF;
|
||||
}
|
||||
#bannerbottom1 th {
|
||||
background: #2E1772;
|
||||
}
|
||||
#bannerbottom2 th {
|
||||
background: #594FBF;
|
||||
}
|
||||
|
||||
|
||||
.grid td { border-top: 1px solid #ccc; border-left: 1px solid #ccc; }
|
||||
.grid { border-bottom: 1px solid #ccc; border-right: 1px solid #ccc; }
|
||||
|
||||
|
||||
|
||||
/* font and text properties, exclusive of link indication, alignment, text-indent */
|
||||
|
||||
#banner {
|
||||
font-size: xx-small;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
font-size: x-small
|
||||
}
|
||||
|
||||
/* box properties (exclusive of borders), positioning, alignments, list types, text-indent */
|
||||
|
||||
.app h3, .app h4 {
|
||||
padding: 3px;
|
||||
margin-right: 2px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
#rightcol div.www, #rightcol div.help {
|
||||
border: none;
|
||||
}
|
||||
#rightcol div.www h3 {
|
||||
background-color: #ddd;
|
||||
color: #000;
|
||||
}
|
||||
#rightcol div.www h3 {
|
||||
padding: 3px;
|
||||
}
|
||||
#bannerbottom1 th, #bannerbottom2 th {
|
||||
text-align: left;
|
||||
vertical-align: bottom;
|
||||
}
|
785
simplepool/simplepool-examples/includes/tigris.css
Normal file
785
simplepool/simplepool-examples/includes/tigris.css
Normal file
|
@ -0,0 +1,785 @@
|
|||
/* $Id: tigris.css,v 1.1.1.1 2004-03-28 00:16:01 ethauvin Exp $
|
||||
|
||||
This file defines basic default formatting for HTML conforming to Tigris application style. To extend or override these rules for your instance, edit inst.css instead of this file. */
|
||||
|
||||
/* colors, backgrounds, borders, link indication */
|
||||
body {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.app h3, .app h4, .tabs td, .tabs th, .functnbar {
|
||||
background-image: url(../images/nw_maj_rond.gif);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.functnbar, .functnbar2 {
|
||||
background-color: #aaa;
|
||||
}
|
||||
|
||||
.functnbar2, .functnbar3 {
|
||||
background-color: #aaa;
|
||||
background-image: url(../images/sw_maj_rond.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: bottom left;
|
||||
}
|
||||
|
||||
.functnbar3 {
|
||||
background-color: #ddd;
|
||||
background-image: url(../images/sw_med_rond.gif);
|
||||
}
|
||||
|
||||
.functnbar, .functnbar2, .functnbar3 {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.functnbar a, .functnbar2 a, .functnbar3 a {
|
||||
color: #000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#navcolumn .body div, body.docs #toc li li {
|
||||
background-image: url(../images/strich.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: .5em .5em;
|
||||
}
|
||||
|
||||
#searchbox .body div, #navcolumn .body .heading {
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
a:link, #navcolumn a:visited, .app a:visited, .tasknav a:visited {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a:link.selfref, a:visited.selfref {
|
||||
color: #555 !important;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:active, a:hover, #leftcol a:active, #leftcol a:hover {
|
||||
color: #f30 !important;
|
||||
}
|
||||
|
||||
#leftcol a, #breadcrumbs a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.app h3, .app h4 {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.app h3 {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.app h3 a:link, .app h3 a:visited, .app h4 a:link, .app h4 a:visited {
|
||||
color: #fff !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.app h4 {
|
||||
background-color: #888;
|
||||
}
|
||||
|
||||
.a td {
|
||||
background: #ddd;
|
||||
}
|
||||
|
||||
.b td {
|
||||
background: #efefef;
|
||||
}
|
||||
|
||||
table, th, td {
|
||||
border: none;
|
||||
}
|
||||
|
||||
div.colbar {
|
||||
background: #eee;
|
||||
border-color: #999 #EEE #EEE #999;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
}
|
||||
|
||||
.toolgroup {
|
||||
background: #efefef;
|
||||
}
|
||||
|
||||
.toolgroup .label {
|
||||
border-bottom: 1px solid #666;
|
||||
border-right: 1px solid #666;
|
||||
background: #ddd;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.toolgroup .body {
|
||||
border-right: 1px solid #aaa;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#breadcrumbs {
|
||||
border-top: 1px solid #fff;
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
#main {
|
||||
border-top: 1px solid #999;
|
||||
}
|
||||
|
||||
#rightcol div.www, #rightcol div.help {
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
body.docs div.docs {
|
||||
background-color: #fff;
|
||||
border-left: 1px solid #ddd;
|
||||
border-top: 1px solid #ddd;
|
||||
}
|
||||
|
||||
#helptext .label {
|
||||
background-image: url(../images/icon_help_sml.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 97%;
|
||||
}
|
||||
|
||||
body.docs {
|
||||
background: #eee url(../images/help_logo.gif) top right no-repeat !important;
|
||||
}
|
||||
|
||||
.docs h3, .docs h4 {
|
||||
border-top: solid 1px #000;
|
||||
}
|
||||
|
||||
#apphead h2 em {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.app th {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.tabs th {
|
||||
border-right: 1px solid #333;
|
||||
background-color: #ddd;
|
||||
color: #fff;
|
||||
border-left: 1px solid #fff;
|
||||
}
|
||||
|
||||
.tabs td {
|
||||
background-color: #999;
|
||||
border-bottom: 1px solid #fff;
|
||||
border-right: 1px solid #fff;
|
||||
border-left: 1px solid #fff;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
border-bottom: 6px #ddd solid;
|
||||
}
|
||||
|
||||
.tabs th, .tabs th a:link, .tabs th a:visited {
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.tabs td, .tabs td a:link, .tabs td a:visited {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tabs a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.axial th {
|
||||
background-color: #ddd;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.alert {
|
||||
background-color: #ff9;
|
||||
}
|
||||
|
||||
.expandedwaste {
|
||||
background: url(../images/icon_arrowwaste2_sml.gif) no-repeat;
|
||||
}
|
||||
|
||||
.collapsedwaste {
|
||||
background: url(../images/icon_arrowwaste1_sml.gif) no-repeat;
|
||||
}
|
||||
|
||||
.filebrowse .expanded, .filebrowse-alt .expanded {
|
||||
background-image: url(../images/icon_arrowfolderopen2_sml.gif);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.filebrowse .collapsed, .filebrowse-alt .collapsed {
|
||||
background-image: url(../images/icon_arrowfolderclosed1_sml.gif);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.filebrowse .leafnode, .filebrowse-alt .leafnode {
|
||||
background-image: url(../images/icon_folder_sml.gif);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.filebrowse .leaf, .filebrowse-alt .leaf {
|
||||
background-image: url(../images/icon_doc_sml.gif);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.sortup {
|
||||
background: url(../images/icon_sortup.gif) no-repeat;
|
||||
}
|
||||
|
||||
.sortdown {
|
||||
background: url(../images/icon_sortdown.gif) no-repeat;
|
||||
}
|
||||
|
||||
.collapsedwaste {
|
||||
background: url(../images/icon_arrowwaste1_sml.gif) no-repeat;
|
||||
}
|
||||
|
||||
body .grid td {
|
||||
border-top: 1px solid #ccc;
|
||||
border-left: 1px solid #ccc;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.confirm {
|
||||
color: #090;
|
||||
}
|
||||
|
||||
.info {
|
||||
color: #069;
|
||||
}
|
||||
|
||||
.errormessage, .warningmessage, .donemessage, .infomessage {
|
||||
border-top: 5px solid #900;
|
||||
border-left: 1px solid #900;
|
||||
background-image: url(../images/icon_error_lrg.gif);
|
||||
background-repeat: no-repeat;
|
||||
background-position: 5px 1.33em;
|
||||
}
|
||||
|
||||
.warningmessage {
|
||||
background-image: url(../images/icon_warning_lrg.gif);
|
||||
border-color: #c60;
|
||||
}
|
||||
|
||||
.donemessage {
|
||||
background-image: url(../images/icon_success_lrg.gif);
|
||||
border-color: #090;
|
||||
}
|
||||
|
||||
.infomessage {
|
||||
background-image: url(../images/icon_info_lrg.gif);
|
||||
border-color: #069;
|
||||
}
|
||||
|
||||
.docinfo {
|
||||
background: url(../images/icon_doc_lrg.gif) no-repeat;
|
||||
}
|
||||
|
||||
.dirinfo {
|
||||
background: url(../images/icon_folder_lrg.gif) no-repeat;
|
||||
}
|
||||
|
||||
.memberinfo {
|
||||
background: url(../images/icon_members_lrg.gif) no-repeat;
|
||||
}
|
||||
|
||||
.usergroupinfo {
|
||||
background: url(../images/icon_usergroups_lrg.gif) no-repeat;
|
||||
}
|
||||
|
||||
.errormark, .warningmark, .donemark, .infomark {
|
||||
background: url(../images/icon_error_sml.gif) no-repeat;
|
||||
}
|
||||
|
||||
.warningmark {
|
||||
background-image: url(../images/icon_warning_sml.gif);
|
||||
}
|
||||
|
||||
.donemark {
|
||||
background-image: url(../images/icon_success_sml.gif);
|
||||
}
|
||||
|
||||
.infomark {
|
||||
background-image: url(../images/icon_info_sml.gif);
|
||||
}
|
||||
|
||||
.cvsdiff, .cvsblame {
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.cvsdiffadd {
|
||||
background-color: #afa;
|
||||
}
|
||||
|
||||
.cvsdiffremove {
|
||||
background-color: #faa;
|
||||
}
|
||||
|
||||
.cvsdiffchanges1 {
|
||||
background-color: #ff7;
|
||||
}
|
||||
|
||||
.cvsdiffchanges2 {
|
||||
background-color: #ff7;
|
||||
}
|
||||
|
||||
li.selection ul a {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.band1 {
|
||||
color: #fff;
|
||||
background-color: #663;
|
||||
}
|
||||
|
||||
.band2 {
|
||||
color: #fff;
|
||||
background-color: #66C;
|
||||
}
|
||||
|
||||
.band3 {
|
||||
background-color: #C99;
|
||||
}
|
||||
|
||||
.band4 {
|
||||
background-color: #CFF;
|
||||
}
|
||||
|
||||
.band5 {
|
||||
color: #fff;
|
||||
background-color: #336;
|
||||
}
|
||||
|
||||
.band6 {
|
||||
color: #fff;
|
||||
background-color: #966;
|
||||
}
|
||||
|
||||
.band7 {
|
||||
background-color: #9CC;
|
||||
}
|
||||
|
||||
.band8 {
|
||||
background-color: #FFC;
|
||||
}
|
||||
|
||||
.band9 {
|
||||
color: #fff;
|
||||
background-color: #633;
|
||||
}
|
||||
|
||||
.band10 {
|
||||
color: #fff;
|
||||
background-color: #699;
|
||||
}
|
||||
|
||||
.band11 {
|
||||
background-color: #CC9;
|
||||
}
|
||||
|
||||
.band12 {
|
||||
background-color: #CCF;
|
||||
}
|
||||
|
||||
.band13 {
|
||||
color: #fff;
|
||||
background-color: #366;
|
||||
}
|
||||
|
||||
.band14 {
|
||||
color: #fff;
|
||||
background-color: #996;
|
||||
}
|
||||
|
||||
.band15 {
|
||||
background-color: #99C;
|
||||
}
|
||||
|
||||
.band16 {
|
||||
background-color: #FCC;
|
||||
}
|
||||
|
||||
.app .helplink, #helptext .helplink {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.legend th, .bars th {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
/* font and text properties, exclusive of link indication, alignment, text-indent */
|
||||
body, th, td, input, select {
|
||||
font-family: Verdana, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
code, pre {
|
||||
font-family: 'Andale Mono', Courier, monospace;
|
||||
}
|
||||
|
||||
body, .app h3, .app h4, #rightcol h3, pre, code, #apphead h2 small, h4, table {
|
||||
font-size: x-small;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
small, div#footer, div#footer table, div#login, div.tabs th, div.tabs td, input, select, .paginate, .functnbar, .functnbar2, .functnbar3, #breadcrumbs, .courtesylinks, #rightcol div.help, .colbar, .tasknav, body.docs div#toc, #leftcol, .legend, .bars {
|
||||
font-size: xx-small;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
font-size: x-small;
|
||||
}
|
||||
|
||||
.tabs td, .tabs th, dt, .tasknav .selfref, #login .username, .selection {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
li.selection ul {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#apphead h2 em {
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
#banner h1 {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
/* box properties (exclusive of borders), positioning, alignments, list types, text-indent */
|
||||
#bodycol h2 {
|
||||
margin-top: .3em;
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
p, ul, ol, dl, .bars table {
|
||||
margin-top: .67em;
|
||||
margin-bottom: .67em;
|
||||
}
|
||||
|
||||
h3, h4 {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
form {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#bodycol {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
width: 100%;
|
||||
voice-family: "\"}\"";
|
||||
voice-family: inherit;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
html>body #bodycol {
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.docs {
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
ol ol {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
|
||||
ol ol ol {
|
||||
list-style-type: lower-roman;
|
||||
}
|
||||
|
||||
.app h3, .app h4 {
|
||||
padding: 5px;
|
||||
margin-right: 2px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.app td, .app th {
|
||||
padding: 2px 3px;
|
||||
}
|
||||
|
||||
.h3 p, .h4 p, .h3 dt, .h4 dt {
|
||||
margin-right: 7px;
|
||||
margin-left: 7px;
|
||||
}
|
||||
|
||||
.tasknav {
|
||||
margin-bottom: 1.33em;
|
||||
}
|
||||
|
||||
div.colbar {
|
||||
padding: 3px;
|
||||
margin: 2px 2px 0;
|
||||
}
|
||||
|
||||
.tabs {
|
||||
margin-top: .67em;
|
||||
margin-right: 2px;
|
||||
margin-left: 2px;
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
.tabs td, .tabs th {
|
||||
padding: 3px 9px;
|
||||
}
|
||||
|
||||
#rightcol div.www, #rightcol div.help {
|
||||
padding: 0 .5em;
|
||||
}
|
||||
|
||||
body.docs #toc {
|
||||
position: absolute;
|
||||
top: 15px;
|
||||
left: 0px;
|
||||
width: 120px;
|
||||
padding: 0 20px 0 0;
|
||||
}
|
||||
|
||||
body.docs #toc ul, #toc ol {
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
body.docs #toc li {
|
||||
margin-top: 7px;
|
||||
padding-left: 10px;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
body.docs div.docs {
|
||||
margin: 61px 0 0 150px;
|
||||
padding: 1em 2em 1em 1em !important;
|
||||
}
|
||||
|
||||
.docs p+p {
|
||||
text-indent: 5%;
|
||||
margin-top: -.67em;
|
||||
}
|
||||
|
||||
.docs h3, .docs h4 {
|
||||
margin-bottom: .1em;
|
||||
padding-top: .3em;
|
||||
}
|
||||
|
||||
.functnbar, .functnbar2, .functnbar3 {
|
||||
padding: 5px;
|
||||
margin: .67em 2px;
|
||||
}
|
||||
|
||||
.functnbar3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
body.composite, body.docs {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
th, td {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.bars th {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.right {
|
||||
text-align: right !important;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
.axial th, .axial th .strut {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.app .axial td th {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
body .stb {
|
||||
margin-top: 1em;
|
||||
text-indent: 0;
|
||||
}
|
||||
|
||||
body .mtb {
|
||||
margin-top: 2em;
|
||||
text-indent: 0;
|
||||
}
|
||||
|
||||
.courtesylinks {
|
||||
margin-top: 1em;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-bottom: .67em;
|
||||
}
|
||||
|
||||
.toolgroup {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.toolgroup .body {
|
||||
padding: 4px 4px 4px 0;
|
||||
}
|
||||
|
||||
.toolgroup .label {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.toolgroup .body div {
|
||||
padding-bottom: .3em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.toolgroup .body div div {
|
||||
margin-top: .3em;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.tier1 {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.tier2 {
|
||||
margin-left: 1.5em;
|
||||
}
|
||||
|
||||
.tier3 {
|
||||
margin-left: 3em;
|
||||
}
|
||||
|
||||
.tier4 {
|
||||
margin-left: 4.5em;
|
||||
}
|
||||
|
||||
.tier5 {
|
||||
margin-left: 6em;
|
||||
}
|
||||
|
||||
.tier6 {
|
||||
margin-left: 7.5em;
|
||||
}
|
||||
|
||||
.tier7 {
|
||||
margin-left: 9em;
|
||||
}
|
||||
|
||||
.tier8 {
|
||||
margin-left: 10.5em;
|
||||
}
|
||||
|
||||
.tier9 {
|
||||
margin-left: 12em;
|
||||
}
|
||||
|
||||
.tier10 {
|
||||
margin-left: 13.5em;
|
||||
}
|
||||
|
||||
.filebrowse .expanded, .filebrowse .collapsed {
|
||||
padding-left: 34px;
|
||||
}
|
||||
|
||||
.filebrowse .leafnode, .filebrowse .leaf {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.messagechild {
|
||||
padding-left: 34px;
|
||||
}
|
||||
|
||||
.filebrowse-alt .expanded, .filebrowse-alt .collapsed, .filebrowse-alt .leaf, .filebrowse-alt .leafnode, .expandedwaste, .collapsedwaste, .sortup, .sortdown {
|
||||
/* hide from macie5\*/
|
||||
float: left;
|
||||
/* resume */
|
||||
display: inline-block;
|
||||
height: 15px;
|
||||
width: 34px;
|
||||
padding-left: 0 !important;
|
||||
}
|
||||
|
||||
.filebrowse-alt .leaf, .filebrowse-alt .leafnode, .sortup, .sortdown {
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.filebrowse ul, .filebrowse-alt ul {
|
||||
list-style-type: none;
|
||||
padding-left: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.filebrowse ul ul, .filebrowse-alt ul ul {
|
||||
margin-left: 1.5em;
|
||||
margin-top: 0;
|
||||
padding-top: .67em;
|
||||
}
|
||||
|
||||
.filebrowse li, .filebrowse-alt li {
|
||||
margin-bottom: .67em;
|
||||
}
|
||||
|
||||
td.filebrowse h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.errormessage, .warningmessage, .donemessage, .infomessage, .docinfo, .dirinfo, .memberinfo, .usergroupinfo {
|
||||
margin: .67em 0;
|
||||
padding: .33em 0 .67em 42px;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.errormark, .warningmark, .donemark, .infomark {
|
||||
padding-left: 20px;
|
||||
min-height: 15px;
|
||||
}
|
||||
|
||||
.alt {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#banner h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#leftcol, #leftcol .strut {
|
||||
width: 14em;
|
||||
}
|
||||
|
||||
.axial th, .axial th .strut {
|
||||
width: 12em;
|
||||
}
|
||||
|
||||
#breadcrumbs {
|
||||
padding: 2px 8px;
|
||||
}
|
||||
|
||||
.app h3, .app h4 {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.legend {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.legend th, .bars th {
|
||||
text-align: right;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
#projectdocumentlist td.filebrowse-alt {
|
||||
padding-right: .75em;
|
||||
}
|
54
simplepool/simplepool-examples/index.html
Normal file
54
simplepool/simplepool-examples/index.html
Normal file
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "includes/tigris.css";
|
||||
@import "includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="https://simplepool.dev.java.net/">Project Home</a></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool for webapps using JSTL.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="jndi/index.jsp">JNDI DataSource Examples</a> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="servlet/index.jsp">Servlet DataSource Examples</a> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="longdescription">
|
||||
<h3>Description</h3>
|
||||
<p>SimplePool is a simple database connection pool implementation for web applications, specifically those using <a href="http://java.sun.com/products/jsp/jstl/">JSTL</a>.</p>
|
||||
<p>The connection pool can be created, accessed and managed via <a href="jndi">JNDI</a> or a provided <a href="servlet/">Servlet</a>.</p>
|
||||
<p>The examples above have been tailored for use with <a href="http://jakarta.apache.org/tomcat/">Tomcat</a> and <a href="http://www.mysql.com/">MySQL</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
84
simplepool/simplepool-examples/jndi/index.jsp
Normal file
84
simplepool/simplepool-examples/jndi/index.jsp
Normal file
|
@ -0,0 +1,84 @@
|
|||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<%@page import="javax.naming.*" %>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "../includes/tigris.css";
|
||||
@import "../includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: JNDI DataSource Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<script language="javascript" type="text/javascript">
|
||||
<%
|
||||
boolean enabled = false;
|
||||
|
||||
try {
|
||||
enabled = (new InitialContext().lookup("java:comp/env/jdbc/JNDIPoolDS") != null);
|
||||
} catch (Exception ignore) { }
|
||||
%>
|
||||
function RTFM()
|
||||
{
|
||||
alert("Please read the instructions to enable this example.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
JNDI DataSource Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="../index.html">Examples Home</a></p>
|
||||
<p><strong>Please read the instructions before trying to run the examples.</strong></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool example using JDNI.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="<% if (enabled) { %>scriptlet.jsp<% } else { %>javascript:RTFM()<% } %>">Scriptlet Example</a> [<a href="../source.jsp?file=jndi/scriptlet.jsp">source</a>]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="<% if (enabled) { %>jstl.jsp<% } else { %>javascript:RTFM()<% } %>">JSTL Example</a> [<a href="../source.jsp?file=jndi/jstl.jsp">source</a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="instructions">
|
||||
<h3>Instructions</h3>
|
||||
<p>JNDI is used to create, access and manage the connection pool.</p>
|
||||
<p class="alert">First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.</p>
|
||||
<p class="alert">The JNDI DataSource is defined as naming resource in the current webapp context, as shown in this minimal <a href="../source.jsp?file=conf/server.xml">server configuration file</a>. </p>
|
||||
<p>The JNDI DataSource is configured using the following parameters:</p>
|
||||
<ul>
|
||||
<li>The <span class="info">varName</span> parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.</li>
|
||||
<li>The <span class="info">driver</span> parameter is used to specify the name of the JDBC driver class to be registered. For <code>example: com.mysql.jdbc.Driver</code>.</li>
|
||||
<li>The <span class="info">user</span> parameter is used to specify the database username, if any.</li>
|
||||
<li>The <span class="info">password</span> parameter is used to specify the database password, if any.</li>
|
||||
<li>The <span class="info">jdbcUrl</span> parameter is used to specify the JDBC URL associated with the database. For example: <code>jdbc:mysql://localhost:3306/dbname</code>.</li>
|
||||
<li>The <span class="info">minConns</span> parameter is used to specify the minimum number of connections to start the pool with.</li>
|
||||
<li>The <span class="info">maxConns</span> parameter is used to specify the maximum number of connections to be dynamically created in the pool.</li>
|
||||
<li>The <span class="info">maxConnTime</span> parameter is used to specify the time (in days) between connection resets. The pool manager will perform a basic cleanup at the specified interval.</li>
|
||||
<li>The <span class="info">maxCheckoutSeconds</span> parameter is used to specify the maximum time a connection can be checked out before being recycled. A zero value turns this option off.</li>
|
||||
</ul>
|
||||
<p>Please note that <em>all parameters are required</em>.</p>
|
||||
<p class="alert">Please take a minute to incorporate the <a href="../source.jsp?file=conf/server.xml">JDNI DataSource example</a> in your <code>$CATALINE_HOME/conf/server.xml</code>. Once done, please restart Tomcat. The examples will be functional upon restart.</p>
|
||||
<p>Please look at the [source] of the provided examples to understand how to access the connection pool from a scriptlet or using the JSTL SQL tags. The examples demonstrates how to list all of the tables contained in the specified database.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
27
simplepool/simplepool-examples/jndi/jstl.jsp
Normal file
27
simplepool/simplepool-examples/jndi/jstl.jsp
Normal file
|
@ -0,0 +1,27 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool JNDI/JSTL Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%-- Execute the query using our JNDI DataSource --%>
|
||||
<sql:query var="rs" dataSource="jdbc/JNDIPoolDS">
|
||||
SHOW TABLES
|
||||
</sql:query>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
|
||||
<%--
|
||||
Loop through the result set and
|
||||
display the current column value
|
||||
--%>
|
||||
<c:forEach var="row" items="${rs.rowsByIndex}">
|
||||
<li><c:out value="${row[0]}"/></li>
|
||||
</c:forEach>
|
||||
|
||||
<ul>
|
||||
</body>
|
||||
</html>
|
45
simplepool/simplepool-examples/jndi/scriptlet.jsp
Normal file
45
simplepool/simplepool-examples/jndi/scriptlet.jsp
Normal file
|
@ -0,0 +1,45 @@
|
|||
<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool JNDI Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%
|
||||
// Get a new initial JNDI context
|
||||
Context ctx = new InitialContext();
|
||||
|
||||
// Get a reference to our JNDI DataSource
|
||||
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/JNDIPoolDS");
|
||||
|
||||
// Get a connection from the pool
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
// Create a new statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Execute the query
|
||||
ResultSet rst = stmt.executeQuery("SHOW TABLES");
|
||||
%>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
<%
|
||||
// Loop through the result set and
|
||||
// display the current column value
|
||||
while (rst.next()) {
|
||||
%>
|
||||
<li><%= rst.getString(1) %></li>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<ul>
|
||||
|
||||
<%
|
||||
// Close the result set, statement and connection
|
||||
rst.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
%>
|
||||
</body>
|
||||
</html>
|
56
simplepool/simplepool-examples/licenses/JSTL License.txt
Normal file
56
simplepool/simplepool-examples/licenses/JSTL License.txt
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* ========================================================================= *
|
||||
* *
|
||||
* The Apache Software License, Version 1.1 *
|
||||
* *
|
||||
* Copyright (c) 1999, 2000 The Apache Software Foundation. *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* ========================================================================= *
|
||||
* *
|
||||
* Redistribution and use in source and binary forms, with or without modi- *
|
||||
* fication, are permitted provided that the following conditions are met: *
|
||||
* *
|
||||
* 1. Redistributions of source code must retain the above copyright notice, *
|
||||
* this list of conditions and the following disclaimer. *
|
||||
* *
|
||||
* 2. Redistributions in binary form must reproduce the above copyright *
|
||||
* notice, this list of conditions and the following disclaimer in the *
|
||||
* documentation and/or other materials provided with the distribution. *
|
||||
* *
|
||||
* 3. The end-user documentation included with the redistribution, if any, *
|
||||
* must include the following acknowlegement: *
|
||||
* *
|
||||
* "This product includes software developed by the Apache Software *
|
||||
* Foundation <http://www.apache.org/>." *
|
||||
* *
|
||||
* Alternately, this acknowlegement may appear in the software itself, if *
|
||||
* and wherever such third-party acknowlegements normally appear. *
|
||||
* *
|
||||
* 4. The names "The Jakarta Project", "Tomcat", and "Apache Software *
|
||||
* Foundation" must not be used to endorse or promote products derived *
|
||||
* from this software without prior written permission. For written *
|
||||
* permission, please contact <apache@apache.org>. *
|
||||
* *
|
||||
* 5. Products derived from this software may not be called "Apache" nor may *
|
||||
* "Apache" appear in their names without prior written permission of the *
|
||||
* Apache Software Foundation. *
|
||||
* *
|
||||
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES *
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY *
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
|
||||
* THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY *
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS *
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) *
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, *
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN *
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
|
||||
* POSSIBILITY OF SUCH DAMAGE. *
|
||||
* *
|
||||
* ========================================================================= *
|
||||
* *
|
||||
* This software consists of voluntary contributions made by many indivi- *
|
||||
* duals on behalf of the Apache Software Foundation. For more information *
|
||||
* on the Apache Software Foundation, please see <http://www.apache.org/>. *
|
||||
* *
|
||||
* ========================================================================= */
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/simplepool/simplepool-examples/licenses/SimplePool License.txt,v $
|
||||
* $Revision: 1.1.1.1 $
|
||||
* $Date: 2004-03-28 00:16:01 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
77
simplepool/simplepool-examples/servlet/index.jsp
Normal file
77
simplepool/simplepool-examples/servlet/index.jsp
Normal file
|
@ -0,0 +1,77 @@
|
|||
<!DOCTYPE html PUBLIC "-//Tigris//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://style.tigris.org/tigris_transitional.dtd">
|
||||
<%@page import="javax.naming.*" %>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
/* <![CDATA[ */
|
||||
@import "../includes/tigris.css";
|
||||
@import "../includes/inst.css";
|
||||
/* ]]> */
|
||||
</style>
|
||||
<title>simplepool: Servlet DataSource Examples</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
|
||||
<meta http-equiv="Content-Style-Type" content="text/css" />
|
||||
<script language="javascript" type="text/javascript">
|
||||
<% boolean enabled = (pageContext.findAttribute("ServletPoolDS") != null); %>
|
||||
function RTFM()
|
||||
{
|
||||
alert("Please read the instructions to enable this example.");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body marginwidth="0" marginheight="0" class="composite">
|
||||
<table border="0" cellspacing="0" cellpadding="4" width="100%" id="main">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="bodycol">
|
||||
<div id="apphead">
|
||||
<h2><small>simplepool</small><br />
|
||||
Servlet DataSource Examples</h2>
|
||||
</div>
|
||||
<p class="tasknav"><a href="../index.html">Examples Home</a></p>
|
||||
<p><strong>Please read the instructions before trying to run the examples.</strong></p>
|
||||
<div id="examples" class="app">
|
||||
<div class="axial">
|
||||
<table border="0" cellspacing="2" cellpadding="3">
|
||||
<tr>
|
||||
<th>Summary</th>
|
||||
<td>A simple database connection pool example using the SimplePool Servlet.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 1</th>
|
||||
<td><a href="<% if (enabled) { %>scriptlet.jsp<% } else { %>javascript:RTFM()<% } %>">Scriptlet Example</a> [<a href="../source.jsp?file=servlet/scriptlet.jsp">source</a>]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Example 2</th>
|
||||
<td><a href="<% if (enabled) { %>jstl.jsp<% } else { %>javascript:RTFM()<% } %>">JSTL Example</a> [<a href="../source.jsp?file=servlet/jstl.jsp">source</a>]</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="h3" id="instructions">
|
||||
<h3>Instructions</h3>
|
||||
<p>The SimplePoolServlet is used to create, access and manage the connection pool.</p>
|
||||
<p class="alert">First, make sure that your JDBC driver is available, by placing its components in this webapp's WEB-INF/lib/ directory.</p>
|
||||
<p>The SimplePoolServlet is configured using a set of required initialization parameters, as show in this webapp's <code><a href="../source.jsp?file=WEB-INF/web.xml">WEB-INF/web.xml</a></code> under the <code><servlet/></code> section:</p>
|
||||
<ul>
|
||||
<li>The <code class="info">varName</code> initialization parameter is used to specify the name of the variable which will hold a reference to the DataSource object created by the Servlet.</li>
|
||||
<li>The <code class="info">driver</code> initialization parameter is used to specify the name of the JDBC driver class to be registered. For <code>example: com.mysql.jdbc.Driver</code>.</li>
|
||||
<li>The <span class="info">user</span> initialization parameter is used to specify the database username, if any.</li>
|
||||
<li>The <code class="info">password</code> initialization parameter is used to specify the database password, if any.</li>
|
||||
<li>The <code class="info">jdbcUrl</code> initialization parameter is used to specify the JDBC URL associated with the database. For example: <code>jdbc:mysql://localhost:3306/dbname</code>.</li>
|
||||
<li>The <code class="info">minConns</code> initialization parameter is used to specify the minimum number of connections to start the pool with.</li>
|
||||
<li>The <code class="info">maxConns</code> initialization parameter is used to specify the maximum number of connections to be dynamically created in the pool.</li>
|
||||
<li>The <code class="info">maxConnTime</code> initialization parameter is used to specify the time (in days) between connection resets. The pool manager will perform a basic cleanup at the specified interval.</li>
|
||||
<li>The <code class="info">maxCheckoutSeconds</code> initialization parameter is used to specify the maximum time a connection can be checked out before being recycled. A zero value turns this option off.</li>
|
||||
</ul>
|
||||
<p>Please note that <em>all parameters are required</em>.</p>
|
||||
<p class="alert">Please take a minute to uncomment the <code><servlet/></code> declaration and configure the Servlet's initialization parameters in this webapp's <code><a href="../source.jsp?file=WEB-INF/web.xml">WEB-INF/web.xml</a></code>. Once done, please restart the webapp and/or Tomcat. The examples will be functional upon restart.</p>
|
||||
<p>Please look at the [source] of the provided examples to understand how to access the connection pool from a scriptlet or using the JSTL SQL tags. The examples demonstrates how to list all of the tables contained in the specified database.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
27
simplepool/simplepool-examples/servlet/jstl.jsp
Normal file
27
simplepool/simplepool-examples/servlet/jstl.jsp
Normal file
|
@ -0,0 +1,27 @@
|
|||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
|
||||
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool Servlet/JSTL Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%-- Execute the query using our DataSource --%>
|
||||
<sql:query var="rs" dataSource="${ServletPoolDS}">
|
||||
SHOW TABLES
|
||||
</sql:query>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
|
||||
<%--
|
||||
Loop through the result set and
|
||||
display the current column value
|
||||
--%>
|
||||
<c:forEach var="row" items="${rs.rowsByIndex}">
|
||||
<li><c:out value="${row[0]}"/></li>
|
||||
</c:forEach>
|
||||
|
||||
<ul>
|
||||
</body>
|
||||
</html>
|
44
simplepool/simplepool-examples/servlet/scriptlet.jsp
Normal file
44
simplepool/simplepool-examples/servlet/scriptlet.jsp
Normal file
|
@ -0,0 +1,44 @@
|
|||
<%@page import="javax.naming.*, javax.sql.*, java.sql.*;" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool Servlet Example</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%
|
||||
// Get a reference to our DataSource
|
||||
DataSource ds = (DataSource) pageContext.findAttribute("ServletPoolDS");
|
||||
|
||||
// Get a connection from the pool
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
// Create a new statement
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
// Execute the query
|
||||
ResultSet rst = stmt.executeQuery("SHOW TABLES");
|
||||
%>
|
||||
|
||||
<h3>Tables</h3>
|
||||
<ul>
|
||||
<%
|
||||
// Loop through the result set and
|
||||
// display the current column value
|
||||
while (rst.next()) {
|
||||
%>
|
||||
<li><%= rst.getString(1) %></li>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
<ul>
|
||||
|
||||
<%
|
||||
// Close the result set, statement and connection
|
||||
// and display the current column value
|
||||
rst.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
%>
|
||||
</body>
|
||||
</html>
|
||||
|
25
simplepool/simplepool-examples/source.jsp
Normal file
25
simplepool/simplepool-examples/source.jsp
Normal file
|
@ -0,0 +1,25 @@
|
|||
<%@page import="java.io.*"%>
|
||||
<html>
|
||||
<body>
|
||||
<pre>
|
||||
<%
|
||||
String file = request.getParameter("file");
|
||||
if ((file != null) && (file.trim().length() > 0) && (file.indexOf( ".." ) == -1)) {
|
||||
InputStream is = pageContext.getServletContext().getResourceAsStream(file);
|
||||
if (is != null) {
|
||||
InputStreamReader isr = new InputStreamReader(is);
|
||||
for (int ch = isr.read(); ch != -1; ch = isr.read()) {
|
||||
if (ch == '<') {
|
||||
out.print("<");
|
||||
} else if (ch == '\t') {
|
||||
out.print(" ");
|
||||
} else {
|
||||
out.print((char) ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
571
simplepool/src/net/java/dev/simplepool/SimplePool.java
Normal file
571
simplepool/src/net/java/dev/simplepool/SimplePool.java
Normal file
|
@ -0,0 +1,571 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/simplepool/src/net/java/dev/simplepool/SimplePool.java,v $
|
||||
* $Revision: 1.1.1.1 $
|
||||
* $Date: 2004-03-28 00:16:23 $
|
||||
*
|
||||
* Copyright (c) 2002, Marc A. Mnich (http://www.javaexchange.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License, please see:
|
||||
*
|
||||
* http://www.javaexchange.com/GPL.html
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Creates and manages a pool of database connections.
|
||||
*
|
||||
* @author <a href="http://www.javaexchange.com/">Marc A. Mnich</a>
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1.1.1 $, $Date: 2004-03-28 00:16:23 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePool implements Runnable {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SimplePool.class);
|
||||
|
||||
private Thread runner;
|
||||
|
||||
private Connection[] connPool;
|
||||
private int[] connStatus;
|
||||
|
||||
private long[] connLockTime;
|
||||
private long[] connCreateDate;
|
||||
private String[] connID;
|
||||
private String driver;
|
||||
private String jdbcUrl;
|
||||
private String user;
|
||||
private String password;
|
||||
private int currConnections;
|
||||
private int connLast;
|
||||
private int maxConns;
|
||||
private int maxConnMSec;
|
||||
private int maxCheckoutSeconds = 60;
|
||||
//available: set to false on destroy, checked by getConnection()
|
||||
private boolean available = true;
|
||||
|
||||
private SQLWarning currSQLWarning;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new Connection Pool.
|
||||
*
|
||||
* @param driver JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'
|
||||
* @param jdbcUrl JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'
|
||||
* @param user Database login name. e.g. 'Scott'
|
||||
* @param password Database password. e.g. 'Tiger'
|
||||
* @param minConns Minimum number of connections to start with.
|
||||
* @param maxConns Maximum number of connections in dynamic pool.
|
||||
* @param maxConnTime Time in days between connection resets. (Reset does a basic cleanup)
|
||||
* @param maxCheckoutSeconds Max time a connection can be checked out before being recycled. Zero value turns option
|
||||
* off, default is 60 seconds.
|
||||
*
|
||||
* @throws IOException If the pool cannot be created.
|
||||
*/
|
||||
public SimplePool(String driver, String jdbcUrl, String user, String password, int minConns, int maxConns,
|
||||
double maxConnTime, int maxCheckoutSeconds)
|
||||
throws IOException {
|
||||
|
||||
this.connPool = new Connection[maxConns];
|
||||
this.connStatus = new int[maxConns];
|
||||
this.connLockTime = new long[maxConns];
|
||||
this.connCreateDate = new long[maxConns];
|
||||
this.connID = new String[maxConns];
|
||||
this.currConnections = minConns;
|
||||
this.maxConns = maxConns;
|
||||
this.driver = driver;
|
||||
this.jdbcUrl = jdbcUrl;
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.maxCheckoutSeconds = maxCheckoutSeconds;
|
||||
this.maxConnMSec = (int) (maxConnTime * 86400000.0); //86400 sec/day
|
||||
if (this.maxConnMSec < 30000) { // Recycle no less than 30 seconds.
|
||||
this.maxConnMSec = 30000;
|
||||
}
|
||||
|
||||
log.info("-----------------------------------------");
|
||||
log.info("Starting Connection Pool:");
|
||||
log.info("driver = " + driver);
|
||||
log.info("jdbcUrl = " + jdbcUrl);
|
||||
log.info("user = " + user);
|
||||
log.info("minconnections = " + minConns);
|
||||
log.info("maxconnections = " + maxConns);
|
||||
log.info("Total refresh interval = " + maxConnTime + " days");
|
||||
log.info("maxCheckoutSeconds = " + maxCheckoutSeconds);
|
||||
log.info("-----------------------------------------");
|
||||
|
||||
|
||||
// Initialize the pool of connections with the mininum connections:
|
||||
// Problems creating connections may be caused during reboot when the
|
||||
// servlet is started before the database is ready. Handle this
|
||||
// by waiting and trying again. The loop allows 5 minutes for
|
||||
// db reboot.
|
||||
boolean connectionsSucceeded = false;
|
||||
int dbLoop = 20;
|
||||
|
||||
try {
|
||||
for (int i = 1; i < dbLoop; i++) {
|
||||
try {
|
||||
for (int j = 0; j < currConnections; j++) {
|
||||
createConn(j);
|
||||
}
|
||||
connectionsSucceeded = true;
|
||||
break;
|
||||
} catch (SQLException e) {
|
||||
|
||||
log.error("Attempt (" + String.valueOf(i) + " of " + String.valueOf(dbLoop) +
|
||||
") failed to create new connections set at startup.", e);
|
||||
log.warn("Will try again in 15 seconds...");
|
||||
|
||||
try {
|
||||
Thread.sleep(15000L);
|
||||
} catch (InterruptedException ignore) {
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!connectionsSucceeded) { // All attempts at connecting to db exhausted
|
||||
throw new IOException("All attempts at connecting to Database exhausted.");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.fatal(e.getMessage(), e);
|
||||
throw new IOException(e.getMessage());
|
||||
}
|
||||
|
||||
// Fire up the background housekeeping thread
|
||||
runner = new Thread(this);
|
||||
runner.start();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Housekeeping thread. Runs in the background with low CPU overhead. Connections are checked for warnings and
|
||||
* closure and are periodically restarted.
|
||||
* <p/>
|
||||
* This thread is a catchall for corrupted connections and prevents the buildup of open cursors. (Open cursors
|
||||
* result when the application fails to close a Statement).
|
||||
* <p/>
|
||||
* This method acts as fault tolerance for bad connection/statement programming.
|
||||
*/
|
||||
public void run() {
|
||||
boolean forever = true;
|
||||
Statement stmt = null;
|
||||
long maxCheckoutMillis = (long) (maxCheckoutSeconds * 1000);
|
||||
|
||||
while (forever) {
|
||||
|
||||
// Get any Warnings on connections and print to event file
|
||||
for (int i = 0; i < currConnections; i++) {
|
||||
try {
|
||||
currSQLWarning = connPool[i].getWarnings();
|
||||
if (currSQLWarning != null) {
|
||||
|
||||
log.debug("Warnings on connection [" + String.valueOf(i) + "]: " + currSQLWarning);
|
||||
|
||||
connPool[i].clearWarnings();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
log.debug("Cannot access connection [" + String.valueOf(i) + "] warnings.", e);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < currConnections; i++) { // Do for each connection
|
||||
|
||||
long age = System.currentTimeMillis() - connCreateDate[i];
|
||||
|
||||
try { // Test the connection with createStatement call
|
||||
synchronized (connStatus) {
|
||||
if (connStatus[i] > 0) { // In use, catch it next time!
|
||||
|
||||
// Check the time it's been checked out and recycle
|
||||
long timeInUse = System.currentTimeMillis() - connLockTime[i];
|
||||
log.warn("Connection [" + i + "] in use for " + timeInUse + " ms.");
|
||||
if (maxCheckoutMillis != 0) {
|
||||
if (timeInUse > maxCheckoutMillis) {
|
||||
log.warn("Connection [" + i + "] failed to be returned in time. Recycling...");
|
||||
throw new SQLException();
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
connStatus[i] = 2; // Take offline (2 indicates housekeeping lock)
|
||||
}
|
||||
|
||||
|
||||
if (age > maxConnMSec) { // Force a reset at the max conn time
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
stmt = connPool[i].createStatement();
|
||||
connStatus[i] = 0; // Connection is O.K.
|
||||
log.trace("Connection [" + String.valueOf(i) + "] confirmed.");
|
||||
|
||||
// Some DBs return an object even if DB is shut down
|
||||
if (connPool[i].isClosed()) {
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
|
||||
// Connection has a problem, restart it
|
||||
} catch (SQLException e) {
|
||||
|
||||
log.debug("Recycling connection [" + String.valueOf(i) + ']');
|
||||
try {
|
||||
connPool[i].close();
|
||||
} catch (SQLException e0) {
|
||||
log.warn("Can't close connection [" + String.valueOf(i) +
|
||||
"]. Might have been closed already. Trying to recycle anyway...", e);
|
||||
}
|
||||
|
||||
try {
|
||||
createConn(i);
|
||||
} catch (SQLException e1) {
|
||||
log.warn("Failed to create connection [" + String.valueOf(i) + ']', e1);
|
||||
|
||||
connStatus[i] = 0; // Can't open, try again next time
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (stmt != null) {
|
||||
stmt.close();
|
||||
}
|
||||
} catch (SQLException ignore) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(20000L);
|
||||
} // Wait 20 seconds for next cycle
|
||||
catch (InterruptedException e) {
|
||||
// Returning from the run method sets the internal
|
||||
// flag referenced by Thread.isAlive() to false.
|
||||
// This is required because we don't use stop() to
|
||||
// shutdown this thread.
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // End run
|
||||
|
||||
/**
|
||||
* This method hands out the connections in round-robin order. This prevents a faulty connection from locking up an
|
||||
* application entirely. A browser 'refresh' will get the next connection while the faulty connection is cleaned up
|
||||
* by the housekeeping thread.
|
||||
* <p/>
|
||||
* If the min number of threads are ever exhausted, new threads are added up the the max thread count. Finally, if
|
||||
* all threads are in use, this method waits 2 seconds and tries again, up to ten times. After that, it returns a
|
||||
* null.
|
||||
*
|
||||
* @return A connection from the pool.
|
||||
*/
|
||||
public Connection getConnection() {
|
||||
|
||||
Connection conn = null;
|
||||
|
||||
if (available) {
|
||||
boolean gotOne = false;
|
||||
|
||||
for (int outerloop = 1; outerloop <= 10; outerloop++) {
|
||||
|
||||
try {
|
||||
int loop = 0;
|
||||
int roundRobin = connLast + 1;
|
||||
if (roundRobin >= currConnections) {
|
||||
roundRobin = 0;
|
||||
}
|
||||
|
||||
do {
|
||||
synchronized (connStatus) {
|
||||
if ((connStatus[roundRobin] < 1) && (!connPool[roundRobin].isClosed())) {
|
||||
conn = connPool[roundRobin];
|
||||
connStatus[roundRobin] = 1;
|
||||
connLockTime[roundRobin] = System.currentTimeMillis();
|
||||
connLast = roundRobin;
|
||||
gotOne = true;
|
||||
break;
|
||||
} else {
|
||||
loop++;
|
||||
roundRobin++;
|
||||
if (roundRobin >= currConnections) {
|
||||
roundRobin = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while ((!gotOne) && (loop < currConnections));
|
||||
|
||||
} catch (SQLException e1) {
|
||||
log.debug(e1.getMessage(), e1);
|
||||
}
|
||||
|
||||
if (gotOne) {
|
||||
break;
|
||||
} else {
|
||||
synchronized (this) { // Add new connections to the pool
|
||||
if (currConnections < maxConns) {
|
||||
try {
|
||||
createConn(currConnections);
|
||||
currConnections++;
|
||||
} catch (SQLException e) {
|
||||
log.error("Unable to create new connection.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(2000L);
|
||||
} catch (InterruptedException ignore) {
|
||||
;
|
||||
}
|
||||
|
||||
log.debug("Connections Exhausted. Will wait and try again in loop " + String.valueOf(outerloop));
|
||||
}
|
||||
|
||||
} // End of try 10 times loop
|
||||
|
||||
} else {
|
||||
log.debug("Unsuccessful getConnection() request during destroy()");
|
||||
} // End if(available)
|
||||
|
||||
log.debug("Handing out connection [" + idOfConnection(conn) + "]: " +
|
||||
(new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a")).format(new Date()));
|
||||
|
||||
return conn;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the local JDBC ID for a connection.
|
||||
*
|
||||
* @param conn The connection object.
|
||||
*
|
||||
* @return The local JDBC ID for the connection.
|
||||
*/
|
||||
public int idOfConnection(Connection conn) {
|
||||
int match = -1;
|
||||
String tag;
|
||||
|
||||
try {
|
||||
tag = conn.toString();
|
||||
} catch (NullPointerException e1) {
|
||||
tag = "none";
|
||||
}
|
||||
|
||||
for (int i = 0; i < currConnections; i++) {
|
||||
if (connID[i].equals(tag)) {
|
||||
match = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return match;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees a connection. Replaces connection back into the main pool for reuse.
|
||||
*
|
||||
* @param conn The connection object.
|
||||
*
|
||||
* @return A status or empty string.
|
||||
*/
|
||||
public String freeConnection(Connection conn) {
|
||||
String res = "";
|
||||
|
||||
int thisconn = idOfConnection(conn);
|
||||
if (thisconn >= 0) {
|
||||
connStatus[thisconn] = 0;
|
||||
res = "freed " + conn.toString();
|
||||
log.debug("Freed connection [" + String.valueOf(thisconn) + ']');
|
||||
} else {
|
||||
log.error("Could not free connection [" + String.valueOf(thisconn) + ']');
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the age of a connection -- the time since it was handed out to an application.
|
||||
*
|
||||
* @param conn The connection object.
|
||||
*
|
||||
* @return The age of the connection.
|
||||
*/
|
||||
public long getAge(Connection conn) { // Returns the age of the connection in millisec.
|
||||
int thisconn = idOfConnection(conn);
|
||||
return System.currentTimeMillis() - connLockTime[thisconn];
|
||||
}
|
||||
|
||||
private void createConn(int i)
|
||||
throws SQLException {
|
||||
|
||||
Date now = new Date();
|
||||
|
||||
try {
|
||||
Class.forName(driver);
|
||||
|
||||
connPool[i] = DriverManager.getConnection
|
||||
(jdbcUrl, user, password);
|
||||
|
||||
connStatus[i] = 0;
|
||||
connID[i] = connPool[i].toString();
|
||||
connLockTime[i] = 0L;
|
||||
connCreateDate[i] = now.getTime();
|
||||
} catch (ClassNotFoundException e2) {
|
||||
log.debug("Error creating connection. The driver could not be loaded.", e2);
|
||||
}
|
||||
|
||||
log.debug("Opening connection [" + String.valueOf(i) + "]: " + connPool[i].toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the housekeeping thread and closes all connections in the pool. Call this method from the destroy()
|
||||
* method of the servlet.
|
||||
* <p/>
|
||||
* Multi-phase shutdown having following sequence:
|
||||
* </p>
|
||||
* <ol>
|
||||
* <li><code>getConnection()</code> will refuse to return connections.</li>
|
||||
* <li>The housekeeping thread is shut down.<br>
|
||||
* Up to the time of <code>millis</code> milliseconds after shutdown of the housekeeping thread,
|
||||
* <code>freeConnection()</code> can still be called to return used connections.<br>
|
||||
* After <code>millis</code> milliseconds after the shutdown of the housekeeping thread, all connections in the pool
|
||||
* are closed.</li>
|
||||
* <li>If any connections were in use while being closed then a <code>SQLException</code> is thrown.</li>
|
||||
* <li>The log is closed.</li>
|
||||
* </ol>
|
||||
* <p/>
|
||||
* Call this method from a servlet destroy() method.
|
||||
*
|
||||
* @param millis the time to wait in milliseconds.
|
||||
*
|
||||
* @throws SQLException if connections were in use after <code>millis</code>.
|
||||
*/
|
||||
public void destroy(int millis) throws SQLException {
|
||||
|
||||
log.info("Shutting down SimplePool.");
|
||||
|
||||
// Checking for invalid negative arguments is not necessary,
|
||||
// Thread.join() does this already in runner.join().
|
||||
|
||||
// Stop issuing connections
|
||||
available = false;
|
||||
|
||||
// Shut down the background housekeeping thread
|
||||
runner.interrupt();
|
||||
|
||||
// Wait until the housekeeping thread has died.
|
||||
try {
|
||||
runner.join((long) millis);
|
||||
} catch (InterruptedException ignore) {
|
||||
;
|
||||
}
|
||||
|
||||
// The housekeeping thread could still be running
|
||||
// (e.g. if millis is too small). This case is ignored.
|
||||
// At worst, this method will throw an exception with the
|
||||
// clear indication that the timeout was too short.
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
// Wait for freeConnection() to return any connections
|
||||
// that are still used at this time.
|
||||
int useCount;
|
||||
while ((useCount = getUseCount()) > 0 && System.currentTimeMillis() - startTime <= millis) {
|
||||
try {
|
||||
Thread.sleep(500L);
|
||||
} catch (InterruptedException ignore) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
// Close all connections, whether safe or not
|
||||
for (int i = 0; i < currConnections; i++) {
|
||||
try {
|
||||
connPool[i].close();
|
||||
} catch (SQLException e1) {
|
||||
log.debug("Cannot close connections on Destroy.");
|
||||
}
|
||||
}
|
||||
|
||||
if (useCount > 0) {
|
||||
//bt-test successful
|
||||
String msg = "Unsafe shutdown: Had to close " + useCount + " active DB connections after " + millis +
|
||||
"ms.";
|
||||
log.error(msg);
|
||||
// Throwing following Exception is essential because servlet authors
|
||||
// are likely to have their own error logging requirements.
|
||||
throw new SQLException(msg);
|
||||
}
|
||||
}//End destroy()
|
||||
|
||||
|
||||
/**
|
||||
* Less safe shutdown. Uses default timeout value.
|
||||
* <p/>
|
||||
* This method simply calls the <code>destroy()</code> method with a <code>millis</code> value of 10000 (10 seconds)
|
||||
* and ignores <code>SQLException</code> thrown by that method.
|
||||
*
|
||||
* @see #destroy(int)
|
||||
*/
|
||||
public void destroy() {
|
||||
try {
|
||||
destroy(10000);
|
||||
} catch (SQLException e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of connections in use.
|
||||
* <p/>
|
||||
* This method could be reduced to return a counter that is maintained by all methods that update connStatus.
|
||||
* However, it is more efficient to do it this way because: Updating the counter would put an additional burden on
|
||||
* the most frequently used methods; in comparison, this method is rarely used (although essential).
|
||||
*
|
||||
* @return The number of connections in use.
|
||||
*/
|
||||
public int getUseCount() {
|
||||
int useCount = 0;
|
||||
synchronized (connStatus) {
|
||||
for (int i = 0; i < currConnections; i++) {
|
||||
if (connStatus[i] > 0) { // In use
|
||||
useCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return useCount;
|
||||
}//End getUseCount()
|
||||
|
||||
/**
|
||||
* Returns the number of connections in the dynamic pool.
|
||||
*
|
||||
* @return The number of connections in the pool.
|
||||
*/
|
||||
public int getSize() {
|
||||
return currConnections;
|
||||
}//End getSize()
|
||||
|
||||
}// End class
|
357
simplepool/src/net/java/dev/simplepool/SimplePoolConnection.java
Normal file
357
simplepool/src/net/java/dev/simplepool/SimplePoolConnection.java
Normal file
|
@ -0,0 +1,357 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/simplepool/src/net/java/dev/simplepool/SimplePoolConnection.java,v $
|
||||
* $Revision: 1.1.1.1 $
|
||||
* $Date: 2004-03-28 00:16:23 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link java.sql.Connection}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1.1.1 $, $Date: 2004-03-28 00:16:23 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolConnection implements Connection {
|
||||
|
||||
private Connection conn;
|
||||
private SimplePool pool;
|
||||
|
||||
/**
|
||||
* Creates a new SimplePoolConnection object.
|
||||
*
|
||||
* @param pool The connection pool.
|
||||
*/
|
||||
public SimplePoolConnection(SimplePool pool) {
|
||||
this.pool = pool;
|
||||
conn = pool.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setAutoCommit(boolean)}.
|
||||
*/
|
||||
public void setAutoCommit(boolean autoCommit)
|
||||
throws SQLException {
|
||||
conn.setAutoCommit(autoCommit);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getAutoCommit}.
|
||||
*/
|
||||
public boolean getAutoCommit()
|
||||
throws SQLException {
|
||||
return conn.getAutoCommit();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setCatalog(String)}.
|
||||
*/
|
||||
public void setCatalog(String catalog)
|
||||
throws SQLException {
|
||||
conn.setCatalog(catalog);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getCatalog()}.
|
||||
*/
|
||||
public String getCatalog()
|
||||
throws SQLException {
|
||||
return conn.getCatalog();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#isClosed}.
|
||||
*/
|
||||
public boolean isClosed()
|
||||
throws SQLException {
|
||||
return conn.isClosed();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setHoldability(int)}.
|
||||
*/
|
||||
public void setHoldability(int holdability)
|
||||
throws SQLException {
|
||||
conn.setHoldability(holdability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getHoldability}.
|
||||
*/
|
||||
public int getHoldability()
|
||||
throws SQLException {
|
||||
return conn.getHoldability();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getMetaData}.
|
||||
*/
|
||||
public DatabaseMetaData getMetaData()
|
||||
throws SQLException {
|
||||
return conn.getMetaData();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setReadOnly(boolean)}.
|
||||
*/
|
||||
public void setReadOnly(boolean readOnly)
|
||||
throws SQLException {
|
||||
conn.setReadOnly(readOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#isReadOnly}.
|
||||
*/
|
||||
public boolean isReadOnly()
|
||||
throws SQLException {
|
||||
return conn.isReadOnly();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setSavepoint}.
|
||||
*/
|
||||
public Savepoint setSavepoint()
|
||||
throws SQLException {
|
||||
return conn.setSavepoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setSavepoint(String)}.
|
||||
*/
|
||||
public Savepoint setSavepoint(String savepoint)
|
||||
throws SQLException {
|
||||
return conn.setSavepoint(savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setTransactionIsolation(int)}.
|
||||
*/
|
||||
public void setTransactionIsolation(int level)
|
||||
throws SQLException {
|
||||
conn.setTransactionIsolation(level);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getTransactionIsolation}.
|
||||
*/
|
||||
public int getTransactionIsolation()
|
||||
throws SQLException {
|
||||
return conn.getTransactionIsolation();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#setTypeMap(Map)}.
|
||||
*/
|
||||
public void setTypeMap(Map map)
|
||||
throws SQLException {
|
||||
conn.setTypeMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getTypeMap}.
|
||||
*/
|
||||
public Map getTypeMap()
|
||||
throws SQLException {
|
||||
return conn.getTypeMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#getWarnings}.
|
||||
*/
|
||||
public SQLWarning getWarnings()
|
||||
throws SQLException {
|
||||
return conn.getWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#clearWarnings}.
|
||||
*/
|
||||
public void clearWarnings()
|
||||
throws SQLException {
|
||||
conn.clearWarnings();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#close}.
|
||||
*/
|
||||
public void close()
|
||||
throws SQLException {
|
||||
pool.freeConnection(conn);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#commit}.
|
||||
*/
|
||||
public void commit()
|
||||
throws SQLException {
|
||||
conn.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement}.
|
||||
*/
|
||||
public Statement createStatement()
|
||||
throws SQLException {
|
||||
return conn.createStatement();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement(int, int)}.
|
||||
*/
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.createStatement(resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#createStatement(int, int, int)}.
|
||||
*/
|
||||
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#nativeSQL(String)}.
|
||||
*/
|
||||
public String nativeSQL(String sql)
|
||||
throws SQLException {
|
||||
return conn.nativeSQL(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String, int, int)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql, resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareCall(String, int, int, int)}.
|
||||
*/
|
||||
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int, int)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int, int, int)}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
|
||||
int resultSetHoldability)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, int[])}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, columnIndexes);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#prepareStatement(String, String[])}.
|
||||
*/
|
||||
public PreparedStatement prepareStatement(String sql, String[] columnNames)
|
||||
throws SQLException {
|
||||
return conn.prepareStatement(sql, columnNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#releaseSavepoint(Savepoint)}.
|
||||
*/
|
||||
public void releaseSavepoint(Savepoint savepoint)
|
||||
throws SQLException {
|
||||
conn.releaseSavepoint(savepoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#rollback}.
|
||||
*/
|
||||
public void rollback()
|
||||
throws SQLException {
|
||||
conn.rollback();
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link java.sql.Connection#rollback(Savepoint)}.
|
||||
*/
|
||||
public void rollback(Savepoint savepoint)
|
||||
throws SQLException {
|
||||
conn.rollback(savepoint);
|
||||
}
|
||||
}
|
319
simplepool/src/net/java/dev/simplepool/SimplePoolDataSource.java
Normal file
319
simplepool/src/net/java/dev/simplepool/SimplePoolDataSource.java
Normal file
|
@ -0,0 +1,319 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/simplepool/src/net/java/dev/simplepool/SimplePoolDataSource.java,v $
|
||||
* $Revision: 1.1.1.1 $
|
||||
* $Date: 2004-03-28 00:16:24 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.PrintWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link javax.sql.DataSource}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1.1.1 $, $Date: 2004-03-28 00:16:24 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolDataSource implements DataSource {
|
||||
|
||||
private PrintWriter logWriter = new PrintWriter(System.out);
|
||||
private SimplePool pool = null;
|
||||
|
||||
private String driver = "";
|
||||
private String jdbcUrl = "";
|
||||
private String user = "";
|
||||
private String password = "";
|
||||
private String minConns = "";
|
||||
private String maxConns = "";
|
||||
private String maxConnTime = "";
|
||||
private String maxCheckoutSeconds = "";
|
||||
|
||||
/**
|
||||
* Initializes the connection pool.
|
||||
*
|
||||
* @throws Exception if the pool could not be intialized.
|
||||
*/
|
||||
protected void init() throws Exception {
|
||||
|
||||
pool = new SimplePool(driver, jdbcUrl, user, password,
|
||||
Integer.parseInt(minConns), Integer.parseInt(maxConns),
|
||||
Double.parseDouble(maxConnTime), Integer.parseInt(maxCheckoutSeconds));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getConnection()}.
|
||||
*/
|
||||
public Connection getConnection() throws SQLException {
|
||||
|
||||
if (pool == null) {
|
||||
try {
|
||||
init();
|
||||
} catch (Exception e) {
|
||||
throw new SQLException("Error initializing Connection Broker.");
|
||||
}
|
||||
}
|
||||
|
||||
return new SimplePoolConnection(pool);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getConnection(String, String)}.
|
||||
*/
|
||||
public Connection getConnection(String username, String password)
|
||||
throws SQLException {
|
||||
|
||||
throw new SQLException("Not supported in this DataSource.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#setLogWriter(PrintWriter)}.
|
||||
*/
|
||||
public void setLogWriter(PrintWriter out) throws SQLException {
|
||||
logWriter = out;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getLogWriter}.
|
||||
*/
|
||||
public PrintWriter getLogWriter() {
|
||||
return logWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#setLoginTimeout(int)}.
|
||||
*/
|
||||
public void setLoginTimeout(int seconds) throws SQLException {
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link javax.sql.DataSource#getLoginTimeout}.
|
||||
*/
|
||||
public int getLoginTimeout() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the connection pool.
|
||||
*/
|
||||
public void close() {
|
||||
pool.destroy();
|
||||
pool = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JDBC driver.
|
||||
*
|
||||
* @param driver The JDBC driver. e.g. 'com.mysql.jdbc.Driver'
|
||||
*
|
||||
* @see #getDriver()
|
||||
*/
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JDBC driver.
|
||||
*
|
||||
* @return The JDBC driver string.
|
||||
*
|
||||
* @see #setDriver(String)
|
||||
*/
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the JDBC connect string.
|
||||
*
|
||||
* @param jdbcUrl The JDBC connection URL string. e.g. 'jdbc:mysql://localhost:3306/dbname'
|
||||
*
|
||||
* @see #getJdbcUrl()
|
||||
*/
|
||||
public void setJdbcUrl(String jdbcUrl) {
|
||||
this.jdbcUrl = jdbcUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the JDBC connect string.
|
||||
*
|
||||
* @return The JDBC connection URL string.
|
||||
*
|
||||
* @see #setJdbcUrl(String)
|
||||
*/
|
||||
public String getJdbcUrl() {
|
||||
return jdbcUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database login name.
|
||||
*
|
||||
* @param user The database login name. e.g. 'Scott'
|
||||
*
|
||||
* @see #getUser()
|
||||
*/
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database login name.
|
||||
*
|
||||
* @return The login name string.
|
||||
*
|
||||
* @see #setUser(String)
|
||||
*/
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the database password.
|
||||
*
|
||||
* @param password The database password. e.g. 'Tiger'
|
||||
*
|
||||
* @see #getPassword()
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the database password.
|
||||
*
|
||||
* @return The password string.
|
||||
*
|
||||
* @see #setPassword(String)
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum number of connections to start with.
|
||||
*
|
||||
* @param minConns The minimum number of connections.
|
||||
*
|
||||
* @see #getMinConns()
|
||||
*/
|
||||
public void setMinConns(String minConns) {
|
||||
this.minConns = minConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimum number of connections to start with.
|
||||
*
|
||||
* @return The minimum number of connections string.
|
||||
*
|
||||
* @see #setMinConns(String)
|
||||
*/
|
||||
public String getMinConns() {
|
||||
return minConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum number of connections in dynamic pool.
|
||||
*
|
||||
* @param maxConns The maximum number of connections.
|
||||
*
|
||||
* @see #getMaxConns()
|
||||
*/
|
||||
public void setMaxConns(String maxConns) {
|
||||
this.maxConns = maxConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the maximum number of connections in dynamic pool.
|
||||
*
|
||||
* @return The maximum number of connection string.
|
||||
*
|
||||
* @see #setMaxConns(String)
|
||||
*/
|
||||
public String getMaxConns() {
|
||||
return maxConns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the time in days between connection resets.
|
||||
*
|
||||
* @param maxConnTime The maximum connection time.
|
||||
*
|
||||
* @see #getMaxConnTime()
|
||||
*/
|
||||
public void setMaxConnTime(String maxConnTime) {
|
||||
this.maxConnTime = maxConnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time in days between connection resets.
|
||||
*
|
||||
* @return The maximum connection time string.
|
||||
*
|
||||
* @see #setMaxConnTime(String)
|
||||
*/
|
||||
public String getMaxConnTime() {
|
||||
return maxConnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max time a connection can be checked out before being recycled.
|
||||
*
|
||||
* @param maxCheckoutSeconds The maximum number of seconds to wait before recycling a connection.
|
||||
*
|
||||
* @see #getMaxCheckoutSeconds()
|
||||
*/
|
||||
public void setMaxCheckoutSeconds(String maxCheckoutSeconds) {
|
||||
this.maxCheckoutSeconds = maxCheckoutSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the max time a connection can be checked out before being recycled.
|
||||
*
|
||||
* @return The maximum checkout time string.
|
||||
*
|
||||
* @see #setMaxCheckoutSeconds(String)
|
||||
*/
|
||||
public String getMaxCheckoutSeconds() {
|
||||
return maxCheckoutSeconds;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/simplepool/src/net/java/dev/simplepool/SimplePoolDataSourceFactory.java,v $
|
||||
* $Revision: 1.1.1.1 $
|
||||
* $Date: 2004-03-28 00:16:24 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.Name;
|
||||
import javax.naming.Reference;
|
||||
import javax.naming.spi.ObjectFactory;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* JNDI object factory that creates an instance of {@link SimplePoolDataSource}.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1.1.1 $, $Date: 2004-03-28 00:16:24 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolDataSourceFactory implements ObjectFactory {
|
||||
/**
|
||||
* Creates a {@link SimplePoolDataSource} instance.
|
||||
*
|
||||
* @param obj The object containing location or reference information that is used in creating the
|
||||
* <code>DataSource</code>.
|
||||
* @param name The name of this object relative to <code>ctx</code>, or null if no name is specified.
|
||||
* @param ctx The context relative to which the <code>name</code> parameter is specified, or null if
|
||||
* <code>name</code> is relative to the default initial context.
|
||||
* @param env The possibly null environment that is used in creating the <code>DataSource</code>.
|
||||
*
|
||||
* @return The <code>DataSource</code>; null if it cannot be created.
|
||||
*
|
||||
* @throws Exception if the factory encountered an exception while attempting to create the <code>DataSource</code>,
|
||||
* and no other object factories are to be tried.
|
||||
*/
|
||||
public Object getObjectInstance(Object obj, Name name, Context ctx, Hashtable env)
|
||||
throws Exception {
|
||||
|
||||
Reference ref = (Reference) obj;
|
||||
SimplePoolDataSource dataSource = new SimplePoolDataSource();
|
||||
|
||||
/*
|
||||
driver: JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'<br>
|
||||
jdbcUrl: JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'<br>
|
||||
user: Database login name. e.g. 'Scott'<br>
|
||||
password: Database password. e.g. 'Tiger'<br>
|
||||
minConns: Minimum number of connections to start with.<br>
|
||||
maxConns: Maximum number of connections in dynamic pool.<br>
|
||||
maxConnTime: Time in days between connection resets. (Reset does a basic cleanup)<br>
|
||||
maxCheckoutSeconds: Max time a connection can be checked out before being recycled. Zero value turns option
|
||||
off, default is 60 seconds.
|
||||
*/
|
||||
|
||||
String driver = (String) ref.get("driver").getContent();
|
||||
|
||||
if (driver != null) {
|
||||
dataSource.setDriver(driver);
|
||||
}
|
||||
|
||||
String user = (String) ref.get("user").getContent();
|
||||
|
||||
if (user != null) {
|
||||
dataSource.setUser(user);
|
||||
}
|
||||
|
||||
String password = (String) ref.get("password").getContent();
|
||||
|
||||
if (password != null) {
|
||||
dataSource.setPassword(password);
|
||||
}
|
||||
|
||||
String jdbcUrl = (String) ref.get("jdbcUrl").getContent();
|
||||
|
||||
if (jdbcUrl != null) {
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
}
|
||||
|
||||
String minConns = (String) ref.get("minConns").getContent();
|
||||
|
||||
if (minConns != null) {
|
||||
dataSource.setMinConns(minConns);
|
||||
}
|
||||
|
||||
String maxConns = (String) ref.get("maxConns").getContent();
|
||||
|
||||
if (maxConns != null) {
|
||||
dataSource.setMaxConns(maxConns);
|
||||
}
|
||||
|
||||
String maxConnTime = (String) ref.get("maxConnTime").getContent();
|
||||
|
||||
if (maxConnTime != null) {
|
||||
dataSource.setMaxConnTime(maxConnTime);
|
||||
}
|
||||
|
||||
String maxCheckoutSeconds = (String) ref.get("maxCheckoutSeconds").getContent();
|
||||
|
||||
if (maxCheckoutSeconds != null) {
|
||||
dataSource.setMaxCheckoutSeconds(maxCheckoutSeconds);
|
||||
}
|
||||
|
||||
dataSource.init();
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
}
|
141
simplepool/src/net/java/dev/simplepool/SimplePoolServlet.java
Normal file
141
simplepool/src/net/java/dev/simplepool/SimplePoolServlet.java
Normal file
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* $Source: /zpool01/javanet/scm/svn/tmp/cvs2svn/simplepool/simplepool/src/net/java/dev/simplepool/SimplePoolServlet.java,v $
|
||||
* $Revision: 1.1.1.1 $
|
||||
* $Date: 2004-03-28 00:16:24 $
|
||||
*
|
||||
* Copyright (c) 2004, Russell Beattie (http://www.russellbeattie.com/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Copyright (c) 2004, Erik C. Thauvin (http://www.thauvin.net/erik/)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* Neither the name of the authors nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.java.dev.simplepool;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a pool of database connection based on the specific intialization parameters.
|
||||
*
|
||||
* @author <a href="http://www.russellbeattie.com/">Russell Beattie</a>
|
||||
* @author <a href="http://www.thauvin.net/erik/">Erik C. Thauvin</a>
|
||||
* @version $Revision: 1.1.1.1 $, $Date: 2004-03-28 00:16:24 $
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SimplePoolServlet extends HttpServlet {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SimplePoolServlet.class);
|
||||
private static SimplePoolDataSource dataSource;
|
||||
|
||||
/**
|
||||
* Closes the connection pool.
|
||||
*
|
||||
* @see javax.servlet.http.HttpServlet#destroy
|
||||
*/
|
||||
public void destroy() {
|
||||
if (dataSource != null) {
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the connection pool.
|
||||
* <p/>
|
||||
* The required intialization parameters are:
|
||||
* <p/>
|
||||
* <ul>
|
||||
* <li><code>varName</code> – Name of the variable used to hold a reference to the
|
||||
* {@link SimplePoolDataSource}.</li>
|
||||
* <li><code>driver</code> – JDBC driver. e.g. 'oracle.jdbc.driver.OracleDriver'</li>
|
||||
* <li><code>jdbcUrl</code> – JDBC connect string. e.g. 'jdbc:oracle:thin:@203.92.21.109:1526:orcl'</li>
|
||||
* <li><code>user</code> – Database login name. e.g. 'Scott'</li>
|
||||
* <li><code>password</code> – Database password. e.g. 'Tiger'</li>
|
||||
* <li><code>minConns</code> – Minimum number of connections to start with.</li>
|
||||
* <li><code>maxConns</code> – Maximum number of connections in dynamic pool.</li>
|
||||
* <li><code>maxConnTime</code> – Time in days between connection resets.</li>
|
||||
* <li><code>maxCheckoutSeconds</code> – Max time a connection can be checked out before being recycled.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see javax.servlet.http.HttpServlet#init(ServletConfig)
|
||||
*/
|
||||
public void init(ServletConfig servletConfig)
|
||||
throws ServletException {
|
||||
log.info("Initializing " + servletConfig.getServletName() + " Servlet");
|
||||
|
||||
String varName = servletConfig.getInitParameter("varName");
|
||||
String driver = servletConfig.getInitParameter("driver");
|
||||
String jdbcUrl = servletConfig.getInitParameter("jdbcUrl");
|
||||
String user = servletConfig.getInitParameter("user");
|
||||
String password = servletConfig.getInitParameter("password");
|
||||
String minConns = servletConfig.getInitParameter("minConns");
|
||||
String maxConns = servletConfig.getInitParameter("maxConns");
|
||||
String maxConnTime = servletConfig.getInitParameter("maxConnTime");
|
||||
String maxCheckoutSeconds = servletConfig.getInitParameter("maxCheckoutSeconds");
|
||||
|
||||
if (isValid(varName) && isValid(driver) && isValid(jdbcUrl) && (user != null) && (password != null)
|
||||
&& isValid(minConns) && isValid(maxConns) && isValid(maxConnTime) && isValid(maxCheckoutSeconds)) {
|
||||
dataSource = new SimplePoolDataSource();
|
||||
|
||||
dataSource.setDriver(driver);
|
||||
dataSource.setJdbcUrl(jdbcUrl);
|
||||
dataSource.setUser(user);
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setMinConns(minConns);
|
||||
dataSource.setMaxConns(maxConns);
|
||||
dataSource.setMaxConnTime(maxConnTime);
|
||||
dataSource.setMaxCheckoutSeconds(maxCheckoutSeconds);
|
||||
|
||||
try {
|
||||
dataSource.init();
|
||||
|
||||
servletConfig.getServletContext().setAttribute(varName, dataSource);
|
||||
} catch (Exception e) {
|
||||
log.error("An error occurred while starting the connection pool.", e);
|
||||
throw new ServletException("Error starting the connection pool.");
|
||||
}
|
||||
} else {
|
||||
log.error("One or more intialization parameter is invalid or missing.");
|
||||
throw new ServletException("Invalid or missing initialization parameter.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValid(String s) {
|
||||
if ((s != null) && (s.length() > 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
13
simplepool/src/net/java/dev/simplepool/package.html
Normal file
13
simplepool/src/net/java/dev/simplepool/package.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>SimplePool API</title>
|
||||
</head>
|
||||
<body>
|
||||
This package contains a simple database connection pool implementation for web applications, specifically those using JSTL.
|
||||
<p/>
|
||||
The connection pool can be created, accessed and managed via JNDI or through the {@link net.java.dev.simplepool.SimplePoolServlet}.
|
||||
|
||||
@since 1.0
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue