1 5 6 package org.infohazard.maverick.ctl; 7 8 import org.infohazard.maverick.flow.Controller; 9 import org.infohazard.maverick.flow.ControllerContext; 10 import javax.servlet.*; 11 import javax.servlet.http.*; 12 13 22 public abstract class Throwaway implements Controller 23 { 24 27 public static final String SUCCESS = "success"; 28 29 32 public static final String ERROR = "error"; 33 34 36 private ControllerContext controllerCtx; 37 38 45 public final String go(ControllerContext cctx) throws ServletException 46 { 47 try 48 { 49 this.controllerCtx = cctx; 50 51 String result = this.rawPerform(); 52 53 this.controllerCtx.setModel(this.model()); 54 55 return result; 56 } 57 catch (Exception ex) 58 { 59 throw new ServletException(ex); 60 } 61 } 62 63 66 protected abstract String rawPerform() throws Exception ; 67 68 72 public abstract Object model(); 73 74 77 protected ControllerContext getCtx() 78 { 79 return this.controllerCtx; 80 } 81 82 85 protected HttpServletRequest getRequest() 86 { 87 return this.controllerCtx.getRequest(); 88 } 89 90 93 protected HttpServletResponse getResponse() 94 { 95 return this.controllerCtx.getResponse(); 96 } 97 98 101 protected HttpSession getSession() 102 { 103 return this.getRequest().getSession(); 104 } 105 106 109 protected ServletConfig getServletConfig() 110 { 111 return this.controllerCtx.getServletConfig(); 112 } 113 114 117 protected ServletContext getServletContext() 118 { 119 return this.getServletConfig().getServletContext(); 120 } 121 } | Popular Tags |