private class TcpServerEndpoint.LH.ServerConnectionImpl extends Object implements ServerConnection
Modifier and Type | Field and Description |
---|---|
private Socket |
socket |
private InetAddress |
socketInetAddress |
private int |
socketPort |
Constructor and Description |
---|
TcpServerEndpoint.LH.ServerConnectionImpl(Socket socket) |
Modifier and Type | Method and Description |
---|---|
private void |
addToConnectionSet() |
InvocationConstraints |
checkConstraints(InboundRequestHandle handle,
InvocationConstraints constraints)
Implements
InboundRequest.checkConstraints for a request with the
specified handle. |
void |
checkPermissions(InboundRequestHandle handle)
Implements
InboundRequest.checkPermissions for a request with the
specified handle. |
void |
close()
Closes this connection.
|
SocketChannel |
getChannel()
Returns a socket channel that performs I/O on this connection,
or
null if no socket channel is available. |
InputStream |
getInputStream()
Returns an input stream that reads data from this connection.
|
OutputStream |
getOutputStream()
Returns an output stream that writes data to this connection.
|
void |
populateContext(InboundRequestHandle handle,
Collection context)
Populates the supplied collection with context information
representing a request with the specified handle.
|
InboundRequestHandle |
processRequestData(InputStream in,
OutputStream out)
Reads from the specified input stream any per-request data required by
this connection for an inbound request, writes any required response
data to the specified output stream, and returns a handle for the
request.
|
private final Socket socket
private final InetAddress socketInetAddress
private final int socketPort
TcpServerEndpoint.LH.ServerConnectionImpl(Socket socket)
public InputStream getInputStream() throws IOException
ServerConnection
getInputStream
in interface ServerConnection
IOException
- if an I/O exception occurspublic OutputStream getOutputStream() throws IOException
ServerConnection
getOutputStream
in interface ServerConnection
IOException
- if an I/O exception occurspublic SocketChannel getChannel()
ServerConnection
null
if no socket channel is available. If a
non-null
socket channel is returned, it is
connected.getChannel
in interface ServerConnection
null
public InboundRequestHandle processRequestData(InputStream in, OutputStream out)
ServerConnection
This method is invoked by
ServerConnectionManager
with the request input
stream and the response output stream of the InboundRequest
that it creates for the request when the
request is first received. This method reads information that
was sent by Connection.writeRequestData
and writes information to be read
by Connection.readResponseData
. This method can be used, for
example, to process per-request information about delegation,
client authentication, or client privileges.
If, for security reasons, this method determines that the
request must not be processed further (for example, because
client authentication failed), this method should close the
response output stream and throw a
SecurityException
after writing any response data.
There may be multiple requests in progress concurrently over this connection, and data read from and written to the specified streams may be buffered and multiplexed with data from other requests on this connection's underlying streams. Therefore, this method should only read data from the request input stream and write data to the response output stream and must not otherwise read from or write to this connection's underlying streams.
processRequestData
in interface ServerConnection
in
- the request input stream of the requestout
- the response output stream of the requestpublic void checkPermissions(InboundRequestHandle handle)
ServerConnection
InboundRequest.checkPermissions
for a request with the
specified handle.checkPermissions
in interface ServerConnection
handle
- the handle for the requestpublic InvocationConstraints checkConstraints(InboundRequestHandle handle, InvocationConstraints constraints) throws UnsupportedConstraintException
ServerConnection
InboundRequest.checkConstraints
for a request with the
specified handle.checkConstraints
in interface ServerConnection
handle
- the handle for the requestconstraints
- the constraints that must be satisfiedUnsupportedConstraintException
- if the transport layer
aspects of any of the specified requirements are not satisfied
by this requestpublic void populateContext(InboundRequestHandle handle, Collection context)
ServerConnection
InboundRequest.populateContext
for such requests; the context
may also be populated by the connection manager.populateContext
in interface ServerConnection
handle
- the handle for the requestcontext
- the context collection to populatepublic void close()
ServerConnection
close
in interface ServerConnection
private void addToConnectionSet()
Copyright 2007-2013, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.