KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > connector > AddConnectorAction


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

43
44 public class AddConnectorAction extends Action {
45     
46     
47     // --------------------------------------------------------- Public Methods
48

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

64     public ActionForward execute(ActionMapping mapping,
65     ActionForm form,
66     HttpServletRequest JavaDoc request,
67     HttpServletResponse JavaDoc response)
68     throws IOException JavaDoc, ServletException JavaDoc {
69         
70         // Acquire the resources that we need
71
HttpSession JavaDoc session = request.getSession();
72         
73         // the service Name is needed to retrieve the engine mBean to
74
// which the new connector mBean will be added.
75
String JavaDoc serviceName = request.getParameter("select");
76         
77         // Fill in the form values for display and editing
78
ConnectorForm connectorFm = new ConnectorForm();
79         session.setAttribute("connectorForm", connectorFm);
80         connectorFm.setAdminAction("Create");
81         connectorFm.setObjectName("");
82         connectorFm.setConnectorName("");
83         String JavaDoc type = request.getParameter("type");
84         if (type == null)
85             type = "HTTP"; // default type is HTTP
86
connectorFm.setConnectorType(type);
87         connectorFm.setServiceName(serviceName);
88         if ("HTTPS".equalsIgnoreCase(type)) {
89             connectorFm.setScheme("https");
90         } else {
91             connectorFm.setScheme("http");
92         }
93         connectorFm.setAcceptCountText("10");
94         connectorFm.setCompression("off");
95         connectorFm.setConnLingerText("-1");
96         connectorFm.setConnTimeOutText("60000");
97         connectorFm.setConnUploadTimeOutText("300000");
98         connectorFm.setBufferSizeText("2048");
99         connectorFm.setDisableUploadTimeout("false");
100         connectorFm.setEnableLookups("true");
101         connectorFm.setAddress("");
102         connectorFm.setPortText("");
103         connectorFm.setRedirectPortText("-1");
104         connectorFm.setMinProcessorsText("5");
105         connectorFm.setMaxProcessorsText("20");
106         connectorFm.setMaxKeepAliveText("100");
107         connectorFm.setMaxSpare("50");
108         connectorFm.setMaxThreads("200");
109         connectorFm.setMinSpare("4");
110         connectorFm.setThreadPriority(String.valueOf(Thread.NORM_PRIORITY));
111         connectorFm.setSecure("false");
112         connectorFm.setTcpNoDelay("true");
113         connectorFm.setXpoweredBy("false");
114
115         //supported only by HTTPS
116
connectorFm.setAlgorithm("SunX509");
117         connectorFm.setClientAuthentication("false");
118         connectorFm.setCiphers("");
119         connectorFm.setKeyStoreFileName("");
120         connectorFm.setKeyStorePassword("");
121         connectorFm.setKeyStoreType("JKS");
122         connectorFm.setSslProtocol("TLS");
123                        
124         // supported only by Coyote connectors
125
connectorFm.setProxyName("");
126         connectorFm.setProxyPortText("0");
127         
128         connectorFm.setBooleanVals(Lists.getBooleanValues());
129         connectorFm.setClientAuthVals(Lists.getClientAuthValues());
130         
131         String JavaDoc schemeTypes[]= new String JavaDoc[3];
132         schemeTypes[0] = "HTTP";
133         schemeTypes[1] = "HTTPS";
134         schemeTypes[2] = "AJP";
135         
136         ArrayList JavaDoc types = new ArrayList JavaDoc();
137         // the first element in the select list should be the type selected
138
types.add(new LabelValueBean(type,
139                 "AddConnector.do?select=" +
140                 URLEncoder.encode(serviceName,TomcatTreeBuilder.URL_ENCODING)
141                 + "&type=" + type));
142          for (int i=0; i< schemeTypes.length; i++) {
143             if (!type.equalsIgnoreCase(schemeTypes[i])) {
144                 types.add(new LabelValueBean(schemeTypes[i],
145                 "AddConnector.do?select=" +
146                 URLEncoder.encode(serviceName,TomcatTreeBuilder.URL_ENCODING)
147                 + "&type=" + schemeTypes[i]));
148             }
149         }
150         connectorFm.setConnectorTypeVals(types);
151         
152         // Forward to the connector display page
153
return (mapping.findForward("Connector"));
154         
155     }
156 }
157
Popular Tags