simple.http.load
Class Redirect
java.lang.Object
simple.http.serve.Component
simple.http.load.Service
simple.http.load.Redirect
- All Implemented Interfaces:
- Resource
public abstract class Redirect
- extends Service
The Redirect
object provides a redirectable
implementation of the Service
object. This is
used to implement controllers that ultimately redirect to
another service or site to complete the client request.
Typically the redirect
method is implemented
to perform some processing before being redirected.
The lookup
and resolve
methods are
used to acquire the desired resource object. This must then
be returned for the redirection to complete. If at any stage
during processing and error occurs then an exception may be
thrown to the calling method to indicate the problem.
- Author:
- Niall Gallagher
Constructor Summary |
Redirect(Context context)
Constructor for the Redirect object. |
Method Summary |
Resource |
lookup(java.lang.String target)
This method is used to retrieve services using the name
for that service. |
protected void |
process(Request req,
Response resp)
This process method is used to drive the
redirect method. |
abstract Resource |
redirect(Request req,
Response resp)
The redirect method is used to perform various
operations before a request or client is redirected. |
Resource |
resolve(java.lang.String target)
This method is used to retrieve services using a specific
URI. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Redirect
public Redirect(Context context)
- Constructor for the
Redirect
object. This is
used to provide a service implementation that can be used
used as a controller service. Any subclass of this can
introduce initialization using the constructor or using
the flexible prepare
initializer method.
- Parameters:
context
- the context this controller is rooted at
process
protected void process(Request req,
Response resp)
throws java.lang.Exception
- This
process
method is used to drive the
redirect
method. This will simply invoke the
method and forward the client request to the resulting
Resource
object, which completes the request.
- Specified by:
process
in class Component
- Parameters:
req
- the HTTP request object representing the clientresp
- the HTTP response object to send a reply with
- Throws:
java.lang.Exception
- thrown if there is a problem processing
lookup
public Resource lookup(java.lang.String target)
throws java.lang.Exception
- This method is used to retrieve services using the name
for that service. This method delegates directly to the
LoaderEngine.lookup
method implemented. This
method can be subclassed to provide a naming scheme, such
that resources can be acquired using aliases.
- Parameters:
target
- the target name referencing the resource
- Returns:
- the
Resource
that has been located
- Throws:
java.lang.Exception
resolve
public Resource resolve(java.lang.String target)
throws java.lang.Exception
- This method is used to retrieve services using a specific
URI. The URI format is not important, this method is able
to handle absolute and realitive URI formats. Like the
lookup
method this maps directly to the
the LoaderEngine
implementaion for resolving
resources given a URI target. If the target URI is not
relative, that is, if the URI does not begin with the
root path, "/", then a HTTP redirect will be employed.
- Parameters:
target
- the URI string referencing the resource
- Returns:
- the
Resource
that has been located
- Throws:
java.lang.Exception
redirect
public abstract Resource redirect(Request req,
Response resp)
throws java.lang.Exception
- The
redirect
method is used to perform various
operations before a request or client is redirected. This is
useful when no specific view is associated with a target
service or resource. It allows delegation to other resources,
which can then render the view for the HTTP transaction.
- Parameters:
req
- the HTTP request object representing the clientresp
- the HTTP response object to send a reply with
- Returns:
- returns the resource used to handle the request
- Throws:
java.lang.Exception
- thrown if there is a problem processing