View Javadoc

1   /*
2    * Copyright 2004 Carlos Sanchez.
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 net.sf.oness.common.webapp.controller.action;
17  
18  import javax.servlet.http.HttpServletRequest;
19  import javax.servlet.http.HttpServletResponse;
20  
21  import net.sf.oness.common.model.util.dbunit.DatabasePopulator;
22  
23  import org.apache.struts.action.Action;
24  import org.apache.struts.action.ActionForm;
25  import org.apache.struts.action.ActionForward;
26  import org.apache.struts.action.ActionMapping;
27  
28  /***
29   * Action that populates the database using the bean called "databasePopulator"
30   * in Spring Application Context
31   * 
32   * @author Carlos Sanchez
33   * @version $Revision: 1.2 $
34   */
35  public class DatabasePopulatorAction extends Action {
36  
37      private DatabasePopulator databasePopulator;
38  
39      /***
40       * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
41       *      org.apache.struts.action.ActionForm,
42       *      javax.servlet.http.HttpServletRequest,
43       *      javax.servlet.http.HttpServletResponse)
44       */
45      public ActionForward execute(ActionMapping actionMapping,
46              ActionForm actionForm, HttpServletRequest servletRequest,
47              HttpServletResponse servletResponse) throws Exception {
48          if (databasePopulator == null)
49              databasePopulator = (DatabasePopulator) new SpringActionSupport(
50                      servlet).getBean("databasePopulator");
51          databasePopulator.execute();
52          return actionMapping.findForward("success");
53      }
54  
55  }