/** @return the Java serialization encoding version. */
  public static byte getEncodingVersion(ORB orb, IOR ior) {

    // Is Java serialization enabled?
    // Check the JavaSerializationComponent (tagged component)
    // in the IIOPProfile. If present, the peer ORB's GIOP is capable
    // of using Java serialization instead of CDR serialization.
    // In such a case, use Java serialization, iff the java serialization
    // versions match.

    if (orb.getORBData().isJavaSerializationEnabled()) {
      IIOPProfile prof = ior.getProfile();
      IIOPProfileTemplate profTemp = (IIOPProfileTemplate) prof.getTaggedProfileTemplate();
      java.util.Iterator iter = profTemp.iteratorById(ORBConstants.TAG_JAVA_SERIALIZATION_ID);
      if (iter.hasNext()) {
        JavaSerializationComponent jc = (JavaSerializationComponent) iter.next();
        byte jcVersion = jc.javaSerializationVersion();
        if (jcVersion >= Message.JAVA_ENC_VERSION) {
          return Message.JAVA_ENC_VERSION;
        } else if (jcVersion > Message.CDR_ENC_VERSION) {
          return jc.javaSerializationVersion();
        } else {
          // throw error?
          // Since encodingVersion is <= 0 (CDR_ENC_VERSION).
        }
      }
    }
    return Message.CDR_ENC_VERSION; // default
  }
示例#2
0
  public ServerSocket createServerSocket(String type, InetSocketAddress inetSocketAddress)
      throws IOException {
    ServerSocketChannel serverSocketChannel = null;
    ServerSocket serverSocket = null;

    if (orb.getORBData().acceptorSocketType().equals(ORBConstants.SOCKETCHANNEL)) {
      serverSocketChannel = ServerSocketChannel.open();
      serverSocket = serverSocketChannel.socket();
    } else {
      serverSocket = new ServerSocket();
    }
    serverSocket.bind(inetSocketAddress);
    return serverSocket;
  }
示例#3
0
  public Socket createSocket(String type, InetSocketAddress inetSocketAddress) throws IOException {
    SocketChannel socketChannel = null;
    Socket socket = null;

    if (orb.getORBData().connectionSocketType().equals(ORBConstants.SOCKETCHANNEL)) {
      socketChannel = SocketChannel.open(inetSocketAddress);
      socket = socketChannel.socket();
    } else {
      socket = new Socket(inetSocketAddress.getHostName(), inetSocketAddress.getPort());
    }

    // Disable Nagle's algorithm (i.e., always send immediately).
    socket.setTcpNoDelay(true);

    return socket;
  }