|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@Deprecated public interface Service
Interface for Service.
Services will be loaded and instantiated using Class.forName
and Class.newInstance
, so they must have a public no-arg
constructor.
There will be only one instance of each Service per web application per
JVM (in case of a distributed application). The execute
method may be invoked concurrently by several threads.
It's not recommended to have any instance fields in the Service class
which can be changed by the execute
method. Instance fields
which are initialized by the init
method and then only read by
the execute
method are OK. If you have instance fields which
can be changed by the execute
method, access to them need to be
synchronized.
The life cycle and instance management of Services are very similar to
Servlet
, see the Servlet specification for details.
Field Summary | |
---|---|
static java.lang.String |
INCLUDE_ATTR_PREFIX
Deprecated. Prefix for request attributes for include attributes. |
static int |
REQUEST_DELETE
Deprecated. Request type DELETE. |
static int |
REQUEST_GET
Deprecated. Request type GET. |
static int |
REQUEST_INCLUDE
Deprecated. Request type include. |
static int |
REQUEST_POST
Deprecated. Request type POST. |
static int |
REQUEST_PUT
Deprecated. Request type PUT. |
Method Summary | |
---|---|
void |
destroy()
Deprecated. Invoked once by the Servlet.destroy() method. |
java.lang.String |
execute(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.util.Map<java.lang.String,java.lang.Object> pageParams,
int requestType)
Deprecated. Invoked for each request to this Service. |
void |
init(javax.servlet.ServletContext context)
Deprecated. Invoked once directly after instantiation, before first use. |
Field Detail |
---|
static final int REQUEST_GET
static final int REQUEST_POST
static final int REQUEST_INCLUDE
static final int REQUEST_PUT
static final int REQUEST_DELETE
static final java.lang.String INCLUDE_ATTR_PREFIX
Method Detail |
---|
void init(javax.servlet.ServletContext context) throws javax.servlet.ServletException
The init method should not invoke DispatcherServlet.lookupService(String)
,
DispatcherServlet.doGet(HttpServletRequest, HttpServletResponse)
,
DispatcherServlet.doPost(HttpServletRequest, HttpServletResponse)
or
ServletExtLib.handleElement(String, org.xml.sax.Attributes, org.xml.sax.ContentHandler)
.
context
- the ServletContext
javax.servlet.ServletException
- may throw ServletExceptionjava.lang.String execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.util.Map<java.lang.String,java.lang.Object> pageParams, int requestType) throws javax.servlet.ServletException, java.io.IOException
May be invoked concurrently by several threads.
Is invoked for GET, POST, PUT, DELETE and HEAD 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
parameter indicate the type of request.
See the HTTP specification for differences between GET, POST, PUT and DELETE
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.
request
- the HttpServletRequest
response
- the HttpServletResponse
pageParams
- map for page parametersrequestType
- the type of request:
REQUEST_GET
, REQUEST_POST
, REQUEST_PUT
, REQUEST_DELETE
or REQUEST_INCLUDE
null
to not
use any page, or the name of an other service to forward to
prefixed by "*"
javax.servlet.ServletException
- may throw ServletException
java.io.IOException
- may throw IOExceptionvoid destroy()
Servlet.destroy()
method.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |