|
SimpleServlets v5.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.simpleservlets.pageprocessor.PageProcessor
public abstract class PageProcessor
This abstract class is subclassed by the application-specific class
where the abstract setup() method is implemented.
If any shutdown tasks need to be done, override the shutdown()
method. The init(), destroy, doPost(),
and doGet() methods are rarely overridden (and if any of
these are overridden, care must be taken to avoid breaking
PageProcessor.
| Field Summary | |
|---|---|
static String |
ERROR_PAGE_NAME
Reserved page name for the error page. |
static String |
RELOAD_PAGE_NAME
Reserved page name for the "reload warning" page. |
| Constructor Summary | |
|---|---|
protected |
PageProcessor()
|
| Method Summary | |
|---|---|
void |
addPage(PageHandler handler,
String pageName)
Add a PageHandler and associate it with the specified
page name. |
void |
destroy()
Generally this should not be overridden in subclasses—use shutdown() instead. |
protected void |
doGet(HttpServletRequest req,
HttpServletResponse res)
Generally this should not be overridden in subclasses—use PageHandler instead. |
protected void |
doHeadCustom(HttpServletRequest req,
HttpServletResponse resp)
Generally this should not be overridden in subclasses—use PageHandler instead. |
protected void |
doPost(HttpServletRequest req,
HttpServletResponse res)
Generally this should not be overridden in subclasses—use PageHandler instead. |
PageHandler |
getErrorPage()
Returns the page handler designated as the error page. |
PageHandler |
getFrontPage()
Returns the page handler designated as the front page. |
String |
getFrontPageName()
Returns the name of the front page, or null if no front page has been specified yet. |
ValueMap |
getInitValues()
A mapping of all the web-app initialization parameters. |
PageHandler |
getPage(String pageName)
Returns the page handler for the page with the specified name. |
PageHandler |
getPage(String pageName,
Class<? extends PageHandler> pageType)
Returns the page handler for the page with the specified name. |
String |
getPageName(PageHandler handler)
Returns the name that was associated with the specified PageHandler. |
ReloadPageHandler |
getReloadPage()
Returns the page handler designated for reload/refresh attempts. |
InputStream |
getResourceAsStream(String pathToResource)
Retrieves a stream to a resource typically in the web-app context, typically from a file in a WAR-file. |
ValueMap |
getResourceAsValueMap(String pathToResource)
Creates a ValueMap from a resource typically in the
web-app context, typically from a file in a WAR-file. |
protected Session.Manager |
getSessionManager()
|
void |
init()
Generally this should not be overridden in subclasses—use setup() instead. |
boolean |
isFrontPageAvailable()
Returns true if there is a front page stored. |
boolean |
isPageAvailable(String pageName)
Returns true if there is a page stored for the specified page name. |
void |
setErrorPage(PageHandler handler)
Indicates the page to use when an uncaught exception occurs. |
void |
setFrontPage(PageHandler handler,
String pageName)
Add a PageHandler and associate it with the specified
page name. |
void |
setReloadPage(ReloadPageHandler handler)
Indicates the page to use when the user presses reload/refresh. |
abstract void |
setup()
Implemented by subclasses to configure initial settings. |
void |
showReloadPage(PageContext pc)
Requests that the reload/refresh warning page be shown. |
void |
showReloadPage(PageContext pc,
String continuePage)
Requests that the reload/refresh warning page be shown. |
void |
shutdown()
Called from the destroy() method of the servlet. |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ERROR_PAGE_NAME
public static final String RELOAD_PAGE_NAME
| Constructor Detail |
|---|
protected PageProcessor()
| Method Detail |
|---|
public abstract void setup()
throws PageProcessorException
getInitValues() and getSessionManager()
may be safely called from within setup().
PageProcessorExceptionpublic ValueMap getInitValues()
public InputStream getResourceAsStream(String pathToResource)
throws PageProcessorException
See IOTools.getInputStreamForResource(String) as a more
direct way of getting a stream. During initialization,
PageProcessor registers itself as a
IOTools.ServletResourceLocator
with IOTools.
PageProcessorException - if the specified resource can not
be found in the web-app context.
public ValueMap getResourceAsValueMap(String pathToResource)
throws PageProcessorException
ValueMap from a resource typically in the
web-app context, typically from a file in a WAR-file.
Path usually begins with "/", but this is not required.
See ValueMap.createFromResource(String) as a more
direct way of getting a map. During initialization,
PageProcessor registers itself as a
IOTools.ServletResourceLocator
with IOTools.
PageProcessorException - if the resource does not exist or if
there are problems reading from the specified file.protected Session.Manager getSessionManager()
public void setFrontPage(PageHandler handler,
String pageName)
PageHandler and associate it with the specified
page name. This page will also be marked as the "front page".
The "front page" is returned for unknown page names and when
no page name is specified.
public boolean isFrontPageAvailable()
public PageHandler getFrontPage()
throws PageProcessorException
PageProcessorException - if no front page has been set.public String getFrontPageName()
public void setErrorPage(PageHandler handler)
GenericErrorPage is used. There is always an error page defined.
public PageHandler getErrorPage()
public void setReloadPage(ReloadPageHandler handler)
GenericReloadPage is used. There is always a reload page defined.
public ReloadPageHandler getReloadPage()
public void showReloadPage(PageContext pc)
throws PageProcessorException
PageProcessorException
public void showReloadPage(PageContext pc,
String continuePage)
throws PageProcessorException
pc - context of the current request/response cyclecontinuePage - the page to link to from the warning page. If
null is passed in, then the link will be to the original
requested page that was part of the reload triggering.
PageProcessorException
public void addPage(PageHandler handler,
String pageName)
PageHandler and associate it with the specified
page name.
public boolean isPageAvailable(String pageName)
public PageHandler getPage(String pageName,
Class<? extends PageHandler> pageType)
throws PageProcessorException
PageProcessorException - if no page with that name can be found,
or if the page found does not match the pageType specified.
public PageHandler getPage(String pageName)
throws PageProcessorException
PageProcessorException - if no page with that name can be found.
public String getPageName(PageHandler handler)
throws PageProcessorException
handler - to look up name for
PageProcessorException - if no name has been associated, or
if 2+ names were associated with the same handler.public void shutdown()
public void init()
throws ServletException
setup() instead. If in a rare case this method does need to
be overridden, be sure to call super.init() first.
init in class GenericServletServletExceptionpublic void destroy()
shutdown() instead. If in a rare case this method does need to
be overridden, be sure to call super.destory() first.
destroy in interface Servletdestroy in class GenericServlet
protected void doGet(HttpServletRequest req,
HttpServletResponse res)
throws ServletException,
IOException
doGet in class HttpServletServletException
IOException
protected void doHeadCustom(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
HttpServlet and
does NOT call doGet()!
ServletException
IOException
protected void doPost(HttpServletRequest req,
HttpServletResponse res)
throws ServletException,
IOException
doPost in class HttpServletServletException
IOException
|
SimpleServlets v5.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||