org.norther.tammi.spray.protocol.chain
Interface ProtocolExtension

All Superinterfaces:
Extension
All Known Implementing Classes:
AbstractProtocolRequest.ProtocolRequestExtension

public interface ProtocolExtension
extends Extension

An interface to a protocol specific extension of a servlet request. It is saved as a request attribute using its class name.

Version:
$Id: ProtocolExtension.java,v 1.32 2010-03-30 16:01:28 cvsimp Exp $
Author:
Ilkka Priha

Nested Class Summary
static class ProtocolExtension.Encoding
          Encoding of linked URLs.
static class ProtocolExtension.Relativity
          Relativity of linked URLs.
 
Field Summary
static String KEY
          The extension key.
 
Method Summary
 void encodeLinkedURL(StringBuilder builder, ProtocolExtension.Encoding encoding)
          Encodes the linked URL as specified.
 StringBuilder getLinkedURL(String location, OrderedMap<String,Object> info)
          Gets a URL link to the specified location with additional URL parameters.
 StringBuilder getLinkedURL(String location, ProtocolExtension.Relativity relativity, OrderedMap<String,Object> info)
          Gets an optionally absolute URL link to the specified location with additional URL parameters.
 StringBuilder getLinkedURL(String location, ProtocolExtension.Relativity relativity, String... info)
          Gets an optionally absolute URL link to the specified location.
 StringBuilder getLinkedURL(String location, String... info)
          Gets a URL link to the specified location.
 int getMaxAge()
          Gets the max caching age of pages in clients.
 String getPathTail()
          Gets the tail of the path info without parsed and requested parameters.
 StringBuilder getRedirectedURL(boolean secure, String... info)
          Gets a redirected URL link, which is either secure or non-secure.
 StringBuilder getRedirectedURL(String location, boolean secure, OrderedMap<String,Object> info)
          Gets a redirected URL link with additional URL parameters, which is either secure or non-secure.
 StringBuilder getRedirectedURL(String location, boolean secure, String... info)
          Gets a redirected URL link, which is either secure or non-secure.
 StringBuilder getRedirectedURL(String host, int port, String location, boolean secure, OrderedMap<String,Object> info)
          Gets a redirected URL link with additional URL parameters to the specified host and/or port, which is either secure or non-secure.
 StringBuilder getRedirectedURL(String host, int port, String location, boolean secure, String... info)
          Gets a redirected URL link to a specific host and/or port, which is either secure or non-secure.
 StringBuilder getRedirectedURL(String location, OrderedMap<String,Object> info)
          Gets a redirected URL link with additional URL parameters.
 StringBuilder getRedirectedURL(String location, String... info)
          Gets a redirected URL link to the specified location.
 int getRedirectionCode()
          Gets the redirection code to apply for this request.
 String getRedirectionURL()
          Gets the redirection URL of this request.
 HttpFilter.SessionIdPolicy getSessionIdPolicy()
          Gets the session id policy.
 int getStatus()
          Gets the status code of the response.
 String getURLAuthentication()
          Gets the URL authentication of this request.
 Principal getUserPrincipal()
          Gets the authenticated principal that is registered to the session of this request.
 boolean isAbsoluteURLLinks()
          Gets the absolute URL links option.
 boolean isNoCache()
          Checks whether caching of pages in clients is on or off.
 boolean isPathInfoParsed()
          Gets the path info to be parsed as parameters option.
 boolean isRedirection()
          Checks whether this request is a redirection.
 boolean isUnparsedPath()
          Checks whether the path info doesn't contain any parsed and requested parameters.
 HttpSession registerUserPrincipal(Principal principal)
          Registers the authenticated principal to the session of this request.
 void setMaxAge(int secs)
          Sets the max caching age of pages in clients.
 void setNoCache(boolean flag)
          Sets whether caching of pages in clients is on or off.
 void setNoCache(boolean flag, long expires)
          Sets whether caching of pages in clients is on or off with expiration.
 void setRedirection(boolean flag)
          Sets whether this request is a redirection.
 void setRedirectionURL(String url)
          Sets the redirection URL of this request.
 void setStatus(int code)
          Sets the status code of the response.
 

