001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.console.jmxmanager;
017:
018: import java.io.IOException;
019: import java.io.PrintWriter;
020:
021: import javax.portlet.ActionRequest;
022: import javax.portlet.ActionResponse;
023: import javax.portlet.PortletConfig;
024: import javax.portlet.PortletContext;
025: import javax.portlet.PortletException;
026: import javax.portlet.PortletRequestDispatcher;
027: import javax.portlet.RenderRequest;
028: import javax.portlet.RenderResponse;
029: import javax.portlet.WindowState;
030:
031: import org.apache.geronimo.console.BasePortlet;
032:
033: /**
034: * The JMX manager portlet
035: */
036: public class JMXManagerPortlet extends BasePortlet {
037: private static final String VIEWJMXSERVER_ACTION = "viewJMXServer";
038:
039: private static final String VIEWJMXSERVER_JSP = "/WEB-INF/view/jmxmanager/viewJMXServer.jsp";
040:
041: private static final String HELP_JSP = "/WEB-INF/view/jmxmanager/help.jsp";
042:
043: private PortletRequestDispatcher viewJMXServerView;
044:
045: private PortletRequestDispatcher helpView;
046:
047: /**
048: * Process an action request
049: */
050: public void processAction(ActionRequest actionRequest,
051: ActionResponse actionResponse) throws PortletException,
052: IOException {
053: }
054:
055: /**
056: * Serve up the view mode
057: */
058: protected void doView(RenderRequest renderRequest,
059: RenderResponse renderResponse) throws IOException,
060: PortletException {
061: if (WindowState.MINIMIZED
062: .equals(renderRequest.getWindowState())) {
063: return;
064: } else if (WindowState.NORMAL.equals(renderRequest
065: .getWindowState())) {
066: String action = renderRequest.getParameter("action");
067: if (action == null) {
068: action = VIEWJMXSERVER_ACTION;
069: }
070: if (VIEWJMXSERVER_ACTION.equals(action)) {
071: viewJMXServerView
072: .include(renderRequest, renderResponse);
073: } else {
074: renderResponse.setContentType("text/html");
075: PrintWriter out = renderResponse.getWriter();
076: String errorMsg = "Invalid action message: " + action;
077: out.println(errorMsg);
078: }
079: } else if (WindowState.MAXIMIZED.equals(renderRequest
080: .getWindowState())) {
081: renderResponse.setContentType("text/html");
082: PrintWriter out = renderResponse.getWriter();
083: String errorMsg = "Invalid window state: "
084: + renderRequest.getWindowState();
085: out.println(errorMsg);
086: }
087: }
088:
089: /**
090: * Serve up the help mode
091: */
092: protected void doHelp(RenderRequest renderRequest,
093: RenderResponse renderResponse) throws PortletException,
094: IOException {
095: helpView.include(renderRequest, renderResponse);
096: }
097:
098: /**
099: * Portlet is being placed into service
100: */
101: public void init(PortletConfig portletConfig)
102: throws PortletException {
103: super .init(portletConfig);
104: PortletContext pc = portletConfig.getPortletContext();
105: viewJMXServerView = pc.getRequestDispatcher(VIEWJMXSERVER_JSP);
106: helpView = pc.getRequestDispatcher(HELP_JSP);
107: }
108:
109: /**
110: * Portlet is being taken out of service
111: */
112: public void destroy() {
113: viewJMXServerView = null;
114: helpView = null;
115: super.destroy();
116: }
117: }
|