|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mortbay.component.AbstractLifeCycle
org.mortbay.jetty.handler.AbstractHandler
org.mortbay.jetty.handler.AbstractHandlerContainer
org.mortbay.jetty.handler.HandlerWrapper
org.mortbay.jetty.handler.rewrite.RewriteHandler
public class RewriteHandler
The RewriteHandler is responsible for managing a list of rules to be applied to requests. Its capabilities are not only limited to url rewrites such as RewritePatternRule or RewriteRegexRule; there is also handling for cookies, headers, redirection, setting status or error codes whenever the rule finds a match.
The rules can be matched by the ff. options: pattern matching of PathMap (class PatternRule), regular expressions (class RegexRule) or certain conditions set (e.g. MsieSslRule - the requests must be in SSL mode). Here are the list of rules:
The rules can be grouped into rule containers (class RuleContainerRule), and will only be applied if the request matches the conditions for their container (e.g., by virtual host name) Here are a list of rule containers:
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.mortbay.component.LifeCycle |
---|
LifeCycle.Listener |
Field Summary |
---|
Fields inherited from class org.mortbay.jetty.handler.AbstractHandler |
---|
_string |
Fields inherited from class org.mortbay.component.AbstractLifeCycle |
---|
_listeners |
Fields inherited from interface org.mortbay.jetty.Handler |
---|
ALL, DEFAULT, ERROR, FORWARD, INCLUDE, REQUEST |
Constructor Summary | |
---|---|
RewriteHandler()
|
Method Summary | |
---|---|
void |
addRewriteRule(java.lang.String pattern,
java.lang.String prefix)
Deprecated. |
void |
addRule(Rule rule)
Add a Rule |
java.lang.String |
getOriginalPathAttribute()
|
PathMap |
getRewrite()
Deprecated. |
Rule[] |
getRules()
Returns the list of rules. |
void |
handle(java.lang.String target,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
int dispatch)
Handle a request. |
boolean |
isRewritePathInfo()
|
boolean |
isRewriteRequestURI()
|
void |
setLegacyRule(LegacyRule legacyRule)
To enable configuration from jetty.xml on rewriteRequestURI, rewritePathInfo and originalPathAttribute |
void |
setOriginalPathAttribute(java.lang.String originalPathAttribute)
|
void |
setRewrite(PathMap rewrite)
Deprecated. |
void |
setRewritePathInfo(boolean rewritePathInfo)
|
void |
setRewriteRequestURI(boolean rewriteRequestURI)
|
void |
setRules(Rule[] rules)
Assigns the rules to process. |
void |
setRules(RuleContainer rules)
Assigns the rules to process. |
Methods inherited from class org.mortbay.jetty.handler.HandlerWrapper |
---|
addHandler, doStart, doStop, expandChildren, getHandler, removeHandler, setHandler, setServer |
Methods inherited from class org.mortbay.jetty.handler.AbstractHandlerContainer |
---|
expandHandler, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass |
Methods inherited from class org.mortbay.jetty.handler.AbstractHandler |
---|
destroy, getServer, toString |
Methods inherited from class org.mortbay.component.AbstractLifeCycle |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.mortbay.component.LifeCycle |
---|
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop |
Constructor Detail |
---|
public RewriteHandler()
Method Detail |
---|
public void setLegacyRule(LegacyRule legacyRule)
legacyRule
- old style rewrite rulepublic Rule[] getRules()
Rule
.public void setRules(Rule[] rules)
rules
- an array of Rule
.public void setRules(RuleContainer rules)
rules
- a RuleContainer
containing other rules to processpublic void addRule(Rule rule)
rule
- The rule to add to the end of the rules arraypublic boolean isRewriteRequestURI()
HttpServletRequest.getRequestURI()
.public void setRewriteRequestURI(boolean rewriteRequestURI)
rewriteRequestURI
- true if this handler will rewrite the value
returned by HttpServletRequest.getRequestURI()
.public boolean isRewritePathInfo()
HttpServletRequest.getPathInfo()
.public void setRewritePathInfo(boolean rewritePathInfo)
rewritePathInfo
- true if this handler will rewrite the value
returned by HttpServletRequest.getPathInfo()
.public java.lang.String getOriginalPathAttribute()
public void setOriginalPathAttribute(java.lang.String originalPathAttribute)
originalPathAttribute
- If non null, this string will be used
as the attribute name to store the original request path.public PathMap getRewrite()
public void setRewrite(PathMap rewrite)
public void addRewriteRule(java.lang.String pattern, java.lang.String prefix)
public void handle(java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int dispatch) throws java.io.IOException, javax.servlet.ServletException
Handler
handle
in interface Handler
handle
in class HandlerWrapper
target
- The target of the request - either a URI or a name.request
- The request either as the Request
object or a wrapper of that request. The HttpConnection.getCurrentConnection()
method can be used access the Request object if required.response
- The response as the Response
object or a wrapper of that request. The HttpConnection.getCurrentConnection()
method can be used access the Response object if required.dispatch
- The dispatch mode: Handler.REQUEST
, Handler.FORWARD
, Handler.INCLUDE
, Handler.ERROR
java.io.IOException
javax.servlet.ServletException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |