KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > util > pool > PoolProperties


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 //NOTE: Tabs are used instead of spaces for indentation.
25
// Make sure that your editor does not replace tabs with spaces.
26
// Set the tab length using your favourite editor to your
27
// visual preference.
28

29 /*
30  * Filename: PoolProperties.java
31  *
32  * Copyright 2000-2001 by iPlanet/Sun Microsystems, Inc.,
33  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
34  * All rights reserved.
35  *
36  * This software is the confidential and proprietary information
37  * of iPlanet/Sun Microsystems, Inc. ("Confidential Information").
38  * You shall not disclose such Confidential Information and shall
39  * use it only in accordance with the terms of the license
40  * agreement you entered into with iPlanet/Sun Microsystems.
41  */

42  
43 /**
44  * <BR> <I>$Source: /cvs/glassfish/appserv-commons/src/java/com/sun/enterprise/util/pool/PoolProperties.java,v $</I>
45  * @author $Author: tcfujii $
46  * @version $Revision: 1.3 $ $Date: 2005/12/25 04:12:28 $
47  */

48  
49 package com.sun.enterprise.util.pool;
50
51 import java.util.Properties JavaDoc;
52
53 public class PoolProperties {
54
55     /**
56      * The factory class name property. Not used now.
57      */

58     public static final String JavaDoc FACTORY_CLASS_NAME = "pool.factory.class";
59     
60     /**
61      * Minimum pool size property.
62      */

63     public static final String JavaDoc MINIMUM_SIZE = "pool.minsize";
64     public static final String JavaDoc INITIAL_SIZE = "pool.initialsize";
65     public static final String JavaDoc LOW_WATER_MARK = "pool.lowwatermark";
66     public static final String JavaDoc HI_WATER_MARK = "pool.hiwatermark";
67     public static final String JavaDoc MAX_STRONG_REFERENCES = "pool.maxstrongrefs";
68     public static final String JavaDoc POOL_LIMIT = "pool.limit";
69     public static final String JavaDoc MAX_IDLE_TIME = "pool.maxidletime";
70     
71     public long key;
72     public String JavaDoc factoryClassName;
73     /**
74      * The minimum pool size. Default 0.
75      */

76     public int minimumSize;
77     
78     /**
79      * The initial pool size. Default 0.
80      */

81     public int initialSize;
82     
83     /**
84      * Low water mark. Pool implementation may interpret this property accordingly.
85      */

86     public int lowWaterMark;
87     
88     /**
89      * High water mark. Pool implementation may interpret this property accordingly.
90      */

91     public int hiWaterMark;
92     
93     /**
94      * Maximum strong References. SoftObjectPools uses this property. This property tells
95      * the maximum number of strong reference that can be maintained in the pool. This must
96      * be less than the pool limit and difference indicates the number of SoftReferences
97      * that will be used to hold the objects in the pool.
98      */

99     public int maxStrongRefs;
100     
101     /**
102      * The maximum size of the pool. <b>If this value is less than or equal to zero, then this
103      * pool will be treated as an UnBounded pool.</b>
104      */

105     public int poolLimit;
106     public long maxIdleTime;
107
108     public PoolProperties() {
109     }
110     
111     public PoolProperties(int minimumSize, int poolLimit) {
112         this.minimumSize = minimumSize;
113         this.poolLimit = poolLimit;
114     }
115     
116     public PoolProperties(Properties JavaDoc props) {
117         factoryClassName = props.getProperty(FACTORY_CLASS_NAME);
118         minimumSize = getIntProperty(props, MINIMUM_SIZE, 0);
119         initialSize = getIntProperty(props, INITIAL_SIZE, 0);
120         lowWaterMark = getIntProperty(props, LOW_WATER_MARK, 0);
121         hiWaterMark = getIntProperty(props, HI_WATER_MARK, 0);
122         poolLimit = getIntProperty(props, POOL_LIMIT, 0);
123         maxIdleTime = getLongProperty(props, MAX_IDLE_TIME, 60 * 1000);
124     }
125     
126     public String JavaDoc getFactoryClassName() {
127         return this.factoryClassName;
128     }
129     
130     public void setFactoryClassName(String JavaDoc name) {
131         this.factoryClassName = name;
132     }
133     
134     
135     public int getMinimumSize() {
136         return this.minimumSize;
137     }
138     public void setMinimumSize(int val) {
139         this.minimumSize = val;
140     }
141         
142     
143     public int getInitialSize() {
144         return this.initialSize;
145     }
146     public void setInitialSize(int val) {
147         this.initialSize = val;
148     }
149     
150     
151     public int getLowWaterMark() {
152         return this.lowWaterMark;
153     }
154     public void setLowWaterMark(int val) {
155         this.lowWaterMark = val;
156     }
157     
158     
159     public int getHiWaterMark() {
160         return this.hiWaterMark;
161     }
162     public void setHiWaterMark(int val) {
163         this.hiWaterMark = val;
164     }
165     
166     
167     public int getMaxStrongRefs() {
168         return this.maxStrongRefs;
169     }
170     public void setMaxStrongRefs(int val) {
171         this.maxStrongRefs = val;
172     }
173     
174     
175     public int getPoolLimit() {
176         return this.poolLimit;
177     }
178     public void setPoolLimit(int val) {
179         this.poolLimit = val;
180     }
181     
182     
183     public long getMaxIdleTime() {
184         return this.maxIdleTime;
185     }
186     public void setMaxIdleTime(long val) {
187         this.maxIdleTime = val;
188     }
189     
190     
191     
192     
193     private int getIntProperty(Properties JavaDoc props, String JavaDoc name, int defaultValue) {
194         try {
195             return Integer.parseInt(props.getProperty(name));
196         } catch (Throwable JavaDoc th) {
197             return defaultValue;
198         }
199     }
200     
201     
202     private long getLongProperty(Properties JavaDoc props, String JavaDoc name, long defaultValue) {
203         try {
204             return Long.parseLong(props.getProperty(name));
205         } catch (Throwable JavaDoc th) {
206             return defaultValue;
207         }
208     }
209     
210     public String JavaDoc toString() {
211         StringBuffer JavaDoc sbuf = new StringBuffer JavaDoc();
212         sbuf.append("key: ").append(key)
213             .append("; min: ").append(minimumSize)
214             .append("; init: ").append(initialSize)
215             .append("; lowWM: ").append(lowWaterMark)
216             .append("; hiWM: ").append(hiWaterMark)
217             .append("; maxSRefs: ").append(maxStrongRefs)
218             .append("; limit: ").append(poolLimit);
219         return sbuf.toString();
220     }
221     
222 }
223
Popular Tags