net.jini.jeri.tcp
Class TcpServerEndpoint.LH.ServerConnectionImpl

java.lang.Object
  extended by net.jini.jeri.tcp.TcpServerEndpoint.LH.ServerConnectionImpl
All Implemented Interfaces:
ServerConnection
Enclosing class:
TcpServerEndpoint.LH

private class TcpServerEndpoint.LH.ServerConnectionImpl
extends Object
implements ServerConnection

ServerConnection implementation. Instances of this class should never get exposed to anything other than our ServerConnectionManager, which we trust to operate correctly, so we do not bother to validate request handles passed in.


Field Summary
private  Socket socket
           
private  InetAddress socketInetAddress
           
private  int socketPort
           
 
Constructor Summary
TcpServerEndpoint.LH.ServerConnectionImpl(Socket socket)
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

private final Socket socket

socketInetAddress

private final InetAddress socketInetAddress

socketPort

private final int socketPort
Constructor Detail

TcpServerEndpoint.LH.ServerConnectionImpl

TcpServerEndpoint.LH.ServerConnectionImpl(Socket socket)
Method Detail

getInputStream

public InputStream getInputStream()
                           throws IOException
Description copied from interface: ServerConnection
Returns an input stream that reads data from this connection.

Specified by:
getInputStream in interface ServerConnection
Returns:
an input stream that reads data from this connection
Throws:
IOException - if an I/O exception occurs

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Description copied from interface: ServerConnection
Returns an output stream that writes data to this connection.

Specified by:
getOutputStream in interface ServerConnection
Returns:
an output stream that writes data to this connection
Throws:
IOException - if an I/O exception occurs

getChannel

public SocketChannel getChannel()
Description copied from interface: ServerConnection
Returns a socket channel that performs I/O on this connection, or null if no socket channel is available. If a non-null socket channel is returned, it is connected.

Specified by:
getChannel in interface ServerConnection
Returns:
a socket channel that performs I/O on this connection, or null

processRequestData

public InboundRequestHandle processRequestData(InputStream in,
                                               OutputStream out)
Description copied from interface: ServerConnection
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.

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.

Specified by:
processRequestData in interface ServerConnection
Parameters:
in - the request input stream of the request
out - the response output stream of the request
Returns:
a handle to identify the request in later invocations on this connection

checkPermissions

public void checkPermissions(InboundRequestHandle handle)
Description copied from interface: ServerConnection
Implements InboundRequest.checkPermissions for a request with the specified handle.

Specified by:
checkPermissions in interface ServerConnection
Parameters:
handle - the handle for the request

checkConstraints

public InvocationConstraints checkConstraints(InboundRequestHandle handle,
                                              InvocationConstraints constraints)
                                       throws UnsupportedConstraintException
Description copied from interface: ServerConnection
Implements InboundRequest.checkConstraints for a request with the specified handle.

Specified by:
checkConstraints in interface ServerConnection
Parameters:
handle - the handle for the request
constraints - the constraints that must be satisfied
Returns:
the constraints that must be at least partially implemented by higher layers
Throws:
UnsupportedConstraintException - if the transport layer aspects of any of the specified requirements are not satisfied by this request

populateContext

public void populateContext(InboundRequestHandle handle,
                            Collection context)
Description copied from interface: ServerConnection
Populates the supplied collection with context information representing a request with the specified handle. This method is used to implement InboundRequest.populateContext for such requests; the context may also be populated by the connection manager.

Specified by:
populateContext in interface ServerConnection
Parameters:
handle - the handle for the request
context - the context collection to populate

close

public void close()
Description copied from interface: ServerConnection
Closes this connection.

Specified by:
close in interface ServerConnection

addToConnectionSet

private void addToConnectionSet()


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.