KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > console > internaldb > InternalDBPortlet


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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  */

17
18 package org.apache.geronimo.console.internaldb;
19
20 import java.io.IOException JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Map JavaDoc;
23
24 import javax.portlet.ActionRequest;
25 import javax.portlet.ActionResponse;
26 import javax.portlet.PortletConfig;
27 import javax.portlet.PortletException;
28 import javax.portlet.PortletRequestDispatcher;
29 import javax.portlet.RenderRequest;
30 import javax.portlet.RenderResponse;
31 import javax.portlet.WindowState;
32
33 import org.apache.geronimo.console.BasePortlet;
34
35 public class InternalDBPortlet extends BasePortlet {
36
37     private static final String JavaDoc NORMALVIEW_JSP = "/WEB-INF/view/internaldb/internalDBNormal.jsp";
38
39     private static final String JavaDoc MAXIMIZEDVIEW_JSP = "/WEB-INF/view/internaldb/internalDBMaximized.jsp";
40
41     private static final String JavaDoc HELPVIEW_JSP = "/WEB-INF/view/internaldb/internalDBHelp.jsp";
42
43     private static InternalDBHelper helper = new InternalDBHelper();
44
45     private static Map JavaDoc javaSysInfo = new HashMap JavaDoc();
46
47     private PortletRequestDispatcher normalView;
48
49     private PortletRequestDispatcher maximizedView;
50
51     private PortletRequestDispatcher helpView;
52
53     public void processAction(ActionRequest actionRequest,
54             ActionResponse actionResponse) throws PortletException, IOException JavaDoc {
55         // Getting parameters here because it fails on doView()
56
String JavaDoc rdbms = actionRequest.getParameter("rdbms");
57         if (rdbms != null) {
58             actionResponse.setRenderParameter("rdbms", rdbms);
59         }
60     }
61
62     protected void doView(RenderRequest renderRequest,
63             RenderResponse renderResponse) throws IOException JavaDoc, PortletException {
64         if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
65             return;
66         }
67
68         String JavaDoc rdbmsParam = renderRequest.getParameter("rdbms");
69         int rdbms = 1;
70         if ((rdbmsParam != null) && (rdbmsParam.length() > 0)) {
71             rdbms = Integer.parseInt(rdbmsParam);
72         }
73         Map JavaDoc internalDB = helper.getDBInfo();
74         renderRequest.setAttribute("internalDB", internalDB);
75
76         if (WindowState.NORMAL.equals(renderRequest.getWindowState())) {
77             normalView.include(renderRequest, renderResponse);
78         } else {
79             maximizedView.include(renderRequest, renderResponse);
80         }
81     }
82
83     protected void doHelp(RenderRequest renderRequest,
84             RenderResponse renderResponse) throws PortletException, IOException JavaDoc {
85         helpView.include(renderRequest, renderResponse);
86     }
87
88     public void init(PortletConfig portletConfig) throws PortletException {
89         super.init(portletConfig);
90         normalView = portletConfig.getPortletContext().getRequestDispatcher(
91                 NORMALVIEW_JSP);
92         maximizedView = portletConfig.getPortletContext().getRequestDispatcher(
93                 MAXIMIZEDVIEW_JSP);
94         helpView = portletConfig.getPortletContext().getRequestDispatcher(
95                 HELPVIEW_JSP);
96     }
97
98     public void destroy() {
99         normalView = null;
100         maximizedView = null;
101         helpView = null;
102         super.destroy();
103     }
104
105 }
Popular Tags