View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.controllers.threads;
12  
13  import javax.servlet.http.HttpServletRequest;
14  import javax.servlet.http.HttpServletResponse;
15  
16  import org.springframework.beans.factory.annotation.Value;
17  import org.springframework.stereotype.Controller;
18  import org.springframework.web.bind.ServletRequestUtils;
19  import org.springframework.web.bind.annotation.RequestMapping;
20  import org.springframework.web.servlet.ModelAndView;
21  import org.springframework.web.servlet.mvc.AbstractController;
22  
23  import psiprobe.Utils;
24  
25  /**
26   * The Class ImplSelectorController.
27   */
28  @Controller
29  public class ImplSelectorController extends AbstractController {
30  
31    /** The impl1 controller. */
32    private String impl1Controller;
33  
34    /** The impl2 controller. */
35    private String impl2Controller;
36  
37    /**
38     * Gets the impl1 controller.
39     *
40     * @return the impl1 controller
41     */
42    public String getImpl1Controller() {
43      return impl1Controller;
44    }
45  
46    /**
47     * Sets the impl1 controller.
48     *
49     * @param impl1Controller the new impl1 controller
50     */
51    @Value("forward:/th_impl1.htm")
52    public void setImpl1Controller(String impl1Controller) {
53      this.impl1Controller = impl1Controller;
54    }
55  
56    /**
57     * Gets the impl2 controller.
58     *
59     * @return the impl2 controller
60     */
61    public String getImpl2Controller() {
62      return impl2Controller;
63    }
64  
65    /**
66     * Sets the impl2 controller.
67     *
68     * @param impl2Controller the new impl2 controller
69     */
70    @Value("forward:/th_impl2.htm")
71    public void setImpl2Controller(String impl2Controller) {
72      this.impl2Controller = impl2Controller;
73    }
74  
75    @RequestMapping(path = "/threads.htm")
76    @Override
77    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
78        throws Exception {
79      return super.handleRequest(request, response);
80    }
81  
82    @Override
83    protected ModelAndView handleRequestInternal(HttpServletRequest request,
84        HttpServletResponse response) throws Exception {
85      boolean forceOld = ServletRequestUtils.getBooleanParameter(request, "forceold", false);
86      if (!forceOld && Utils.isThreadingEnabled()) {
87        return new ModelAndView(impl2Controller);
88      }
89      return new ModelAndView(impl1Controller);
90    }
91  
92  }