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

Print this page




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.rmi.transport.tcp;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 import java.rmi.server.LogStream;

  30 
  31 import sun.rmi.runtime.Log;
  32 
  33 /**
  34  * ConnectionMultiplexer manages the transparent multiplexing of
  35  * multiple virtual connections from one endpoint to another through
  36  * one given real connection to that endpoint.  The input and output
  37  * streams for the the underlying real connection must be supplied.
  38  * A callback object is also supplied to be informed of new virtual
  39  * connections opened by the remote endpoint.  After creation, the
  40  * run() method must be called in a thread created for demultiplexing
  41  * the connections.  The openConnection() method is called to
  42  * initiate a virtual connection from this endpoint.
  43  *
  44  * @author Peter Jones
  45  */
  46 @SuppressWarnings("deprecation")
  47 final class ConnectionMultiplexer {
  48 
  49     /** "multiplex" log level */
  50     static int logLevel = LogStream.parseLevel(getLogLevel());
  51 
  52     private static String getLogLevel() {
  53         return java.security.AccessController.doPrivileged(
  54             new sun.security.action.GetPropertyAction("sun.rmi.transport.tcp.multiplex.logLevel"));
  55     }
  56 
  57     /* multiplex system log */
  58     static final Log multiplexLog =
  59         Log.getLog("sun.rmi.transport.tcp.multiplex",
  60                    "multiplex", ConnectionMultiplexer.logLevel);
  61 
  62     /** multiplexing protocol operation codes */
  63     private final static int OPEN     = 0xE1;
  64     private final static int CLOSE    = 0xE2;
  65     private final static int CLOSEACK = 0xE3;
  66     private final static int REQUEST  = 0xE4;
  67     private final static int TRANSMIT = 0xE5;
  68 
  69     /** object to notify for new connections from remote endpoint */
  70     private TCPChannel channel;
  71 
  72     /** input stream for underlying single connection */
  73     private InputStream in;
  74 




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.rmi.transport.tcp;
  26 
  27 import java.io.*;
  28 import java.util.*;
  29 import java.rmi.server.LogStream;
  30 import java.security.PrivilegedAction;
  31 
  32 import sun.rmi.runtime.Log;
  33 
  34 /**
  35  * ConnectionMultiplexer manages the transparent multiplexing of
  36  * multiple virtual connections from one endpoint to another through
  37  * one given real connection to that endpoint.  The input and output
  38  * streams for the the underlying real connection must be supplied.
  39  * A callback object is also supplied to be informed of new virtual
  40  * connections opened by the remote endpoint.  After creation, the
  41  * run() method must be called in a thread created for demultiplexing
  42  * the connections.  The openConnection() method is called to
  43  * initiate a virtual connection from this endpoint.
  44  *
  45  * @author Peter Jones
  46  */
  47 @SuppressWarnings("deprecation")
  48 final class ConnectionMultiplexer {
  49 
  50     /** "multiplex" log level */
  51     static int logLevel = LogStream.parseLevel(getLogLevel());
  52 
  53     private static String getLogLevel() {
  54         return java.security.AccessController.doPrivileged(
  55            (PrivilegedAction<String>) () -> System.getProperty("sun.rmi.transport.tcp.multiplex.logLevel"));
  56     }
  57 
  58     /* multiplex system log */
  59     static final Log multiplexLog =
  60         Log.getLog("sun.rmi.transport.tcp.multiplex",
  61                    "multiplex", ConnectionMultiplexer.logLevel);
  62 
  63     /** multiplexing protocol operation codes */
  64     private final static int OPEN     = 0xE1;
  65     private final static int CLOSE    = 0xE2;
  66     private final static int CLOSEACK = 0xE3;
  67     private final static int REQUEST  = 0xE4;
  68     private final static int TRANSMIT = 0xE5;
  69 
  70     /** object to notify for new connections from remote endpoint */
  71     private TCPChannel channel;
  72 
  73     /** input stream for underlying single connection */
  74     private InputStream in;
  75