Field Detail

KEY

static final String KEY
The extension key.

Method Detail

getPathTail

String getPathTail()
Gets the tail of the path info without parsed and requested parameters.

Returns:
the path tail or null.

isUnparsedPath

boolean isUnparsedPath()
Checks whether the path info doesn't contain any parsed and requested parameters.

Returns:
true if unparsed, false otherwise.

isRedirection

boolean isRedirection()
Checks whether this request is a redirection.

Returns:
true if a redirection, otherwise false.

setRedirection

void setRedirection(boolean flag)
Sets whether this request is a redirection.

Parameters:
flag - true if a redirection, otherwise false.

getRedirectionURL

String getRedirectionURL()
Gets the redirection URL of this request.

Returns:
the redirection URL or null.

setRedirectionURL

void setRedirectionURL(String url)
Sets the redirection URL of this request.

Parameters:
url - the redirection URL.

getRedirectionCode

int getRedirectionCode()
Gets the redirection code to apply for this request.

Returns:
the redirection status code.

getURLAuthentication

String getURLAuthentication()
Gets the URL authentication of this request.

Returns:
the URL authentication or null,

isAbsoluteURLLinks

boolean isAbsoluteURLLinks()
Gets the absolute URL links option.

Returns:
the absolute URL links option.

isPathInfoParsed

boolean isPathInfoParsed()
Gets the path info to be parsed as parameters option.

Returns:
the path info parsed option.

getSessionIdPolicy

HttpFilter.SessionIdPolicy getSessionIdPolicy()
Gets the session id policy.

Returns:
the session id policy.

getLinkedURL

StringBuilder getLinkedURL(String location,
                           String... info)
Gets a URL link to the specified location. The returned URL is either absolute or relative depending on the server configuration of URL links. The location parameter must be properly encoded in advance.

If the location is an absolute URL, it is converted into a string buffer as such.

An absolute path is appended to the context URL of the current request. The authority component is included if URL links are configured to be absolute.

A relative path is appended to the context URL after the path info parameters of linked key filters or before the corresponding query string parameters depending on the configuration.

Parameters:
location - the encoded location of the link.
info - an array of unencoded URL parameters.
Returns:
the encoded link URL.

getLinkedURL

StringBuilder getLinkedURL(String location,
                           ProtocolExtension.Relativity relativity,
                           String... info)
Gets an optionally absolute URL link to the specified location.

Parameters:
location - the encoded location of the link.
relativity - the relativity of the location.
info - an array of unencoded URL parameters.
Returns:
the encoded link URL.

getLinkedURL

StringBuilder getLinkedURL(String location,
                           OrderedMap<String,Object> info)
Gets a URL link to the specified location with additional URL parameters. The returned URL is either absolute or relative depending on the server configuration of URL links. The location parameter must be properly encoded in advance.

Applied parameters from linked key filters are inserted to the URL parameter map, if any.

Parameters:
location - the encoded location of the link.
info - a map of unencoded URL parameters.
Returns:
the encoded link URL.

getLinkedURL

StringBuilder getLinkedURL(String location,
                           ProtocolExtension.Relativity relativity,
                           OrderedMap<String,Object> info)
Gets an optionally absolute URL link to the specified location with additional URL parameters.

Parameters:
location - the encoded location of the link.
relativity - the relativity of the location.
info - a map of unencoded URL parameters.
Returns:
the encoded link URL.

getRedirectedURL

StringBuilder getRedirectedURL(boolean secure,
                               String... info)
Gets a redirected URL link, which is either secure or non-secure. The location is the URL of the current request.

Parameters:
secure - true for a secure link, false otherwise.
info - an array of unencoded URL parameters.
Returns:
the encoded redirection URL.

getRedirectedURL

StringBuilder getRedirectedURL(String location,
                               String... info)
Gets a redirected URL link to the specified location. The returned URL is always absolute as e.g. WAP doesn't accept relative redirections. The location must be properly encoded in advance.

If the location is an absolute URL, it is converted into a string buffer as such.

An absolute path is appended to the servlet URL of the current request.

A relative path is appended to the servlet URL after the path info parameters of linked key filters or before the corresponding query string parameters depending on the configuration.

