public interface ServerConnection
ServerConnection
implementation typically
contains a Socket
.
ServerConnection
is implemented by a
connection-based ServerEndpoint
implementation that uses
ServerConnectionManager
for managing connections. A
ServerConnection
is created by the implementation for
newly-accepted connections and passed to the manager's handleConnection
method.
Modifier and Type | Method and Description |
---|---|
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.
|
InputStream getInputStream() throws IOException
IOException
- if an I/O exception occursOutputStream getOutputStream() throws IOException
IOException
- if an I/O exception occursSocketChannel getChannel()
null
if no socket channel is available. If a
non-null
socket channel is returned, it is
connected.null
InboundRequestHandle processRequestData(InputStream in, OutputStream out) throws IOException
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.
in
- the request input stream of the requestout
- the response output stream of the requestNullPointerException
- if in
or
out
is null
IOException
- if an I/O exception occursSecurityException
- if a security exception occursvoid checkPermissions(InboundRequestHandle handle)
InboundRequest.checkPermissions
for a request with the
specified handle.handle
- the handle for the requestSecurityException
- if the current security context does
not have the permissions necessary to receive the requestIllegalArgumentException
- if the specified handle was
not returned from this connection's
processRequestData
methodNullPointerException
- if handle
is
null
InvocationConstraints checkConstraints(InboundRequestHandle handle, InvocationConstraints constraints) throws UnsupportedConstraintException
InboundRequest.checkConstraints
for a request with the
specified handle.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 requestIllegalArgumentException
- if the specified handle was
not returned from this connection's
processRequestData
methodNullPointerException
- if handle
or
constraints
is null
void populateContext(InboundRequestHandle handle, Collection context)
InboundRequest.populateContext
for such requests; the context
may also be populated by the connection manager.handle
- the handle for the requestcontext
- the context collection to populateIllegalArgumentException
- if the specified handle was
not returned from this connection's
processRequestData
methodNullPointerException
- if handle
or
context
is null
UnsupportedOperationException
- if context
is unmodifiablevoid close() throws IOException
IOException
- if an I/O exception occurs