SMILA (incubation) API documentation

org.eclipse.smila.http.server.util
Class ARequestHandler

java.lang.Object
  extended by org.eclipse.smila.http.server.util.ARequestHandler
All Implemented Interfaces:
HttpHandler, RequestHandler

public abstract class ARequestHandler
extends java.lang.Object
implements RequestHandler

Abstract base class for RequestHandler implementations. Provides methods to access the properties of the ComponentContext and a implementation for method match();


Constructor Summary
ARequestHandler()
           
 
Method Summary
protected  void activate(ComponentContext context)
          OSGi Declarative Services service activation method.
 java.util.List<java.lang.String> getDynamicUriParts(java.lang.String requestUri)
          return the dynamic parts of the URL as defined by the URI pattern.
 java.lang.String getRootContextPath()
          
 java.lang.String getStaticUriParts(java.lang.String requestUri)
          Return static part of request uri (depends on uri pattern of http handler).
 java.lang.String getUriPattern()
          Return the URI pattern below the root context path that this RequestHandler serves.
 boolean matches(java.lang.String requestUri)
          Checks if the URI pattern matches the given requestUri.
protected  java.lang.String urlDecode(java.lang.String urlPart)
          decode a part of an URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.smila.http.server.HttpHandler
handle
 

Constructor Detail

ARequestHandler

public ARequestHandler()
Method Detail

getRootContextPath

public final java.lang.String getRootContextPath()

Specified by:
getRootContextPath in interface HttpHandler
Returns:
the URI path this handler is invoked for.

getUriPattern

public final java.lang.String getUriPattern()
Return the URI pattern below the root context path that this RequestHandler serves.

Specified by:
getUriPattern in interface RequestHandler
Returns:
the URI pattern (a regular expression)

matches

public final boolean matches(java.lang.String requestUri)
Checks if the URI pattern matches the given requestUri. If true the RequestHandler can handle requests to this URI.

Specified by:
matches in interface RequestHandler
Parameters:
requestUri - a requestUri
Returns:
true if the URI pattern matches, false otherwise

getDynamicUriParts

public final java.util.List<java.lang.String> getDynamicUriParts(java.lang.String requestUri)
return the dynamic parts of the URL as defined by the URI pattern. All result values are already URL-decoded.

Parameters:
requestUri - request URI
Returns:
dynamic URI parts.

getStaticUriParts

public final java.lang.String getStaticUriParts(java.lang.String requestUri)
Return static part of request uri (depends on uri pattern of http handler). The result is URL-decoded.

Parameters:
requestUri - e.g. "http://localhost:8050/SMILA/handler/todo/"
Returns:
static part, e.g. "SMILA/handler/", if dynamic part is "todo/"

activate

protected void activate(ComponentContext context)
OSGi Declarative Services service activation method. Must be explicitly called of the subclass implements its own activation method.

Parameters:
context - OSGi service component context.

urlDecode

protected java.lang.String urlDecode(java.lang.String urlPart)
decode a part of an URL. Try to use UTF-8 encoding, if that doesn't work, fallback to platform default encoding.

Parameters:
urlPart - part of a request URL
Returns:
urlPart in decoded form

SMILA (incubation) API documentation