KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > dbcp > AbandonedConfig


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.commons.dbcp;
18
19 /**
20  * Configuration settings for handling abandoned db connections.
21  *
22  * @author Glenn L. Nielsen
23  * @version $Revision: 1.5 $ $Date: 2004/02/28 11:48:04 $
24  * @deprecated This will be removed in a future version of DBCP.
25  */

26 public class AbandonedConfig {
27
28     private boolean removeAbandoned = false;
29
30     /**
31      * Flag to remove abandoned connections if they exceed the
32      * removeAbandonedTimeout.
33      *
34      * Set to true or false, default false.
35      * If set to true a connection is considered abandoned and eligible
36      * for removal if it has been idle longer than the removeAbandonedTimeout.
37      * Setting this to true can recover db connections from poorly written
38      * applications which fail to close a connection.
39      *
40      * @return boolean
41      */

42     public boolean getRemoveAbandoned() {
43         return (this.removeAbandoned);
44     }
45
46     /**
47      * Flag to remove abandoned connections if they exceed the
48      * removeAbandonedTimeout.
49      *
50      * Set to true or false, default false.
51      * If set to true a connection is considered abandoned and eligible
52      * for removal if it has been idle longer than the removeAbandonedTimeout.
53      * Setting this to true can recover db connections from poorly written
54      * applications which fail to close a connection.
55      *
56      * @param boolean
57      */

58     public void setRemoveAbandoned(boolean removeAbandoned) {
59         this.removeAbandoned = removeAbandoned;
60     }
61
62     private int removeAbandonedTimeout = 300;
63
64     /**
65      * Timeout in seconds before an abandoned connection can be removed.
66      *
67      * Defaults to 300 seconds.
68      *
69      * @return int remove abandoned timeout in seconds
70      */

71     public int getRemoveAbandonedTimeout() {
72         return (this.removeAbandonedTimeout);
73     }
74
75     /**
76      * Timeout in seconds before an abandoned connection can be removed.
77      *
78      * Defaults to 300 seconds.
79      *
80      * @param int remove abandoned timeout in seconds
81      */

82     public void setRemoveAbandonedTimeout(int removeAbandonedTimeout) {
83         this.removeAbandonedTimeout = removeAbandonedTimeout;
84     }
85
86     private boolean logAbandoned = false;
87
88     /**
89      * Flag to log stack traces for application code which abandoned
90      * a Statement or Connection.
91      *
92      * Defaults to false.
93      * Logging of abandoned Statements and Connections adds overhead
94      * for every Connection open or new Statement because a stack
95      * trace has to be generated.
96      *
97      * @return boolean
98      */

99     public boolean getLogAbandoned() {
100         return (this.logAbandoned);
101     }
102
103     /**
104      * Flag to log stack traces for application code which abandoned
105      * a Statement or Connection.
106      *
107      * Defaults to false.
108      * Logging of abandoned Statements and Connections adds overhead
109      * for every Connection open or new Statement because a stack
110      * trace has to be generated.
111      *
112      * @param boolean
113      */

114     public void setLogAbandoned(boolean logAbandoned) {
115         this.logAbandoned = logAbandoned;
116     }
117
118 }
119
Popular Tags