|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The Shunt interface allows Maverick to automagically determine which of a set of views should be executed based on some arbitrary characteristic of the request. Views are associated with modes in the Maverick configuration, and the Shunt is responsible for identifying the proper mode based on the request.
The canonical example of a Shunt is the LanguageShunt, which uses the Accept-Language header to choose among views with modes like "en", "fr", etc. More complicated Shunts might allow regexes or other sophisticated expressions in the mode string.
Individual Shunt instances are associated with a particular view name, so there can be many modes for each of "success", "error", etc.
As the Maverick config file is loaded, Shunts are created and modes are defined with defineMode(). Then, during execution, getView() is called. Thus, defineMode() can be slow, but geView() should be fast.
Method Summary | |
void |
defineMode(java.lang.String mode,
View v)
As the Maverick config file is loaded, this method will be called to associate modes with particular views. |
View |
getView(javax.servlet.http.HttpServletRequest request)
This is called during runtime to obtain a view based on some arbitrary characteristic of the request. |
Method Detail |
public void defineMode(java.lang.String mode, View v) throws ConfigException
mode
- The mode associated with this view. Can be null.
ConfigException
- If modes clash (such as a duplicate mode).public View getView(javax.servlet.http.HttpServletRequest request) throws NoSuitableModeException
request
- The state of the request is used to determine the proper mode.
NoSuitableModeException
- if the shunt could not pick a view from the
modes which were defined.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |