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 java.util.List;
20: import javax.portlet.ActionRequest;
21: import javax.portlet.ActionResponse;
22: import javax.portlet.PortletException;
23: import javax.portlet.RenderRequest;
24: import javax.portlet.RenderResponse;
25: import org.apache.commons.logging.Log;
26: import org.apache.commons.logging.LogFactory;
27: import org.apache.geronimo.console.MultiPageModel;
28: import org.apache.geronimo.console.util.ConfigurationData;
29: import org.apache.geronimo.console.util.PortletManager;
30: import org.apache.geronimo.kernel.config.ConfigurationModuleType;
31: import org.apache.geronimo.management.geronimo.WebModule;
32:
33: /**
34: * Handler for the screen where you select the webapps to expose through Apache
35: *
36: * @version $Rev: 476061 $ $Date: 2006-11-16 22:36:50 -0800 (Thu, 16 Nov 2006) $
37: */
38: public class WebAppHandler extends BaseApacheHandler {
39: private final static Log log = LogFactory
40: .getLog(WebAppHandler.class);
41:
42: public WebAppHandler() {
43: super (WEB_APP_MODE, "/WEB-INF/view/apache/jk/webApps.jsp");
44: }
45:
46: public String actionBeforeView(ActionRequest request,
47: ActionResponse response, MultiPageModel model)
48: throws PortletException, IOException {
49: return getMode();
50: }
51:
52: public void renderView(RenderRequest request,
53: RenderResponse response, MultiPageModel amodel)
54: throws PortletException, IOException {
55: ApacheModel model = (ApacheModel) amodel;
56: ConfigurationData[] webApps = PortletManager.getConfigurations(
57: request, ConfigurationModuleType.WAR, true);
58: if (model.getWebApps().size() == 0) {
59: List list = model.getWebApps();
60: for (int i = 0; i < webApps.length; i++) {
61: ConfigurationData app = webApps[i];
62: WebAppData data = new WebAppData(app.getParentName()
63: .getArtifact(), app.getChildName(), app
64: .getModuleBeanName() == null ? null : app
65: .getModuleBeanName(), false, null, false);
66: if (app.isRunning()) {
67: WebModule web = (WebModule) PortletManager
68: .getManagedBean(request, app
69: .getModuleBeanName());
70: data.setContextRoot(web.getContextPath());
71: String path;
72: if (web.getWARDirectory().getProtocol().equals(
73: "file")) {
74: path = web.getWARDirectory().getPath();
75: } else {
76: path = "WARMustBeUnpacked";
77: }
78:
79: data.setWebAppDir(path);
80: }
81: list.add(data);
82: }
83: }
84: request.setAttribute("webApps", webApps);
85: }
86:
87: public String actionAfterView(ActionRequest request,
88: ActionResponse response, MultiPageModel amodel)
89: throws PortletException, IOException {
90: return RESULTS_MODE + BEFORE_ACTION;
91: }
92: }
|