001    /*
002     * Copyright 1999,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.apache.commons.scaffold.http;
018    
019    
020    import java.io.IOException;
021    import java.util.Properties;
022    import javax.servlet.ServletException;
023    
024    import org.apache.commons.scaffold.http.ConnectionServlet;
025    
026    /**
027     * Load a connection adaptor and initialize default command store
028     * for use with StorageBeans.
029     * <p>
030     * This servlet can be configured using the following init-params:
031     * <p>
032     * <b>command_path</b> Path to SQL commands (Properties file).
033     * <p>
034     * <b>NOTE:</b> Unlike the path to the Struts application resources file,
035     * the paths for this servlet should use a slash and includes the
036     * properties extension.
037     * <p>
038     * The runtime processing of requests is handled by the Struts controller.
039     * This servlet is just to handle our own custom bits.
040     */
041    public class SetUp extends ConnectionServlet {
042    
043    
044    // --------------------------------------------------------------- keys
045    
046        /**
047         * Parameter to specify a new path for commands used by the
048         * application [command_path].
049         */
050        public static String COMMAND_PARAMETER = "command_path";
051    
052    
053        /**
054         * Default path for commands used by application
055         * ["resources/command.properties"].
056         */
057        public static String COMMAND_PATH =
058            "resources/command.properties";
059    
060    
061    
062    // --------------------------------------------------------- initCustom
063    
064        /**
065         * Initialize the SQL properties for the Artimus application.
066         *
067         * Loads the commands for the keys and articles packages.
068         *
069         * @exception IOException if an input/output error is encountered
070         * @exception ServletException if we cannot initialize these resources
071         */
072        protected void initCustom() throws IOException, ServletException {
073    
074                // Initialize sql package
075            Properties commands =
076                loadProperties(COMMAND_PARAMETER,COMMAND_PATH,null);
077    
078            org.apache.commons.scaffold.sql.StorageBeanBase.init(commands);
079    
080        }
081    
082    } // end SetUp
083