public class PrudenceRouter extends FallbackRouter
Router
with shortcut methods. Inherits all functionality from
FallbackRouter
, CapturingRouter
and ResolvingRouter
.MODE_BEST_MATCH, MODE_CUSTOM, MODE_FIRST_MATCH, MODE_LAST_MATCH, MODE_NEXT_MATCH, MODE_RANDOM_MATCH
Constructor and Description |
---|
PrudenceRouter(Context context)
Constructs a Prudence router with a default
Fallback cache
duration of 5 seconds. |
PrudenceRouter(Context context,
int cacheDuration)
Constructs a Prudence router.
|
Modifier and Type | Method and Description |
---|---|
TemplateRoute |
attach(String uriTemplate,
String targetClassName)
Attach a
ServerResource with the specified class name. |
TemplateRoute |
attachBase(String uriTemplate,
Restlet target)
As
Router.attach(String, Restlet) , but enforces matching mode
Template.MODE_STARTS_WITH . |
TemplateRoute |
attachBase(String uriTemplate,
String targetClassName)
As
attach(String, String) , but enforces matching mode
Template.MODE_STARTS_WITH . |
TemplateRoute |
capture(String uriTemplate,
String internalUriTemplate)
As
CapturingRouter.capture(String, String, boolean) , with capturing of query. |
TemplateRoute |
captureAndHide(String uriTemplate,
String internalUriTemplate)
As
captureAndHide(String, String, boolean) , with capturing of
query. |
TemplateRoute |
captureAndHide(String uriTemplate,
String internalUriTemplate,
boolean captureQuery)
Shortcut for calling
capture(String, String) and
hide(String) . |
TemplateRoute |
captureBase(String uriTemplate,
String internalUriTemplate)
As
captureBase(String, String, boolean) , with capturing of
query. |
TemplateRoute |
captureBase(String uriTemplate,
String internalUriTemplate,
boolean captureQuery)
As
capture(String, String) , but enforces matching mode
Template.MODE_STARTS_WITH . |
TemplateRoute |
captureOther(String uriTemplate,
String application,
String internalUriTemplate)
As
CapturingRouter.captureOther(String, String, String, boolean) , with capturing
of query. |
TemplateRoute |
captureOtherAndHide(String uriTemplate,
String application,
String internalUriTemplate)
Shortcut for calling
captureOther(String, String, String) and
hide(String) . |
void |
handle(Request request,
Response response) |
void |
hide(String uriTemplate)
Sets the URI template to always return
Status.CLIENT_ERROR_NOT_FOUND . |
void |
hide(String uriTemplate,
int mode)
Sets the URI template to always return
Status.CLIENT_ERROR_NOT_FOUND . |
TemplateRoute |
reattach(String uriTemplate,
Restlet target)
As
Router.attach(String, Restlet) , but detaches the target first. |
TemplateRoute |
reattachBase(String uriTemplate,
Restlet target)
As
reattach(String, Restlet) , but enforces matching mode
Template.MODE_STARTS_WITH . |
TemplateRoute |
redirectClient(String uriTemplate,
String targetUriTemplate)
Redirects a URI to a new URI with HTTP status 307 ("temporary").
|
TemplateRoute |
redirectClient(String uriTemplate,
String targetUriTemplate,
int statusCode)
Redirects a URI to a new URI.
|
TemplateRoute |
redirectClientBase(String uriTemplate,
String targetUriTemplate)
As
redirectClient(String, String) , but enforces matching mode
Template.MODE_STARTS_WITH . |
TemplateRoute |
redirectClientBase(String uriTemplate,
String targetUriTemplate,
int statusCode)
As
redirectClient(String, String, int) , but enforces matching
mode Template.MODE_STARTS_WITH . |
attachFallback, detach, getCacheDuration, setCacheDuration
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, 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 PrudenceRouter(Context context)
Fallback
cache
duration of 5 seconds.context
- The contextpublic TemplateRoute attach(String uriTemplate, String targetClassName) throws ClassNotFoundException, ClassCastException
ServerResource
with the specified class name. The class
is loaded using this class's class loader.uriTemplate
- The URI path template that must match the relative part of the
resource URItargetClassName
- The target Resource class to attachClassNotFoundException
- If the named class was not foundClassCastException
- If the class does not extend ServerResourceRouter.attach(String, Class)
public TemplateRoute attachBase(String uriTemplate, String targetClassName) throws ClassNotFoundException
attach(String, String)
, but enforces matching mode
Template.MODE_STARTS_WITH
.uriTemplate
- The URI path template that must match the relative part of the
resource URItargetClassName
- The target Resource class to attachClassNotFoundException
- If the named class was not foundRouter.attach(String, Class)
public TemplateRoute attachBase(String uriTemplate, Restlet target)
Router.attach(String, Restlet)
, but enforces matching mode
Template.MODE_STARTS_WITH
.uriTemplate
- The URI path template that must match the relative part of the
resource URItarget
- The target Restlet to attachpublic TemplateRoute reattach(String uriTemplate, Restlet target)
Router.attach(String, Restlet)
, but detaches the target first. The
URI path template that must match the relative part of the resource URIuriTemplate
- The URI path template that must match the relative part of the
resource URItarget
- The target Restlet to attachpublic TemplateRoute reattachBase(String uriTemplate, Restlet target)
reattach(String, Restlet)
, but enforces matching mode
Template.MODE_STARTS_WITH
.uriTemplate
- The URI path template that must match the relative part of the
resource URItarget
- The target Restlet to attachpublic TemplateRoute redirectClient(String uriTemplate, String targetUriTemplate)
Enforces matching mode Template.MODE_EQUALS
.
This is handled via a NormalizingRedirector
.
uriTemplate
- The URI path template that must match the relative part of the
resource URItargetUriTemplate
- The target URI templateNormalizingRedirector
public TemplateRoute redirectClientBase(String uriTemplate, String targetUriTemplate)
redirectClient(String, String)
, but enforces matching mode
Template.MODE_STARTS_WITH
.uriTemplate
- The URI path template that must match the relative part of the
resource URItargetUriTemplate
- The target URI templateNormalizingRedirector
public TemplateRoute redirectClient(String uriTemplate, String targetUriTemplate, int statusCode)
Enforces matching mode Template.MODE_EQUALS
.
This is handled via a NormalizingRedirector
.
uriTemplate
- The URI path template that must match the relative part of the
resource URItargetUriTemplate
- The target URI templatestatusCode
- HTTP status code (must be 301, 302, 303 or 307)NormalizingRedirector
public TemplateRoute redirectClientBase(String uriTemplate, String targetUriTemplate, int statusCode)
redirectClient(String, String, int)
, but enforces matching
mode Template.MODE_STARTS_WITH
.uriTemplate
- The URI path template that must match the relative part of the
resource URItargetUriTemplate
- The target URI templatestatusCode
- HTTP status code (must be 301, 302, 303 or 307)NormalizingRedirector
public TemplateRoute capture(String uriTemplate, String internalUriTemplate)
CapturingRouter.capture(String, String, boolean)
, with capturing of query.uriTemplate
- The URI path template that must match the relative part of the
resource URIinternalUriTemplate
- The internal URI path to which we will redirectpublic TemplateRoute captureBase(String uriTemplate, String internalUriTemplate, boolean captureQuery)
capture(String, String)
, but enforces matching mode
Template.MODE_STARTS_WITH
.uriTemplate
- The URI path template that must match the relative part of the
resource URIinternalUriTemplate
- The internal URI path to which we will redirectcaptureQuery
- Whether to capture the query, toopublic TemplateRoute captureBase(String uriTemplate, String internalUriTemplate)
captureBase(String, String, boolean)
, with capturing of
query.uriTemplate
- The URI path template that must match the relative part of the
resource URIinternalUriTemplate
- The internal URI path to which we will redirectpublic TemplateRoute captureAndHide(String uriTemplate, String internalUriTemplate, boolean captureQuery)
capture(String, String)
and
hide(String)
.uriTemplate
- The URI path template that must match the relative part of the
resource URIinternalUriTemplate
- The internal URI path to which we will redirectcaptureQuery
- Whether to capture the query, toopublic TemplateRoute captureAndHide(String uriTemplate, String internalUriTemplate)
captureAndHide(String, String, boolean)
, with capturing of
query.uriTemplate
- The URI path template that must match the relative part of the
resource URIinternalUriTemplate
- The internal URI path to which we will redirectpublic TemplateRoute captureOther(String uriTemplate, String application, String internalUriTemplate)
CapturingRouter.captureOther(String, String, String, boolean)
, with capturing
of query.uriTemplate
- The URI path template that must match the relative part of the
resource URIapplication
- The internal application nameinternalUriTemplate
- The internal URI path to which we will redirectpublic TemplateRoute captureOtherAndHide(String uriTemplate, String application, String internalUriTemplate)
captureOther(String, String, String)
and
hide(String)
.uriTemplate
- The URI path template that must match the relative part of the
resource URIapplication
- The internal application nameinternalUriTemplate
- The internal URI path to which we will redirectpublic void hide(String uriTemplate)
Status.CLIENT_ERROR_NOT_FOUND
. Note that if there really is a
restlet attached to the URI template, it might still be available via
other routes.
Hiding purposely does not affect the RIAP protocol.
uriTemplate
- The URI path template that must match the resource URIpublic void hide(String uriTemplate, int mode)
Status.CLIENT_ERROR_NOT_FOUND
. Note that if there really is a
restlet attached to the URI template, it might still be available via
other routes.
Hiding purposely does not affect the RIAP protocol.
uriTemplate
- The URI path template that must match the resource URImode
- The matching mode (Template.MODE_EQUALS
or
Template.MODE_STARTS_WITH
)Copyright © 2009-2016 Three Crickets LLC.