KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > core > PBPoolInfo


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

17
18 import org.apache.ojb.broker.util.configuration.Configurable;
19 import org.apache.ojb.broker.util.configuration.Configuration;
20 import org.apache.ojb.broker.util.configuration.ConfigurationException;
21 import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
22 import org.apache.ojb.broker.util.logging.LoggerFactory;
23 import org.apache.ojb.broker.util.pooling.PoolConfiguration;
24
25 import java.util.Properties JavaDoc;
26
27 public class PBPoolInfo extends PoolConfiguration implements Configurable
28 {
29     private static final long serialVersionUID = 3331426619896735439L;
30
31     public PBPoolInfo()
32     {
33         super();
34         init();
35         OjbConfigurator.getInstance().configure(this);
36     }
37
38     public PBPoolInfo(Properties JavaDoc properties)
39     {
40         super();
41         init();
42         OjbConfigurator.getInstance().configure(this);
43         this.putAll(properties);
44     }
45
46     /**
47      * Read in the configuration properties.
48      */

49     public void configure(Configuration pConfig) throws ConfigurationException
50     {
51         if (pConfig instanceof PBPoolConfiguration)
52         {
53             PBPoolConfiguration conf = (PBPoolConfiguration) pConfig;
54             this.setMaxActive(conf.getMaxActive());
55             this.setMaxIdle(conf.getMaxIdle());
56             this.setMaxWait(conf.getMaxWaitMillis());
57             this.setMinEvictableIdleTimeMillis(conf.getMinEvictableIdleTimeMillis());
58             this.setTimeBetweenEvictionRunsMillis(conf.getTimeBetweenEvictionRunsMilli());
59             this.setWhenExhaustedAction(conf.getWhenExhaustedAction());
60         }
61         else
62         {
63             LoggerFactory.getDefaultLogger().error(this.getClass().getName() +
64                     " cannot read configuration properties, use default.");
65         }
66     }
67
68     /**
69      * Init default properties.
70      * We set {@link #setTestOnBorrow}, {@link #setTestOnReturn}, {@link #setTestWhileIdle}
71      * to <ii>false<ii> (See documentation of jakarta-commons-pool).
72      * Override this to change behavior.
73      */

74     public void init()
75     {
76         this.setTestOnBorrow(false);
77         this.setTestOnReturn(false);
78         this.setTestWhileIdle(false);
79     }
80 }
81
Popular Tags