Skip to content

Commit

Permalink
Apply auto-formatting, re #8
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed Feb 27, 2024
1 parent c731a03 commit c55d8e6
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 87 deletions.
130 changes: 65 additions & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,71 +28,71 @@ OpenJAX DBCP is based on a [XML Schema][dbcp-schema] used to specify the formal
1. Create a `dbcp.xml` in `src/main/resources/`.

```xml
<dbcp name="example"
xmlns="http://www.openjax.org/dbcp-1.1.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openjax.org/dbcp-1.1.xsd http://www.openjax.org/dbcp.xsd">
<jdbc>
<url>jdbc:derby:memory:example;create=true</url>
<driverClassName>org.apache.derby.jdbc.EmbeddedDriver</driverClassName>
</jdbc>
<default>
<catalog>catalog</catalog>
<autoCommit>true</autoCommit>
<readOnly>false</readOnly>
<queryTimeout>300000</queryTimeout>
<transactionIsolation>READ_UNCOMMITTED</transactionIsolation>
</default>
<connection>
<properties>
<property name="prop1" value="value1"/>
<property name="prop2" value="value2"/>
</properties>
<initSqls>
<initSql>SELECT 1 FROM SYSIBM.SYSDUMMY1</initSql>
<initSql>SELECT 1 FROM SYSIBM.SYSDUMMY1</initSql>
</initSqls>
</connection>
<size>
<initialSize>0</initialSize>
<maxTotal>8</maxTotal>
<maxIdle>8</maxIdle>
<minIdle>0</minIdle>
<maxOpenPreparedStatements>INDEFINITE</maxOpenPreparedStatements>
</size>
<pool>
<queue>lifo</queue>
<cacheState>false</cacheState>
<maxWait>INDEFINITE</maxWait>
<maxConnectionLifetime>INDEFINITE</maxConnectionLifetime>
<autoCommitOnReturn>true</autoCommitOnReturn>
<rollbackOnReturn>true</rollbackOnReturn>
<removeAbandoned on="maintenance" timeout="300"/>
<abandonedUsageTracking>true</abandonedUsageTracking>
<allowAccessToUnderlyingConnection>false</allowAccessToUnderlyingConnection>
<eviction>
<timeBetweenRuns>300000</timeBetweenRuns>
<numTestsPerRun>3</numTestsPerRun>
<minIdleTime>1800000</minIdleTime>
<softMinIdleTime>INDEFINITE</softMinIdleTime>
<policyClassName>org.openjax.dbcp.MockEvictionPolicy</policyClassName>
</eviction>
</pool>
<validation>
<query>SELECT 1 FROM SYSIBM.SYSDUMMY1</query>
<testOnBorrow>false</testOnBorrow>
<testOnReturn>false</testOnReturn>
<testWhileIdle>false</testWhileIdle>
<fastFail>
<disconnectionSqlCodes>42X01 42X02 42X03</disconnectionSqlCodes>
</fastFail>
</validation>
<logging>
<level>INFO</level>
<logExpiredConnections>true</logExpiredConnections>
<logAbandoned>true</logAbandoned>
</logging>
</dbcp>
<dbcp id="example"
xmlns="http://www.openjax.org/dbcp-1.2.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.openjax.org/dbcp-1.2.xsd http://www.openjax.org/dbcp.xsd">
<jdbc>
<url>jdbc:derby:memory:example;create=true</url>
<driverClassName>org.apache.derby.jdbc.EmbeddedDriver</driverClassName>
</jdbc>
<default>
<catalog>catalog</catalog>
<autoCommit>true</autoCommit>
<readOnly>false</readOnly>
<queryTimeout>300000</queryTimeout>
<transactionIsolation>READ_UNCOMMITTED</transactionIsolation>
</default>
<connection>
<properties>
<property name="prop1" value="value1"/>
<property name="prop2" value="value2"/>
</properties>
<initSqls>
<initSql>SELECT 1 FROM SYSIBM.SYSDUMMY1</initSql>
<initSql>SELECT 1 FROM SYSIBM.SYSDUMMY1</initSql>
</initSqls>
</connection>
<size>
<initialSize>0</initialSize>
<maxTotal>8</maxTotal>
<maxIdle>8</maxIdle>
<minIdle>0</minIdle>
<poolPreparedStatements/>
</size>
<pool>
<queue>lifo</queue>
<cacheState>false</cacheState>
<maxWait>INDEFINITE</maxWait>
<maxConnectionLifetime>INDEFINITE</maxConnectionLifetime>
<autoCommitOnReturn>true</autoCommitOnReturn>
<rollbackOnReturn>true</rollbackOnReturn>
<removeAbandoned on="maintenance" timeout="300"/>
<abandonedUsageTracking>true</abandonedUsageTracking>
<allowAccessToUnderlyingConnection>false</allowAccessToUnderlyingConnection>
<eviction>
<timeBetweenRuns>300000</timeBetweenRuns>
<numTestsPerRun>3</numTestsPerRun>
<minIdleTime>1800000</minIdleTime>
<softMinIdleTime>INDEFINITE</softMinIdleTime>
<policyClassName>org.openjax.dbcp.MockEvictionPolicy</policyClassName>
</eviction>
</pool>
<validation>
<query>SELECT 1 FROM SYSIBM.SYSDUMMY1</query>
<testOnBorrow>false</testOnBorrow>
<testOnReturn>false</testOnReturn>
<testWhileIdle>false</testWhileIdle>
<fastFail>
<disconnectionSqlCodes>42X01 42X02 42X03</disconnectionSqlCodes>
</fastFail>
</validation>
<logging>
<level>INFO</level>
<logExpiredConnections>true</logExpiredConnections>
<logAbandoned>true</logAbandoned>
</logging>
</dbcp>
```

1. Add `org.openjax:dbcp` dependency to the POM.
Expand Down
48 changes: 27 additions & 21 deletions src/main/java/org/openjax/dbcp/DataSources.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public static BasicDataSource createDataSource(final URL url, final ClassLoader
}

/**
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that match
* the specified {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by the {@link BasicDataSource} when it loads
* the JDBC driver.
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that match the
* specified {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by the {@link BasicDataSource} when it loads the
* JDBC driver.
*
* @param id The id of the {@link Dbcp dbcp} bindings to match, or {@code null} to match all bindings.
* @param dbcps Array of {@link Dbcp} JAX-B bindings.
Expand All @@ -136,9 +136,8 @@ public static BasicDataSource createDataSource(final String id, final Dbcp ... d
}

/**
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that match
* any {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by the {@link BasicDataSource} when it loads the JDBC
* driver.
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that match any
* {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by the {@link BasicDataSource} when it loads the JDBC driver.
*
* @param dbcps Array of {@link Dbcp} JAX-B bindings.
* @return The {@link BasicDataSource} instance.
Expand Down Expand Up @@ -181,8 +180,8 @@ public static BasicDataSource createDataSource(final $Dbcp ... dbcps) {

/**
* Create a {@link BasicDataSource} from the configuration supplied by the {@code /dbcp:dbcp} child elements of the provided
* {@link org.openjax.dbcp_1_2.Dbcps} JAX-B binding that match the specified {@code id}.
* {@link ClassLoader#getSystemClassLoader()} will be used by the {@link BasicDataSource} when it loads the JDBC driver.
* {@link org.openjax.dbcp_1_2.Dbcps} JAX-B binding that match the specified {@code id}. {@link ClassLoader#getSystemClassLoader()}
* will be used by the {@link BasicDataSource} when it loads the JDBC driver.
*
* @param id The id of the {@code /dbcp:dbcp} child elements of the provided {@link org.openjax.dbcp_1_2.Dbcps} to match, or
* {@code null} to match all child elements.
Expand Down Expand Up @@ -213,8 +212,8 @@ public static BasicDataSource createDataSource(final org.openjax.dbcp_1_2.Dbcps

/**
* Create a {@link BasicDataSource} from the configuration supplied by the {@code /dbcp:dbcp} child elements of the provided
* {@link Dbcps} JAX-SB binding that match the specified {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by
* the {@link BasicDataSource} when it loads the JDBC driver.
* {@link Dbcps} JAX-SB binding that match the specified {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by the
* {@link BasicDataSource} when it loads the JDBC driver.
*
* @param id The id of the {@code /dbcp:dbcp} child elements of the provided {@link Dbcps} to match, or {@code null} to match all
* child elements.
Expand Down Expand Up @@ -336,9 +335,9 @@ public static BasicDataSource createDataSource(final ClassLoader driverClassLoad
}

/**
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that that
* match any {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by the {@link BasicDataSource} when it loads the
* JDBC driver.
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that that match
* any {@code id}. {@link ClassLoader#getSystemClassLoader()} will be used by the {@link BasicDataSource} when it loads the JDBC
* driver.
*
* @param dbcp The {@link Dbcp} JAX-B bindings providing the configuration.
* @return The {@link BasicDataSource} instance.
Expand Down Expand Up @@ -413,8 +412,8 @@ public static BasicDataSource createDataSource(final $Dbcp dbcp) {
private boolean logAbandoned = false;

/**
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that match
* the specified {@code id}.
* Create a {@link BasicDataSource} from the configuration supplied by the array of {@link Dbcp dbcp} JAX-B bindings that match the
* specified {@code id}.
*
* @param id The id of the {@link Dbcp dbcp} bindings to match, or {@code null} to match all bindings.
* @param driverClassLoader Class loader to be used by the {@link BasicDataSource} when it loads the JDBC driver.
Expand Down Expand Up @@ -493,7 +492,8 @@ private DataSources(final String id, final ClassLoader driverClassLoader, final
final int i$ = properties.size();
if (i$ > 0) {
if (CollectionUtil.isRandomAccess(properties)) {
int i = 0; do { // [RA]
int i = 0;
do { // [RA]
final Dbcp.Connection.Properties.Property property = properties.get(i);
final String name = property.getName();
final String value = property.getValue();
Expand All @@ -503,7 +503,8 @@ private DataSources(final String id, final ClassLoader driverClassLoader, final
while (++i < i$);
}
else {
final Iterator<Dbcp.Connection.Properties.Property> it = properties.iterator(); do { // [I]
final Iterator<Dbcp.Connection.Properties.Property> it = properties.iterator();
do { // [I]
final Dbcp.Connection.Properties.Property property = it.next();
final String name = property.getName();
final String value = property.getValue();
Expand Down Expand Up @@ -730,7 +731,8 @@ private DataSources(final String id, final ClassLoader driverClassLoader, final
final int i$ = properties.size();
if (i$ > 0) {
if (CollectionUtil.isRandomAccess(properties)) {
int i = 0; do { // [RA]
int i = 0;
do { // [RA]
final $Dbcp.Connection.Properties.Property property = properties.get(i);
final $Dbcp.Connection.Properties.Property.Name$ name = property.getName$();
final $Dbcp.Connection.Properties.Property.Value$ value = property.getValue$();
Expand All @@ -740,7 +742,8 @@ private DataSources(final String id, final ClassLoader driverClassLoader, final
while (++i < i$);
}
else {
final Iterator<$Dbcp.Connection.Properties.Property> it = properties.iterator(); do { // [I]
final Iterator<$Dbcp.Connection.Properties.Property> it = properties.iterator();
do { // [I]
final $Dbcp.Connection.Properties.Property property = it.next();
final $Dbcp.Connection.Properties.Property.Name$ name = property.getName$();
final $Dbcp.Connection.Properties.Property.Value$ value = property.getValue$();
Expand All @@ -758,12 +761,15 @@ private DataSources(final String id, final ClassLoader driverClassLoader, final
if (initSqls != null && (size = (sqls = initSqls.getInitSql()).size()) > 0) {
final String[] sql = new String[size];
if (CollectionUtil.isRandomAccess(sqls)) {
int i = 0; do // [RA]
int i = 0;
do // [RA]
sql[i] = sqls.get(i).text();
while (++i < size);
}
else {
int i = -1; final Iterator<$StringNonEmpty> it = sqls.iterator(); do // [I]
int i = -1;
final Iterator<$StringNonEmpty> it = sqls.iterator();
do // [I]
sql[++i] = it.next().text();
while (it.hasNext());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/openjax/dbcp/DelegateDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
}

@Override
public <T>T unwrap(final Class<T> iface) throws SQLException {
public <T> T unwrap(final Class<T> iface) throws SQLException {
return target.unwrap(iface);
}

Expand Down

0 comments on commit c55d8e6

Please sign in to comment.