|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.Uniform
org.restlet.Restlet
org.restlet.Redirector
public class Redirector
Rewrites URIs then redirects the call or the client to a new destination.
There are various redirection modes that you can choose from: client-side
redirections (MODE_CLIENT_FOUND
, MODE_CLIENT_PERMANENT
,
MODE_CLIENT_SEE_OTHER
, MODE_CLIENT_TEMPORARY
) or
server-side redirections, similar to a reverse proxy (
MODE_DISPATCHER
).
Concurrency note: instances of this class or its subclasses can be invoked by
several threads at the same time and therefore must be thread-safe. You
should be especially careful when storing state in member variables.
Template
,
Tutorial:
URI rewriting and redirectionField Summary | |
---|---|
protected int |
mode
The redirection mode. |
static int |
MODE_CLIENT_FOUND
In this mode, the client is simply redirected to the URI generated from the target URI pattern. See org.restlet.data.Status.REDIRECTION_FOUND. |
static int |
MODE_CLIENT_PERMANENT
In this mode, the client is permanently redirected to the URI generated from the target URI pattern. See org.restlet.data.Status.REDIRECTION_PERMANENT. |
static int |
MODE_CLIENT_SEE_OTHER
In this mode, the client is simply redirected to the URI generated from the target URI pattern. See org.restlet.data.Status.REDIRECTION_SEE_OTHER. |
static int |
MODE_CLIENT_TEMPORARY
In this mode, the client is temporarily redirected to the URI generated from the target URI pattern. See org.restlet.data.Status.REDIRECTION_TEMPORARY. |
static int |
MODE_DISPATCHER
In this mode, the call is sent to the context's dispatcher. |
protected java.lang.String |
targetTemplate
The target URI pattern. |
Constructor Summary | |
---|---|
Redirector(Context context,
java.lang.String targetTemplate)
Constructor for the dispatcher mode. |
|
Redirector(Context context,
java.lang.String targetPattern,
int mode)
Constructor. |
Method Summary | |
---|---|
int |
getMode()
Returns the redirection mode. |
protected Reference |
getTargetRef(Request request,
Response response)
Returns the target reference to redirect to. |
java.lang.String |
getTargetTemplate()
Returns the target URI pattern. |
void |
handle(Request request,
Response response)
Handles a call by redirecting using the selected redirection mode. |
protected void |
redirectDispatcher(Reference targetRef,
Request request,
Response response)
Redirects a given call to a target reference. |
protected Representation |
rewrite(Representation initialEntity)
Optionnaly rewrites the response entity returned in the MODE_CONNECTOR mode. |
void |
setMode(int mode)
Sets the redirection mode. |
void |
setTargetTemplate(java.lang.String targetTemplate)
Sets the target URI pattern. |
Methods inherited from class org.restlet.Restlet |
---|
getApplication, getContext, getLogger, init, isStarted, isStopped, setContext, start, stop |
Methods inherited from class org.restlet.Uniform |
---|
delete, delete, get, get, handle, head, head, options, options, post, post, put, put |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MODE_CLIENT_PERMANENT
public static final int MODE_CLIENT_FOUND
public static final int MODE_CLIENT_SEE_OTHER
public static final int MODE_CLIENT_TEMPORARY
public static final int MODE_DISPATCHER
protected volatile java.lang.String targetTemplate
protected volatile int mode
Constructor Detail |
---|
public Redirector(Context context, java.lang.String targetTemplate)
context
- The context.targetTemplate
- The template to build the target URI.Template
public Redirector(Context context, java.lang.String targetPattern, int mode)
context
- The context.targetPattern
- The pattern to build the target URI (using StringTemplate
syntax and the CallModel for variables).mode
- The redirection mode.Method Detail |
---|
public int getMode()
protected Reference getTargetRef(Request request, Response response)
request
- The request to handle.response
- The response to update.
public java.lang.String getTargetTemplate()
public void handle(Request request, Response response)
handle
in class Restlet
request
- The request to handle.response
- The response to update.protected void redirectDispatcher(Reference targetRef, Request request, Response response)
targetRef
- The target reference with URI variables resolved.request
- The request to handle.response
- The response to update.protected Representation rewrite(Representation initialEntity)
initialEntity
- The initial entity returned.
public void setMode(int mode)
mode
- The redirection mode.public void setTargetTemplate(java.lang.String targetTemplate)
targetTemplate
- The target URI pattern.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |