net.jini.jeri.tcp
Class TcpServerEndpoint.LH

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

private static class TcpServerEndpoint.LH
extends Object
implements ServerEndpoint.ListenHandle

ListenHandle implementation: represents a listen operation.


Nested Class Summary
private  class TcpServerEndpoint.LH.ServerConnectionImpl
          ServerConnection implementation.
 
Field Summary
private  int acceptFailureCount
           
private  long acceptFailureTime
           
private  boolean closed
           
private  Set connections
           
private  ServerEndpoint.ListenCookie cookie
           
private  Object lock
           
private  RequestDispatcher requestDispatcher
           
private  SecurityContext securityContext
           
private  ServerSocket serverSocket
           
 
Constructor Summary
TcpServerEndpoint.LH(RequestDispatcher requestDispatcher, ServerSocket serverSocket, SecurityContext securityContext, ServerEndpoint.ListenCookie cookie)
           
 
Method Summary
 void close()
          Stops this listen operation.
private  boolean continueAfterAcceptFailure(Throwable t)
          Throttles the accept loop after ServerSocket.accept throws an exception, and decides whether to continue at all.
private  void executeAcceptLoop()
          Executes the accept loop.
 ServerEndpoint.ListenCookie getCookie()
          Returns a cookie to identify this listen operation.
(package private)  void startAccepting()
          Starts the accept loop.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

requestDispatcher

private final RequestDispatcher requestDispatcher

serverSocket

private final ServerSocket serverSocket

securityContext

private final SecurityContext securityContext

cookie

private final ServerEndpoint.ListenCookie cookie

acceptFailureTime

private long acceptFailureTime

acceptFailureCount

private int acceptFailureCount

lock

private final Object lock

closed

private boolean closed

connections

private final Set connections
Constructor Detail

TcpServerEndpoint.LH

TcpServerEndpoint.LH(RequestDispatcher requestDispatcher,
                     ServerSocket serverSocket,
                     SecurityContext securityContext,
                     ServerEndpoint.ListenCookie cookie)
Method Detail

startAccepting

void startAccepting()
Starts the accept loop.


executeAcceptLoop

private void executeAcceptLoop()
Executes the accept loop. The accept loop runs with the full privileges of this code; "accept" SocketPermissions are checked against the direct user of this endpoint later, when the ServerConnectionManager calls checkPermissions on the InboundRequest before passing it to the RequestDispatcher.


close

public void close()
Stops this listen operation.

Specified by:
close in interface ServerEndpoint.ListenHandle

getCookie

public ServerEndpoint.ListenCookie getCookie()
Returns a cookie to identify this listen operation.

Specified by:
getCookie in interface ServerEndpoint.ListenHandle
Returns:
a ListenCookie to identify the listen operation

toString

public String toString()
Overrides:
toString in class Object

continueAfterAcceptFailure

private boolean continueAfterAcceptFailure(Throwable t)
Throttles the accept loop after ServerSocket.accept throws an exception, and decides whether to continue at all. The current code is borrowed from the JRMP implementation; it always continues, but it delays the loop after bursts of failed accepts.



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