Parameters:
location - the encoded location of the link.
info - an array of unencoded URL parameters.
Returns:
the encoded redirection URL.

getRedirectedURL

StringBuilder getRedirectedURL(String location,
                               OrderedMap<String,Object> info)
Gets a redirected URL link with additional URL parameters. The location must be properly encoded in advance.

Applied parameters from linked key filters are inserted to the URL parameter map, if any.

Parameters:
location - the encoded location of the link.
info - a map of unencoded URL parameters.
Returns:
the encoded redirection URL.

getRedirectedURL

StringBuilder getRedirectedURL(String location,
                               boolean secure,
                               String... info)
Gets a redirected URL link, which is either secure or non-secure. The location must be properly encoded in advance.

Parameters:
location - the encoded location of the link.
secure - true for a secure link, false otherwise.
info - an array of unencoded URL parameters.
Returns:
the encoded redirection URL.

getRedirectedURL

StringBuilder getRedirectedURL(String location,
                               boolean secure,
                               OrderedMap<String,Object> info)
Gets a redirected URL link with additional URL parameters, which is either secure or non-secure. The location must be properly encoded in advance.

Applied parameters from linked key filters are inserted to the URL parameter map, if any.

Parameters:
location - the encoded location of the link.
secure - true for a secure link, false otherwise.
info - a map of unencoded URL parameters.
Returns:
the encoded redirection URL.

getRedirectedURL

StringBuilder getRedirectedURL(String host,
                               int port,
                               String location,
                               boolean secure,
                               String... info)
Gets a redirected URL link to a specific host and/or port, which is either secure or non-secure. The location must be properly encoded in advance.

Parameters:
host - the optional server name of the link.
port - the port number of the link (0 for current).
location - the encoded location of the link.
secure - true for a secure link, false otherwise.
info - an array of unencoded URL parameters.
Returns:
the encoded redirection URL.

getRedirectedURL

StringBuilder getRedirectedURL(String host,
                               int port,
                               String location,
                               boolean secure,
                               OrderedMap<String,Object> info)
Gets a redirected URL link with additional URL parameters to the specified host and/or port, which is either secure or non-secure. The location parameter must be properly encoded in advance.

Applied parameters from linked key filters are inserted to the URL parameter map, if any.

Parameters:
host - the optional server name of the link.
port - the port number of the link (0 for current).
location - the encoded location of the link.
secure - true for a secure link, false otherwise.
info - a map of unencoded URL parameters.
Returns:
the encoded redirection URL.

encodeLinkedURL

void encodeLinkedURL(StringBuilder builder,
                     ProtocolExtension.Encoding encoding)
Encodes the linked URL as specified.

Parameters:
builder - the linked URL.
encoding - the encoding.

isNoCache

boolean isNoCache()
Checks whether caching of pages in clients is on or off.

Returns:
true if caching is disabled, false if enabled.

setNoCache

void setNoCache(boolean flag)
Sets whether caching of pages in clients is on or off.

Parameters:
flag - true if caching is disabled, false if enabled.

setNoCache

void setNoCache(boolean flag,
                long expires)
Sets whether caching of pages in clients is on or off with expiration.

Parameters:
flag - true if caching is disabled, false if enabled.
expires - the expiration in msecs (0 = always, -1 = never).

getMaxAge

int getMaxAge()
Gets the max caching age of pages in clients.

Returns:
the max age in seconds.

setMaxAge

void setMaxAge(int secs)
Sets the max caching age of pages in clients.

Parameters:
secs - the max age in seconds (-1 = forever).

getStatus

int getStatus()
Gets the status code of the response.

Returns:
the status code.

setStatus

void setStatus(int code)
Sets the status code of the response.

Parameters:
code - the status code.

getUserPrincipal

Principal getUserPrincipal()
Gets the authenticated principal that is registered to the session of this request.

Returns:
the authenticated principal or null if not registered.

registerUserPrincipal

HttpSession registerUserPrincipal(Principal principal)
Registers the authenticated principal to the session of this request.

Parameters:
principal - the authenticated principal.
Returns:
the session of the principal.


Copyright © 2004 The Norther Organization. All rights reserved.