01: package org.apache.ojb.broker.core;
02:
03: /* Copyright 2003-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * 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;
26:
27: public class PBPoolInfo extends PoolConfiguration implements
28: Configurable {
29: private static final long serialVersionUID = 3331426619896735439L;
30:
31: public PBPoolInfo() {
32: super ();
33: init();
34: OjbConfigurator.getInstance().configure(this );
35: }
36:
37: public PBPoolInfo(Properties properties) {
38: super ();
39: init();
40: OjbConfigurator.getInstance().configure(this );
41: this .putAll(properties);
42: }
43:
44: /**
45: * Read in the configuration properties.
46: */
47: public void configure(Configuration pConfig)
48: throws ConfigurationException {
49: if (pConfig instanceof PBPoolConfiguration) {
50: PBPoolConfiguration conf = (PBPoolConfiguration) pConfig;
51: this .setMaxActive(conf.getMaxActive());
52: this .setMaxIdle(conf.getMaxIdle());
53: this .setMaxWait(conf.getMaxWaitMillis());
54: this .setMinEvictableIdleTimeMillis(conf
55: .getMinEvictableIdleTimeMillis());
56: this .setTimeBetweenEvictionRunsMillis(conf
57: .getTimeBetweenEvictionRunsMilli());
58: this .setWhenExhaustedAction(conf.getWhenExhaustedAction());
59: } else {
60: LoggerFactory
61: .getDefaultLogger()
62: .error(
63: 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: this .setTestOnBorrow(false);
76: this .setTestOnReturn(false);
77: this .setTestWhileIdle(false);
78: }
79: }
|