View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package com.hack23.cia.web.controller.admin;
6   
7   import com.hack23.cia.service.api.admin.MonitorRequest;
8   import com.hack23.cia.service.api.admin.MonitorResponse;
9   import com.hack23.cia.service.api.application.ApplicationManager;
10  import com.hack23.cia.web.action.admin.MonitorAdminAction;
11  import com.hack23.cia.web.viewfactory.api.admin.MonitorModelAndView;
12  import com.hack23.cia.web.viewfactory.api.admin.MonitorModelAndView.MonitorViewSpecification;
13  import com.hack23.cia.web.viewfactory.api.common.ModelAndView;
14  import com.hack23.cia.web.viewfactory.api.common.ViewFactoryService;
15  
16  /***
17   * The Class MonitorActionHandler.
18   */
19  public class MonitorActionHandler
20          extends
21          AbstractAdminActionHandler<MonitorAdminAction, MonitorRequest, MonitorResponse> {
22  
23      /***
24       * Instantiates a new monitor action handler.
25       *
26       * @param viewFactoryService the view factory service
27       * @param applicationManager the application manager
28       */
29      public MonitorActionHandler(final ViewFactoryService viewFactoryService,
30              final ApplicationManager applicationManager) {
31          super(viewFactoryService, applicationManager);
32      }
33  
34      /*
35       * (non-Javadoc)
36       * 
37       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
38       * createServiceRequest(com.hack23.cia.web.action.common.AbstractAction)
39       */
40      @Override
41      public final MonitorRequest createServiceRequest(
42              final MonitorAdminAction action) {
43          return new MonitorRequest(getUserStateService().getUserSessionId(),
44                  action.getOperation());
45      }
46  
47      /*
48       * (non-Javadoc)
49       * 
50       * @see com.hack23.cia.web.controller.ActionHandler#getSupportedAction()
51       */
52      @SuppressWarnings("unchecked")
53      @Override
54      public final Class getSupportedAction() {
55          return MonitorAdminAction.class;
56      }
57  
58      /*
59       * (non-Javadoc)
60       * 
61       * @seecom.hack23.cia.web.controller.common.AbstractGenericHandler#
62       * handleSuccessResponse(com.hack23.cia.web.action.common.AbstractAction,
63       * com.hack23.cia.service.api.common.AbstractServiceResponse)
64       */
65      @Override
66      public final ModelAndView handleSuccessResponse(
67              final MonitorAdminAction action, final MonitorResponse response) {
68          ModelAndView modelAndView = null;
69  
70          switch (action.getOperation()) {
71          case ResponseTime:
72              modelAndView = new MonitorModelAndView(response.getUserSessionDTO(),
73                      action, MonitorViewSpecification.ResponseTimeView, response
74                              .getGraphFile());
75              break;
76          case RecentActions:
77              modelAndView = new MonitorModelAndView(response.getUserSessionDTO(),
78                      action, MonitorViewSpecification.RecentActionsView,
79                      response.getGraphFile());
80              break;
81          default:
82              break;
83          }
84  
85          return modelAndView;
86  
87      }
88  
89  }