|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nu.staldal.lsp.framework.ThrowawayService
public abstract class ThrowawayService
Abstract base class for Throwaway Service.
Services will be loaded and instantiated using Class.forName
and Class.newInstance
, so they must have a public no-arg
constructor.
A new instance will be created for each request, and that instance is
thrown away after the request. The execute
method is only invoked once per instance, so there are no thread-safety
issues. It's not a problem to use instance fields.
Use the Parameter
annotation on instance fields to automatically
populate them with HTTP request parameter values.
Field Summary | |
---|---|
protected javax.servlet.ServletContext |
context
The ServletContext. |
protected DBConnection |
dbConn
database connection to use for this request, or null if no database has been setup |
protected java.util.List<java.lang.String> |
extraArgs
Any extra URL path components from RestfulDispatcherServlet ,
or null if another dispatcher is used. |
static java.lang.String |
INCLUDE_ATTR_PREFIX
Prefix for request attributes for include attributes. |
protected javax.sql.DataSource |
mainDB
The DataSource to main database,
or null if no database is setup. |
protected javax.servlet.http.HttpServletRequest |
request
The HttpServletRequest. |
static int |
REQUEST_DELETE
Request type DELETE. |
static int |
REQUEST_GET
Request type GET. |
static int |
REQUEST_INCLUDE
Request type include. |
static int |
REQUEST_POST
Request type POST. |
static int |
REQUEST_PUT
Request type PUT. |
protected int |
requestType
The request type. |
protected javax.servlet.http.HttpServletResponse |
response
The HttpServletResponse. |
Constructor Summary | |
---|---|
ThrowawayService()
|
Method Summary | |
---|---|
abstract java.lang.String |
execute(java.util.Map<java.lang.String,java.lang.Object> pageParams)
Invoked for a request to this Service. |
protected java.util.Locale |
getUserLocale()
Get the user's locale. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int REQUEST_GET
public static final int REQUEST_POST
public static final int REQUEST_INCLUDE
public static final int REQUEST_PUT
public static final int REQUEST_DELETE
public static final java.lang.String INCLUDE_ATTR_PREFIX
protected javax.servlet.ServletContext context
protected javax.servlet.http.HttpServletRequest request
protected javax.servlet.http.HttpServletResponse response
protected javax.sql.DataSource mainDB
DataSource
to main database,
or null
if no database is setup.
protected DBConnection dbConn
null
if no database has been setup
protected int requestType
REQUEST_GET
, REQUEST_POST
, REQUEST_PUT
, REQUEST_DELETE
or REQUEST_INCLUDE
protected java.util.List<java.lang.String> extraArgs
RestfulDispatcherServlet
,
or null
if another dispatcher is used.
Constructor Detail |
---|
public ThrowawayService()
Method Detail |
---|
protected java.util.Locale getUserLocale()
null
public abstract java.lang.String execute(java.util.Map<java.lang.String,java.lang.Object> pageParams) throws java.lang.Exception
Is invoked for GET, HEAD, POST, PUT and DELETE requests. You should not treat
HEAD requests differently than GET requests, the framework will
automatically discard the body and only send the headers. The
requestType
field indicate the type of request.
See the HTTP specification for differences between GET and POST requests.
There are three choices to create the response:
pageParams
with parameters to this page.
In this case, response
should only be used
to set headers.response
and return null
. In this case the framework will not
touch response
after this method returns, and will not
use pageParams
. This can be used if you want
to use sendError
or sendRedirect
.pageParams
are
retained. You may add attributes to request
in order to
comnunicate with the other service.
If requestType
is REQUEST_INCLUDE
,
choice 2 and 3 may not be used, and response
may not be
modified in any way. You may either return the name of page, or use
the SAX2 ContentHandler
passed as a request
attribute with name "org.xml.sax.ContentHandler" and
return null
. startDocument
and
endDocument
must not be invoked on the ContentHandler, use
ContentHandlerStartEndDocumentFilter
if this is
a problem.
pageParams
- map for page parameters
null
to not
use any page, or the name of an other service to forward to
prefixed by "*"
java.lang.Exception
- may throw any Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |