|
TopoWeb Commons API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.topoweb.net.TcpDomProtocol
A TCP/IP client implementation of a DOM protocol using a blocking socket. The underlying network protocol is based on well formed request / response XML snippets. Moreover, to keep the parsing simple, we make one crucial assumption:
The root request or response elements always end with an XML
tag of the form </response>
with no
whitespace between the <
and
>
characters (where response
can take on any value).
Actually, this class knows nothing about the remote end, but the above protocol contract is implied at both end-points.
Constructor Summary | |
TcpDomProtocol(java.net.InetSocketAddress socketAddress,
java.lang.String responseTail,
javax.xml.parsers.DocumentBuilder documentBuilder)
Constructs a new instance using the given socket address and the specified response element. |
|
TcpDomProtocol(java.net.InetSocketAddress socketAddress,
java.lang.String responseTail,
javax.xml.parsers.DocumentBuilder documentBuilder,
boolean check)
Constructs a new instance using the given socket address and the specified response element. |
Method Summary | |
org.w3c.dom.Element |
doProtocol(org.w3c.dom.Element request)
Returns the response element for the specified request . |
protected java.io.OutputStream |
getRequestStream(java.net.Socket sock)
Returns a request (output) stream from the specified socket. |
protected java.io.InputStream |
getResponseStream(java.net.Socket sock)
Returns a response (input) stream from the specified socket. |
java.lang.String |
getResponseTagName()
Returns the tag name for the response element. |
protected java.net.Socket |
getSocket()
Returns a ready socket. |
java.net.InetSocketAddress |
getSocketAddress()
Returns the socket address for this instance. |
protected void |
releaseSocket(java.net.Socket sock)
Releases the given socket. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public TcpDomProtocol(java.net.InetSocketAddress socketAddress, java.lang.String responseTail, javax.xml.parsers.DocumentBuilder documentBuilder)
</response>
containing no whitespace.
socketAddress
- the socket address specifying the IP and portresponseTail
- the response tail tagpublic TcpDomProtocol(java.net.InetSocketAddress socketAddress, java.lang.String responseTail, javax.xml.parsers.DocumentBuilder documentBuilder, boolean check)
</response>
containing no whitespace.
socketAddress
- the socket address specifying the IP and portresponseTail
- the response tail tagcheck
- if true
, a best efforts check
is made to ensure that the arguments are validMethod Detail |
public java.net.InetSocketAddress getSocketAddress()
public final java.lang.String getResponseTagName()
protected java.net.Socket getSocket() throws java.io.IOException
doProtocol
method
is implemented. Invoked every time the doProtocol
method is invoked. The default implementation returns a
new socket constructed from the socket address specified at
instantiation. We imagine a subclass might returned a cached
socket.
java.io.IOException
releaseSocket(Socket)
public org.w3c.dom.Element doProtocol(org.w3c.dom.Element request) throws DomProtocolException
DomProtocol
request
.
doProtocol
in interface DomProtocol
request
- the request element
DomProtocolException
- if an error occurs while processing the request;
application-specific errors are expected to be
encoded in the returned response documentprotected java.io.OutputStream getRequestStream(java.net.Socket sock) throws java.io.IOException
java.io.IOException
protected java.io.InputStream getResponseStream(java.net.Socket sock) throws java.io.IOException
StreamFragmenter
to
detect the end of the response.
java.io.IOException
protected void releaseSocket(java.net.Socket sock)
sock
- the socket no longer used
|
TopoWeb Commons API | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |