public class FallbackRouter extends CapturingRouter
Router
that takes care to bunch identical routes under
Fallback
restlets. This is very useful for allowing multiple restlets
a chance to handle a request, while "falling back" to subsequent restlets
when those "fail."
Router.detach(Restlet)
is overriden to support un-bunching.
MODE_BEST_MATCH, MODE_CUSTOM, MODE_FIRST_MATCH, MODE_LAST_MATCH, MODE_NEXT_MATCH, MODE_RANDOM_MATCH
Constructor and Description |
---|
FallbackRouter(Context context)
Constructs a fallback router with a default cache duration of 5 seconds.
|
FallbackRouter(Context context,
int cacheDuration)
Constructs a fallback router.
|
Modifier and Type | Method and Description |
---|---|
TemplateRoute |
attachFallback(String pathTemplate,
Restlet target) |
void |
detach(Restlet target) |
int |
getCacheDuration()
The default cache duration for
Fallback instances, in
milliseconds. |
void |
setCacheDuration(int cacheDuration)
The default cache duration for
Fallback instances, in
milliseconds. |
capture, captureOther, createRoute
toString
attach, attach, attach, attach, attach, attach, attachDefault, attachDefault, createRoute, detach, doHandle, getCustom, getDefaultMatchingMode, getDefaultMatchingQuery, getDefaultRoute, getMatchingMode, getMaxAttempts, getNext, getRequiredScore, getRetryDelay, getRoutes, getRoutingMode, handle, logRoute, redirectPermanent, redirectSeeOther, redirectTemporary, setDefaultMatchingMode, setDefaultMatchingQuery, setDefaultRoute, setMaxAttempts, setRequiredScore, setRetryDelay, setRoutes, setRoutingMode, start, stop
createFinder, finalize, getApplication, getAuthor, getContext, getDescription, getFinderClass, getLogger, getName, getOwner, handle, handle, handle, isStarted, isStopped, setAuthor, setContext, setDescription, setFinderClass, setName, setOwner
public FallbackRouter(Context context)
context
- The contextpublic int getCacheDuration()
Fallback
instances, in
milliseconds.Fallback.getCacheDuration()
public void setCacheDuration(int cacheDuration)
Fallback
instances, in
milliseconds. (Modifiable by concurrent threads.)cacheDuration
- The cache duration, in millisecondsFallback.setCacheDuration(int)
public TemplateRoute attachFallback(String pathTemplate, Restlet target)
pathTemplate
- The URI path template that must match the relative part of the
resource URI.target
- The target Restlet to attach.Copyright © 2009-2016 Three Crickets LLC.