001/* 002 * Copyright 2011 Atteo. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 005 * in compliance with the License. You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software distributed under the License 010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 011 * or implied. See the License for the specific language governing permissions and limitations under 012 * the License. 013 */ 014package org.atteo.moonshine.jta; 015 016import javax.xml.bind.annotation.XmlElement; 017import javax.xml.bind.annotation.XmlRootElement; 018 019import org.atteo.config.Configurable; 020 021@XmlRootElement(name = "pool") 022public class PoolOptions extends Configurable { 023 024 /** 025 * Sets the minimum pool size. 026 * The amount of pooled connections won't go below that value. 027 * The pool will open this amount of connections during initialization. 028 */ 029 @XmlElement 030 private Integer minPoolSize = 2; 031 032 /** 033 * Sets the maximum pool size. The amount of pooled connections won't go 034 * above this value. 035 */ 036 @XmlElement 037 private Integer maxPoolSize = 25; 038 039 /** 040 * Sets the maximum amount of seconds that unused excess connections should stay in the pool. Optional. 041 * 042 * Note: excess connections are connections that are created above the minPoolSize limit. 043 * Note that this value is only an indication; the pool will check regularly as indicated 044 * by the maintenanceInteval property. 045 */ 046 @XmlElement 047 private Integer maxIdleTime; 048 049 /** 050 * Sets the amount of time (in seconds) that the connection pool will allow a connection 051 * to be in use, before claiming it back. Optional. 052 * 053 * The timeout in seconds. Zero means unlimited. Note that this value is 054 * only an indication; the pool will check regularly as indicated by the maintenanceInteval property. 055 */ 056 @XmlElement 057 private Integer reapTimeout; 058 059 /** 060 * Sets the maximum amount of seconds that a connection is kept in the pool before it is destroyed automatically. 061 * Optional, defaults to 0 (no limit). 062 * <p> 063 * This makes transaction manager aware of how long it can keep connection and so removes the need for a test query. 064 * This, in turn, improves performance of the pool because borrowing a connection no longer implies 065 * a roundtrip to the database (inside a synchronized block!). 066 * </p> 067 * <p> 068 * Set this to 0, to use test queries instead. 069 * </p> 070 */ 071 @XmlElement 072 private Integer maxLifeTime = 120; 073 074 public Integer getMinPoolSize() { 075 return minPoolSize; 076 } 077 078 public Integer getMaxPoolSize() { 079 return maxPoolSize; 080 } 081 082 public Integer getMaxIdleTime() { 083 return maxIdleTime; 084 } 085 086 public Integer getReapTimeout() { 087 return reapTimeout; 088 } 089 090 public Integer getMaxLifeTime() { 091 return maxLifeTime; 092 } 093}