01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.console.apache.jk;
17:
18: import java.io.IOException;
19: import javax.portlet.ActionRequest;
20: import javax.portlet.ActionResponse;
21: import javax.portlet.PortletException;
22: import javax.portlet.RenderRequest;
23: import javax.portlet.RenderResponse;
24: import org.apache.geronimo.console.MultiPageModel;
25: import org.apache.geronimo.console.util.PortletManager;
26: import org.apache.geronimo.management.geronimo.NetworkConnector;
27: import org.apache.geronimo.management.geronimo.WebManager;
28:
29: /**
30: * Handler for the screen where you select the webapps to expose through Apache
31: *
32: * @version $Rev: 476061 $ $Date: 2006-11-16 22:36:50 -0800 (Thu, 16 Nov 2006) $
33: */
34: public class ResultsHandler extends BaseApacheHandler {
35: public ResultsHandler() {
36: super (RESULTS_MODE, "/WEB-INF/view/apache/jk/results.jsp");
37: }
38:
39: public String actionBeforeView(ActionRequest request,
40: ActionResponse response, MultiPageModel model)
41: throws PortletException, IOException {
42: //todo: Add AJP Connector
43: return getMode();
44: }
45:
46: public void renderView(RenderRequest request,
47: RenderResponse response, MultiPageModel amodel)
48: throws PortletException, IOException {
49: ApacheModel model = (ApacheModel) amodel;
50: String port = "unknown";
51: if (model.getAddAjpPort() != null) {
52: port = model.getAddAjpPort().toString();
53: } else {
54: WebManager[] managers = PortletManager
55: .getWebManagers(request);
56: // See if any AJP listeners are defined
57: for (int i = 0; i < managers.length; i++) {
58: WebManager manager = managers[i];
59: NetworkConnector[] connectors = manager
60: .getConnectors(WebManager.PROTOCOL_AJP);
61: if (connectors.length > 0) {
62: port = Integer.toString(connectors[0].getPort());
63: break;
64: }
65: }
66: }
67: request.setAttribute("ajpPort", port);
68: }
69:
70: public String actionAfterView(ActionRequest request,
71: ActionResponse response, MultiPageModel model)
72: throws PortletException, IOException {
73: return getMode() + BEFORE_ACTION;
74: }
75: }
|