KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > acting > AbstractConfigurableAction


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 package org.apache.cocoon.acting;
17
18 import org.apache.avalon.framework.configuration.Configurable;
19 import org.apache.avalon.framework.configuration.Configuration;
20 import org.apache.avalon.framework.configuration.ConfigurationException;
21 import org.apache.cocoon.util.HashMap;
22
23 /**
24  * AbstractConfigurableAction gives you the infrastructure for easily
25  * deploying more Actions that take default parameters.
26  *
27  * @author <a HREF="mailto:haul@apache.org">Christian Haul</a>
28  * @version CVS $Id: AbstractConfigurableAction.java 30932 2004-07-29 17:35:38Z vgritsenko $
29  */

30 public abstract class AbstractConfigurableAction extends AbstractAction implements Configurable {
31
32     /**
33      * Stores (global) configuration parameters as <code>key</code> /
34      * <code>value</code> pairs.
35      */

36     protected HashMap settings = null;
37
38     /**
39      * Configures the Action.
40      *
41      * Takes the children from the <code>Configuration</code> and stores them
42      * them as key (configuration name) and value (configuration value)
43      * in <code>settings</code>.
44      * <br/>
45      * This automates parsing of flat string-only configurations.
46      * For nested configurations, override this function in your action.
47      */

48     public void configure(Configuration conf) throws ConfigurationException {
49         Configuration[] parameters = conf.getChildren();
50         this.settings = new HashMap(parameters.length);
51         for (int i = 0; i < parameters.length; i++) {
52             String JavaDoc key = parameters[i].getName();
53             String JavaDoc val = parameters[i].getValue(null);
54             this.settings.put(key, val);
55         }
56     }
57 }
58
Popular Tags