KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > service > AddServiceAction


1 /*
2  * Copyright 2001-2002,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.webapp.admin.service;
18
19 import java.io.IOException JavaDoc;
20 import java.util.Locale JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import javax.servlet.ServletException JavaDoc;
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.http.HttpServletResponse JavaDoc;
25 import javax.servlet.http.HttpSession JavaDoc;
26 import org.apache.struts.action.Action;
27 import org.apache.struts.action.ActionErrors;
28 import org.apache.struts.action.ActionForm;
29 import org.apache.struts.action.ActionForward;
30 import org.apache.struts.action.ActionMapping;
31 import org.apache.struts.util.MessageResources;
32 import org.apache.webapp.admin.LabelValueBean;
33 import org.apache.webapp.admin.Lists;
34
35 /**
36  * The <code>Action</code> that sets up <em>Add Service</em> transactions.
37  *
38  * @author Manveen Kaur
39  * @version $Revision: 1.8 $ $Date: 2004/10/18 06:37:55 $
40  */

41
42 public class AddServiceAction extends Action {
43         
44     // --------------------------------------------------------- Public Methods
45

46     /**
47      * Process the specified HTTP request, and create the corresponding HTTP
48      * response (or forward to another web component that will create it).
49      * Return an <code>ActionForward</code> instance describing where and how
50      * control should be forwarded, or <code>null</code> if the response has
51      * already been completed.
52      *
53      * @param mapping The ActionMapping used to select this instance
54      * @param actionForm The optional ActionForm bean for this request (if any)
55      * @param request The HTTP request we are processing
56      * @param response The HTTP response we are creating
57      *
58      * @exception IOException if an input/output error occurs
59      * @exception ServletException if a servlet exception occurs
60      */

61     public ActionForward execute(ActionMapping mapping,
62                                  ActionForm form,
63                                  HttpServletRequest JavaDoc request,
64                                  HttpServletResponse JavaDoc response)
65         throws IOException JavaDoc, ServletException JavaDoc {
66
67         // Acquire the resources that we need
68
HttpSession JavaDoc session = request.getSession();
69         Locale JavaDoc locale = getLocale(request);
70         MessageResources resources = getResources(request);
71         
72         String JavaDoc serverName = request.getParameter("select");
73         
74         // Fill in the form values for display and editing
75
ServiceForm serviceFm = new ServiceForm();
76         session.setAttribute("serviceForm", serviceFm);
77         serviceFm.setAdminAction("Create");
78         serviceFm.setObjectName("");
79         serviceFm.setEngineObjectName("");
80         serviceFm.setServiceName("");
81         serviceFm.setEngineName("");
82         serviceFm.setDefaultHost("localhost");
83         serviceFm.setAdminServiceName("");
84         serviceFm.setServerObjectName(serverName);
85         ArrayList JavaDoc hosts = new ArrayList JavaDoc();
86         hosts.add(new LabelValueBean
87                   (resources.getMessage(locale, "list.none"), ""));
88         serviceFm.setHostNameVals(hosts);
89         
90         // Forward to the service display page
91
return (mapping.findForward("Service"));
92         
93     }
94
95
96 }
97
Popular Tags