1 /* 2 * Copyright (c) 2003, Inversoft 3 * 4 * This software is distribuable under the GNU Lesser General Public License. 5 * For more information visit gnu.org. 6 */ 7 package com.inversoft.verge.mvc.controller; 8 9 10 import com.inversoft.verge.mvc.MVCException; 11 import com.inversoft.verge.mvc.MVCRequest; 12 13 14 /** 15 * <p> 16 * This interface describes how the default Inversoft MVC 17 * implementation handles the controller logic. In most 18 * cases, the controller will call some business logic, in 19 * some fashion and then change the view to show the results. 20 * Of course, the implementations will dictate how the 21 * controller portion of the MVC system works. 22 * </p> 23 * 24 * <p> 25 * This logic is abstracted in the default Inversoft MVC 26 * implementation from the {@link ControllerParser 27 * ControllerParser} interface so that it can vary depending 28 * on the request more easily. Logic default implementation 29 * uses the same parameter structure for all types of 30 * controllers. The choice of controller is dependent on 31 * a simple parameter. Therefore, the parser determines what 32 * type of controller the request will be using and then 33 * uses an implementation of this interface to call handle 34 * the controller. 35 * </p> 36 * 37 * @author Brian Pontarelli 38 * @since 2.0 39 * @version 2.0 40 */ 41 public interface ControllerHandler { 42 43 /** 44 * Allows the controller implementation to set attributes on the {@link 45 * MVCRequest MVCRequest} object before any MVC processing at all happens. 46 * 47 * @param mvcRequest The MVCRequest to setup 48 * @throws com.inversoft.verge.mvc.MVCException If there were any problems during setting 49 */ 50 void preExecute(MVCRequest mvcRequest) throws MVCException; 51 52 /** 53 * Handles the controller logic by calling business logic, forwarding, 54 * redirecting, or whatever implementations deem necessary. 55 * 56 * @param mvcRequest This contains the HttpServletRequest to use when 57 * calling the Controller system. It also contains the 58 * HttpServletResponse to use when calling the Controller system. 59 * Lastly This contains other controller information which can be 60 * used when calling the controller system. 61 * @return Optionally, this method can return an instance of the Result 62 * interfact that tells the ControllerParser how to handle the 63 * response, which will either to a forward or a redirect to a URL. 64 * If null is returned, the Parser assumes the result has already 65 * been handled 66 * @throws com.inversoft.verge.mvc.MVCException If there were any problems during execution 67 */ 68 Result execute(MVCRequest mvcRequest) throws MVCException; 69 }