01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. 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: package org.apache.cocoon.components.modules.database;
19:
20: import org.apache.avalon.framework.activity.Disposable;
21: import org.apache.avalon.framework.configuration.Configurable;
22: import org.apache.avalon.framework.configuration.Configuration;
23: import org.apache.avalon.framework.configuration.ConfigurationException;
24: import org.apache.avalon.framework.logger.AbstractLogEnabled;
25:
26: import org.apache.cocoon.util.HashMap;
27:
28: /**
29: * AbstractDatabaseModule gives you the infrastructure for easily
30: * deploying more AutoIncrementModules. In order to get at the Logger, use
31: * getLogger().
32: *
33: * @author <a href="mailto:haul@apache.org">Christian Haul</a>
34: * @version CVS $Id: AbstractAutoIncrementModule.java 433543 2006-08-22 06:22:54Z crossley $
35: */
36: public abstract class AbstractAutoIncrementModule extends
37: AbstractLogEnabled implements AutoIncrementModule,
38: Configurable, Disposable {
39:
40: /**
41: * Stores (global) configuration parameters as <code>key</code> /
42: * <code>value</code> pairs.
43: */
44: protected HashMap settings = null;
45:
46: /**
47: * Configures the database access module.
48: *
49: * Takes all elements nested in component declaration and stores
50: * them as key-value pairs in <code>settings</code>. Nested
51: * configuration option are not catered for. This way global
52: * configuration options can be used.
53: *
54: * For nested configurations override this function.
55: * */
56: public void configure(Configuration conf)
57: throws ConfigurationException {
58: Configuration[] parameters = conf.getChildren();
59: this .settings = new HashMap(parameters.length);
60: for (int i = 0; i < parameters.length; i++) {
61: String key = parameters[i].getName();
62: String val = parameters[i].getValue();
63: this .settings.put(key, val);
64: }
65: }
66:
67: /**
68: * dispose
69: */
70: public void dispose() {
71: // Purposely empty so that we don't need to implement it in every
72: // class.
73: }
74: }
|