src/share/classes/sun/rmi/transport/tcp/TCPChannel.java

Print this page




  47 import sun.rmi.transport.Channel;
  48 import sun.rmi.transport.Connection;
  49 import sun.rmi.transport.Endpoint;
  50 import sun.rmi.transport.TransportConstants;
  51 import sun.security.action.GetIntegerAction;
  52 import sun.security.action.GetLongAction;
  53 
  54 /**
  55  * TCPChannel is the socket-based implementation of the RMI Channel
  56  * abstraction.
  57  *
  58  * @author Ann Wollrath
  59  */
  60 public class TCPChannel implements Channel {
  61     /** endpoint for this channel */
  62     private final TCPEndpoint ep;
  63     /** transport for this channel */
  64     private final TCPTransport tr;
  65     /** list of cached connections */
  66     private final List<TCPConnection> freeList =
  67         new ArrayList<TCPConnection>();
  68     /** frees cached connections that have expired (guarded by freeList) */
  69     private Future<?> reaper = null;
  70 
  71     /** using multiplexer (for bi-directional applet communication */
  72     private boolean usingMultiplexer = false;
  73     /** connection multiplexer, if used */
  74     private ConnectionMultiplexer multiplexer = null;
  75     /** connection acceptor (should be in TCPTransport) */
  76     private ConnectionAcceptor acceptor;
  77 
  78     /** most recently authorized AccessControlContext */
  79     private AccessControlContext okContext;
  80 
  81     /** cache of authorized AccessControlContexts */
  82     private WeakHashMap<AccessControlContext,
  83                         Reference<AccessControlContext>> authcache;
  84 
  85     /** the SecurityManager which authorized okContext and authcache */
  86     private SecurityManager cacheSecurityManager = null;
  87 


 463                 reaper = null;
 464             }
 465         }
 466     }
 467 }
 468 
 469 /**
 470  * ConnectionAcceptor manages accepting new connections and giving them
 471  * to TCPTransport's message handler on new threads.
 472  *
 473  * Since this object only needs to know which transport to give new
 474  * connections to, it doesn't need to be per-channel as currently
 475  * implemented.
 476  */
 477 class ConnectionAcceptor implements Runnable {
 478 
 479     /** transport that will handle message on accepted connections */
 480     private TCPTransport transport;
 481 
 482     /** queue of connections to be accepted */
 483     private List<Connection> queue = new ArrayList<Connection>();
 484 
 485     /** thread ID counter */
 486     private static int threadNum = 0;
 487 
 488     /**
 489      * Create a new ConnectionAcceptor that will give connections
 490      * to the specified transport on a new thread.
 491      */
 492     public ConnectionAcceptor(TCPTransport transport) {
 493         this.transport = transport;
 494     }
 495 
 496     /**
 497      * Start a new thread to accept connections.
 498      */
 499     public void startNewAcceptor() {
 500         Thread t = AccessController.doPrivileged(
 501             new NewThreadAction(ConnectionAcceptor.this,
 502                                 "Multiplex Accept-" + ++ threadNum,
 503                                 true));




  47 import sun.rmi.transport.Channel;
  48 import sun.rmi.transport.Connection;
  49 import sun.rmi.transport.Endpoint;
  50 import sun.rmi.transport.TransportConstants;
  51 import sun.security.action.GetIntegerAction;
  52 import sun.security.action.GetLongAction;
  53 
  54 /**
  55  * TCPChannel is the socket-based implementation of the RMI Channel
  56  * abstraction.
  57  *
  58  * @author Ann Wollrath
  59  */
  60 public class TCPChannel implements Channel {
  61     /** endpoint for this channel */
  62     private final TCPEndpoint ep;
  63     /** transport for this channel */
  64     private final TCPTransport tr;
  65     /** list of cached connections */
  66     private final List<TCPConnection> freeList =
  67         new ArrayList<>();
  68     /** frees cached connections that have expired (guarded by freeList) */
  69     private Future<?> reaper = null;
  70 
  71     /** using multiplexer (for bi-directional applet communication */
  72     private boolean usingMultiplexer = false;
  73     /** connection multiplexer, if used */
  74     private ConnectionMultiplexer multiplexer = null;
  75     /** connection acceptor (should be in TCPTransport) */
  76     private ConnectionAcceptor acceptor;
  77 
  78     /** most recently authorized AccessControlContext */
  79     private AccessControlContext okContext;
  80 
  81     /** cache of authorized AccessControlContexts */
  82     private WeakHashMap<AccessControlContext,
  83                         Reference<AccessControlContext>> authcache;
  84 
  85     /** the SecurityManager which authorized okContext and authcache */
  86     private SecurityManager cacheSecurityManager = null;
  87 


 463                 reaper = null;
 464             }
 465         }
 466     }
 467 }
 468 
 469 /**
 470  * ConnectionAcceptor manages accepting new connections and giving them
 471  * to TCPTransport's message handler on new threads.
 472  *
 473  * Since this object only needs to know which transport to give new
 474  * connections to, it doesn't need to be per-channel as currently
 475  * implemented.
 476  */
 477 class ConnectionAcceptor implements Runnable {
 478 
 479     /** transport that will handle message on accepted connections */
 480     private TCPTransport transport;
 481 
 482     /** queue of connections to be accepted */
 483     private List<Connection> queue = new ArrayList<>();
 484 
 485     /** thread ID counter */
 486     private static int threadNum = 0;
 487 
 488     /**
 489      * Create a new ConnectionAcceptor that will give connections
 490      * to the specified transport on a new thread.
 491      */
 492     public ConnectionAcceptor(TCPTransport transport) {
 493         this.transport = transport;
 494     }
 495 
 496     /**
 497      * Start a new thread to accept connections.
 498      */
 499     public void startNewAcceptor() {
 500         Thread t = AccessController.doPrivileged(
 501             new NewThreadAction(ConnectionAcceptor.this,
 502                                 "Multiplex Accept-" + ++ threadNum,
 503                                 true));