View Javadoc

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  
17  package org.apache.commons.scaffold.http;
18  
19  
20  import java.io.IOException;
21  import java.util.Properties;
22  import javax.servlet.ServletException;
23  
24  import org.apache.commons.scaffold.http.ConnectionServlet;
25  
26  /**
27   * Load a connection adaptor and initialize default command store
28   * for use with StorageBeans.
29   * <p>
30   * This servlet can be configured using the following init-params:
31   * <p>
32   * <b>command_path</b> Path to SQL commands (Properties file).
33   * <p>
34   * <b>NOTE:</b> Unlike the path to the Struts application resources file,
35   * the paths for this servlet should use a slash and includes the
36   * properties extension.
37   * <p>
38   * The runtime processing of requests is handled by the Struts controller.
39   * This servlet is just to handle our own custom bits.
40   */
41  public class SetUp extends ConnectionServlet {
42  
43  
44  // --------------------------------------------------------------- keys
45  
46      /**
47       * Parameter to specify a new path for commands used by the
48       * application [command_path].
49       */
50      public static String COMMAND_PARAMETER = "command_path";
51  
52  
53      /**
54       * Default path for commands used by application
55       * ["resources/command.properties"].
56       */
57      public static String COMMAND_PATH =
58          "resources/command.properties";
59  
60  
61  
62  // --------------------------------------------------------- initCustom
63  
64      /**
65       * Initialize the SQL properties for the Artimus application.
66       *
67       * Loads the commands for the keys and articles packages.
68       *
69       * @exception IOException if an input/output error is encountered
70       * @exception ServletException if we cannot initialize these resources
71       */
72      protected void initCustom() throws IOException, ServletException {
73  
74              // Initialize sql package
75          Properties commands =
76              loadProperties(COMMAND_PARAMETER,COMMAND_PATH,null);
77  
78          org.apache.commons.scaffold.sql.StorageBeanBase.init(commands);
79  
80      }
81  
82  } // end SetUp
83