org.eclipse.jetty.rewrite.handler
Class RegexTargetHandler

java.lang.Object
  extended by org.eclipse.jetty.util.component.AbstractLifeCycle
      extended by org.eclipse.jetty.util.component.AggregateLifeCycle
          extended by org.eclipse.jetty.server.handler.AbstractHandler
              extended by org.eclipse.jetty.server.handler.AbstractHandlerContainer
                  extended by org.eclipse.jetty.server.handler.HandlerWrapper
                      extended by org.eclipse.jetty.server.handler.ScopedHandler
                          extended by org.eclipse.jetty.rewrite.handler.RegexTargetHandler
All Implemented Interfaces:
Handler, HandlerContainer, Destroyable, Dumpable, LifeCycle

public class RegexTargetHandler
extends ScopedHandler

A handle that uses regular expressions to select the target.

This handler applies a list of regex to target name mappings to the URIs of requests. If the regex matches the URI, then the mapped target name is used in the nested call to doScope(String, Request, HttpServletRequest, HttpServletResponse).

This handler should be installed as the first handler in a Context. It can be configured either with direct calls to addPatternTarget(String, String) or by setting the context init parameters "org.eclipse.jetty.rewrite.handler.REGEX_MAPPINGS" to a comma separated list of strings in the format regex==target.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener
 
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
 
Field Summary
static String REGEX_MAPPINGS
           
 
Fields inherited from class org.eclipse.jetty.server.handler.ScopedHandler
_nextScope, _outerScope
 
Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
_handler
 
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
 
Constructor Summary
RegexTargetHandler()
           
 
Method Summary
 void addPatternTarget(String pattern, String target)
          Add a pattern to target mapping.
 void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
           
 void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
           
protected  void doStart()
          Start the managed lifecycle beans in the order they were added.
 void dump(Appendable out, String indent)
           
 
Methods inherited from class org.eclipse.jetty.server.handler.ScopedHandler
handle, never, nextHandle, nextScope
 
Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
destroy, doStop, expandChildren, getHandler, getHandlers, getNestedHandlerByClass, setHandler, setServer
 
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass
 
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
dumpThis, getServer
 
Methods inherited from class org.eclipse.jetty.util.component.AggregateLifeCycle
addBean, addBean, contains, dump, dump, dump, dump, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
 
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
 

Field Detail

REGEX_MAPPINGS

public static final String REGEX_MAPPINGS
See Also:
Constant Field Values
Constructor Detail

RegexTargetHandler

public RegexTargetHandler()
Method Detail

addPatternTarget

public void addPatternTarget(String pattern,
                             String target)
Add a pattern to target mapping.

Parameters:
pattern - The regular expression pattern to match.
target - The target (normally servlet name) to handle the request

doStart

protected void doStart()
                throws Exception
Description copied from class: AggregateLifeCycle
Start the managed lifecycle beans in the order they were added.

Overrides:
doStart in class ScopedHandler
Throws:
Exception
See Also:
HandlerWrapper.doStart()

doScope

public void doScope(String target,
                    Request baseRequest,
                    HttpServletRequest request,
                    HttpServletResponse response)
             throws IOException,
                    ServletException
Specified by:
doScope in class ScopedHandler
Throws:
IOException
ServletException

doHandle

public void doHandle(String target,
                     Request baseRequest,
                     HttpServletRequest request,
                     HttpServletResponse response)
              throws IOException,
                     ServletException
Specified by:
doHandle in class ScopedHandler
Throws:
IOException
ServletException

dump

public void dump(Appendable out,
                 String indent)
          throws IOException
Specified by:
dump in interface Dumpable
Overrides:
dump in class AbstractHandlerContainer
Throws:
IOException


Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.