Home » geronimo-2.2-source-release » org.apache.geronimo.console.jmsmanager » [javadoc | source]

    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.jmsmanager;
   19   
   20   import java.io.IOException;
   21   import java.util.HashMap;
   22   import java.util.Map;
   23   
   24   import javax.jms.ConnectionFactory;
   25   import javax.portlet.ActionRequest;
   26   import javax.portlet.ActionResponse;
   27   import javax.portlet.PortletConfig;
   28   import javax.portlet.PortletContext;
   29   import javax.portlet.PortletException;
   30   import javax.portlet.PortletRequestDispatcher;
   31   import javax.portlet.RenderRequest;
   32   import javax.portlet.RenderResponse;
   33   import javax.portlet.WindowState;
   34   
   35   import org.apache.geronimo.console.BasePortlet;
   36   import org.apache.geronimo.console.jmsmanager.handlers.CreateDestinationHandler;
   37   import org.apache.geronimo.console.jmsmanager.handlers.PortletResponseHandler;
   38   import org.apache.geronimo.console.jmsmanager.handlers.RemoveDestinationHandler;
   39   import org.apache.geronimo.console.jmsmanager.handlers.StatisticsHandler;
   40   import org.apache.geronimo.console.jmsmanager.renderers.CreateDestinationRenderer;
   41   import org.apache.geronimo.console.jmsmanager.renderers.PortletRenderer;
   42   import org.apache.geronimo.console.jmsmanager.renderers.StatisticsRenderer;
   43   import org.apache.geronimo.console.jmsmanager.renderers.ViewDLQRenderer;
   44   import org.apache.geronimo.console.jmsmanager.renderers.ViewDestinationsRenderer;
   45   import org.apache.geronimo.console.jmsmanager.renderers.ViewMessagesRenderer;
   46   
   47   public class JMSManagerPortlet extends BasePortlet {
   48   
   49       private PortletRequestDispatcher edit;
   50   
   51       private PortletRequestDispatcher help;
   52   
   53       private ConnectionFactory cf;
   54   
   55       private Map handlers;
   56   
   57       private Map renderers;
   58   
   59       private PortletContext context;
   60   
   61       public void init(PortletConfig portletConfig) throws PortletException {
   62           super.init(portletConfig);
   63   
   64           context = portletConfig.getPortletContext();
   65   
   66           help = context
   67                   .getRequestDispatcher("/WEB-INF/view/jmsmanager/help.jsp");
   68           edit = context
   69                   .getRequestDispatcher("/WEB-INF/view/jmsmanager/edit.jsp");
   70   
   71           renderers = new HashMap();
   72           renderers.put("createDestination", new CreateDestinationRenderer());
   73           renderers.put("viewDestinations", new ViewDestinationsRenderer());
   74           renderers.put("statistics", new StatisticsRenderer());
   75           renderers.put("viewMessages", new ViewMessagesRenderer());
   76           renderers.put("viewDLQ", new ViewDLQRenderer());
   77   
   78           handlers = new HashMap();
   79           handlers.put("createDestination", new CreateDestinationHandler());
   80           handlers.put("removeDestination", new RemoveDestinationHandler());
   81           handlers.put("statistics", new StatisticsHandler());
   82   
   83       }
   84   
   85       public void doHelp(RenderRequest renderRequest,
   86               RenderResponse renderResponse) throws PortletException, IOException {
   87           help.include(renderRequest, renderResponse);
   88       }
   89   
   90       public void doView(RenderRequest renderRequest,
   91               RenderResponse renderResponse) throws IOException, PortletException {
   92   
   93           if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
   94               return;
   95           }
   96   
   97           String view = renderRequest.getParameter("processAction");
   98           if (view == null) {
   99               // no specific content requested - show the destinations list
  100               view = "viewDestinations";
  101           }
  102   
  103           PortletRenderer renderer = (PortletRenderer) renderers.get(view);
  104           if (renderer == null) {
  105               throw new PortletException("Invalid view parameter specified: "
  106                       + view);
  107           }
  108   
  109           String include = renderer.render(renderRequest, renderResponse);
  110           if (include != null) {
  111               PortletRequestDispatcher requestDispatcher = context
  112                       .getRequestDispatcher(include);
  113               requestDispatcher.include(renderRequest, renderResponse);
  114           }
  115   
  116       }
  117   
  118       public void processAction(ActionRequest actionRequest,
  119               ActionResponse actionResponse) throws PortletException, IOException {
  120           String processAction = actionRequest.getParameter("processaction");
  121   
  122           PortletResponseHandler handler = (PortletResponseHandler) handlers
  123                   .get(processAction);
  124   
  125           if (handler == null) {
  126               // throw new RuntimeException( "no handlers for processAction = " +
  127               // processAction );
  128               handler = (PortletResponseHandler) handlers.get("viewDestinations");
  129           }
  130   
  131           handler.processAction(actionRequest, actionResponse);
  132       }
  133   
  134       public void destroy() {
  135   
  136           help = null;
  137           edit = null;
  138           super.destroy();
  139       }
  140   
  141   }

Home » geronimo-2.2-source-release » org.apache.geronimo.console.jmsmanager » [javadoc | source]