|
Tynamo™-SNAP v1.0.4 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.qindesign.servlet.example.FastOneWireServlet
public class FastOneWireServlet
Simple 1-Wire servlet that can list adapters and devices, and can also read a device. The output is XML.
The output is generated according to the following rules:
printDevice
is called to output something appropriate.
| Constructor Summary | |
|---|---|
FastOneWireServlet()
|
|
| Method Summary | |
|---|---|
void |
destroy()
Destroys the servlet. |
protected void |
doGet(HttpServletRequest req,
HttpServletResponse resp)
Process a GET request. |
void |
init()
Initializes the servlet. |
protected void |
printDevice(HttpServletRequest req,
HttpServletResponse resp,
DSPortAdapter a,
OneWireContainer c)
Retrieves a value from the given container. |
protected void |
printErrorMessage(HttpServletResponse resp,
String msg)
Prints an error message. |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doOptions, doPost, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public FastOneWireServlet()
| Method Detail |
|---|
public void init()
throws ServletException
init in class GenericServletServletExceptionpublic void destroy()
destroy in interface Servletdestroy in class GenericServlet
protected void doGet(HttpServletRequest req,
HttpServletResponse resp)
throws ServletException,
IOException
doGet in class HttpServletServletException
IOException
protected void printErrorMessage(HttpServletResponse resp,
String msg)
throws IOException
resp - the HTTP response objectmsg - the error message, a string
IOException
protected void printDevice(HttpServletRequest req,
HttpServletResponse resp,
DSPortAdapter a,
OneWireContainer c)
throws OneWireIOException,
OneWireException,
IOException
Remember to use begin/endExclusive calls on the adapter, and also try to perform output as late as possible to allow for an error status to be generated in the calling code. If the response has already been committed (eg. obtaining the output stream), then any 1-Wire exeption cannot be properly reported to the user.
req - the HTTP request object, for extracting request parameters,
etc.resp - the HTTP response object, for setting the status and
getting the output stream, etc.a - the port adapter, for exclusive calls, etc.c - the 1-Wire container object, assumed to be present
OneWireIOException
OneWireException
IOException
|
Tynamo™-SNAP v1.0.4 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||