1 package com.sri.common.controller;
2
3 import com.jcorporate.expresso.core.controller.ControllerException;
4 import com.jcorporate.expresso.core.controller.ExpressoRequest;
5 import com.jcorporate.expresso.core.controller.ExpressoResponse;
6 import com.jcorporate.expresso.core.db.DBException;
7
8 /***
9 * This interface is an alternative for external state classes produced
10 * inside expresso. In the case of a state handler, all that happens is that
11 * this class is allocated and called within the function call to the state.
12 * It allows delegation to keep Expresso controllers from becoming behemoths,
13 * assists in grouping behavior together and is a step towards taming the
14 * wild 'all-in-one' class behavior that has become common in Expresso
15 * controllers.
16 *
17 * @author Michael Rimov
18 */
19 public interface StateHandler {
20
21 /***
22 * Called to handle the request. Here's an example of the usage within
23 * an Expresso <code>Controller</code> state handler. It is assumed
24 * that the class <code>MyHandler</code> implements the StateHandler
25 * interface.
26 * <p/>
27 * <code><pre>
28 * protected void runMyState(final ControllerRequest request,
29 * final ControllerResponse response) throws ControllerException, DBException {
30 * <p/>
31 * MyHander handler = new MyHandler();
32 * handler.handleRequest(request,response);
33 * }
34 * </pre></code>
35 * </p>
36 *
37 * @param request ControllerRequest The Function's ControllerRequest object.
38 * @param response ControllerResponse The Function's ControllerResponse object.
39 * @throws DBException upon underlying database exception error.
40 * @throws ControllerException upon underlying ControllerException error.
41 * @throws NonHandleableException if the state attempts a transition that
42 * throws a NonHandleableException
43 */
44 void handleRequest(ExpressoRequest request, ExpressoResponse response) throws DBException, ControllerException;
45
46
47 }