|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object nu.staldal.lsp.framework.ThrowawayService nu.staldal.lsp.framework.EasyService
public abstract class EasyService
Abstract base class for easy services.
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.
Use the PageParameter
annotation on instance fields to automatically
use them as page parameters to templates.
Field Summary |
---|
Fields inherited from class nu.staldal.lsp.framework.ThrowawayService |
---|
context, dbConn, extraArgs, INCLUDE_ATTR_PREFIX, mainDB, request, REQUEST_DELETE, REQUEST_GET, REQUEST_INCLUDE, REQUEST_POST, REQUEST_PUT, requestType, response |
Constructor Summary | |
---|---|
EasyService()
|
Method Summary | |
---|---|
abstract java.lang.String |
execute()
Invoked for a request to this Service. |
java.lang.String |
execute(java.util.Map<java.lang.String,java.lang.Object> pageParams)
Do not override this method. |
Methods inherited from class nu.staldal.lsp.framework.ThrowawayService |
---|
getUserLocale |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EasyService()
Method Detail |
---|
public final java.lang.String execute(java.util.Map<java.lang.String,java.lang.Object> pageParams) throws java.lang.Exception
execute
in class ThrowawayService
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 Exceptionexecute()
public abstract java.lang.String execute() 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
ThrowawayService.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:
PageParameter
. 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. This can be used if you want
to use sendError
or sendRedirect
.request
in order to
comnunicate with the other service.
If requestType
is ThrowawayService.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.
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 |