public class APIServlet extends HttpServlet
API
.
This servlet supports various HTTP methods, depending on the calling
conventions. A request with an unsupported method makes this servlet
return the HTTP status code 405 Method Not Allowed
.
If no matching function is found, then this servlet returns HTTP status
code 404 Not Found
.
If the servlet is temporarily unavailable, then the HTTP status
503 Service Unavailable
is returned.
If the servlet encountered an initialization error, then the HTTP status
code 500 Internal Server Error
is returned.
If the state is ready then the HTTP status code
200 OK
is returned.
When the servlet is initialized, it gathers configuration information from different sources:
web.xml
file with
build-time settings. Some of these settings are required in order
for the XINS/Java Server Framework to start up, while others are
optional. These build-time settings are passed to the servlet by the
application server as a ServletConfig
object. See
init(ServletConfig)
.
java -Dorg.xins.server.config=`pwd`/config/xins.properties
-jar orion.jar
log4j.rootLogger=DEBUG, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %-5p [%c]
%m%n
Constructor and Description |
---|
APIServlet()
Constructs a new
APIServlet object. |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Destroys this servlet.
|
ServletConfig |
getServletConfig()
Returns the
ServletConfig object which contains the
bootstrap properties for this servlet. |
String |
getServletInfo()
Returns information about this servlet, as plain text.
|
void |
init(ServletConfig config)
Initializes this servlet using the specified configuration.
|
void |
service(HttpServletRequest request,
HttpServletResponse response)
Handles an HTTP request to this servlet.
|
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
getInitParameter, getInitParameterNames, getServletContext, getServletName, init, log, log
public String getServletInfo()
getServletInfo
in interface Servlet
getServletInfo
in class GenericServlet
null
and not an
empty character string.public void init(ServletConfig config) throws IllegalArgumentException, ServletException
init
in interface Servlet
init
in class GenericServlet
config
- the ServletConfig
object which contains bootstrap properties for
this servlet, as specified by the assembler, cannot be
null
.IllegalArgumentException
- if config == null
|| config.ServletConfig.getServletContext()
== null
.ServletException
- if the servlet could not be initialized.public ServletConfig getServletConfig()
ServletConfig
object which contains the
bootstrap properties for this servlet. The returned ServletConfig
object is the one passed to the init(ServletConfig)
method.getServletConfig
in interface Servlet
getServletConfig
in class GenericServlet
ServletConfig
object that was used to initialize this
servlet, or null
if this servlet is not yet
initialized.public void service(HttpServletRequest request, HttpServletResponse response) throws NullPointerException, IOException
null
, then the behaviour of this method is undefined.service
in class HttpServlet
request
- the servlet request, should not be null
.response
- the servlet response, should not be null
.NullPointerException
- if this servlet is yet uninitialized.IOException
- if there is an error error writing to the response output stream.public void destroy()
After this method has finished, no more requests will be handled successfully.
destroy
in interface Servlet
destroy
in class GenericServlet
See http://www.xins.org/.