コード例 #1
0
 public SpdyProxyProtocol() {
   endpoint = new JIoEndpoint();
   ((JIoEndpoint) endpoint).setHandler(cHandler);
   setSoLinger(Constants.DEFAULT_CONNECTION_LINGER);
   setSoTimeout(Constants.DEFAULT_CONNECTION_TIMEOUT);
   setTcpNoDelay(Constants.DEFAULT_TCP_NO_DELAY);
 }
コード例 #2
0
 public void resume() throws Exception {
   try {
     endpoint.resume();
   } catch (Exception ex) {
     log.error(sm.getString("http11protocol.endpoint.resumeerror"), ex);
     throw ex;
   }
   if (log.isInfoEnabled()) log.info(sm.getString("http11protocol.resume", getName()));
 }
コード例 #3
0
 public String getName() {
   String encodedAddr = "";
   if (getAddress() != null) {
     encodedAddr = "" + getAddress();
     if (encodedAddr.startsWith("/")) encodedAddr = encodedAddr.substring(1);
     encodedAddr = URLEncoder.encode(encodedAddr) + "-";
   }
   return ("http-" + encodedAddr + endpoint.getPort());
 }
コード例 #4
0
  public void init() throws Exception {
    endpoint.setName(getName());
    endpoint.setHandler(cHandler);

    // Verify the validity of the configured socket factory
    try {
      if (isSSLEnabled()) {
        sslImplementation = SSLImplementation.getInstance(sslImplementationName);
        socketFactory = sslImplementation.getServerSocketFactory();
        endpoint.setServerSocketFactory(socketFactory);
      } else if (socketFactoryName != null) {
        socketFactory = (ServerSocketFactory) Class.forName(socketFactoryName).newInstance();
        endpoint.setServerSocketFactory(socketFactory);
      }
    } catch (Exception ex) {
      log.error(sm.getString("http11protocol.socketfactory.initerror"), ex);
      throw ex;
    }

    if (socketFactory != null) {
      Iterator<String> attE = attributes.keySet().iterator();
      while (attE.hasNext()) {
        String key = attE.next();
        Object v = attributes.get(key);
        socketFactory.setAttribute(key, v);
      }
    }

    try {
      endpoint.init();
    } catch (Exception ex) {
      log.error(sm.getString("http11protocol.endpoint.initerror"), ex);
      throw ex;
    }
    if (log.isInfoEnabled()) log.info(sm.getString("http11protocol.init", getName()));
  }
コード例 #5
0
  public void start() throws Exception {
    if (this.domain != null) {
      try {
        tpOname = new ObjectName(domain + ":" + "type=ThreadPool,name=" + getName());
        Registry.getRegistry(null, null).registerComponent(endpoint, tpOname, null);
      } catch (Exception e) {
        log.error("Can't register endpoint");
      }
      rgOname = new ObjectName(domain + ":type=GlobalRequestProcessor,name=" + getName());
      Registry.getRegistry(null, null).registerComponent(cHandler.global, rgOname, null);
    }

    try {
      endpoint.start();
    } catch (Exception ex) {
      log.error(sm.getString("http11protocol.endpoint.starterror"), ex);
      throw ex;
    }
    if (log.isInfoEnabled()) log.info(sm.getString("http11protocol.start", getName()));
  }
コード例 #6
0
 public void setBacklog(int backlog) {
   endpoint.setBacklog(backlog);
 }
コード例 #7
0
 public int getUnlockTimeout() {
   return endpoint.getUnlockTimeout();
 }
コード例 #8
0
 public int getSoTimeout() {
   return endpoint.getSoTimeout();
 }
コード例 #9
0
 public int getSoLinger() {
   return endpoint.getSoLinger();
 }
コード例 #10
0
 public boolean getTcpNoDelay() {
   return endpoint.getTcpNoDelay();
 }
コード例 #11
0
 public InetAddress getAddress() {
   return endpoint.getAddress();
 }
コード例 #12
0
 public Executor getExecutor() {
   return endpoint.getExecutor();
 }
コード例 #13
0
 public void destroy() throws Exception {
   if (log.isInfoEnabled()) log.info(sm.getString("http11protocol.stop", getName()));
   endpoint.destroy();
   if (tpOname != null) Registry.getRegistry(null, null).unregisterComponent(tpOname);
   if (rgOname != null) Registry.getRegistry(null, null).unregisterComponent(rgOname);
 }
コード例 #14
0
 public int getPort() {
   return endpoint.getPort();
 }
コード例 #15
0
 public void setExecutor(Executor executor) {
   endpoint.setExecutor(executor);
 }
コード例 #16
0
 public void setPort(int port) {
   endpoint.setPort(port);
 }
コード例 #17
0
 public int getMaxThreads() {
   return endpoint.getMaxThreads();
 }
コード例 #18
0
 public void setAddress(InetAddress ia) {
   endpoint.setAddress(ia);
 }
コード例 #19
0
 public void setMaxThreads(int maxThreads) {
   endpoint.setMaxThreads(maxThreads);
 }
コード例 #20
0
 public void setTcpNoDelay(boolean tcpNoDelay) {
   endpoint.setTcpNoDelay(tcpNoDelay);
 }
コード例 #21
0
 public int getThreadPriority() {
   return endpoint.getThreadPriority();
 }
コード例 #22
0
 public void setSoLinger(int soLinger) {
   endpoint.setSoLinger(soLinger);
 }
コード例 #23
0
 public void setThreadPriority(int threadPriority) {
   endpoint.setThreadPriority(threadPriority);
 }
コード例 #24
0
 public void setSoTimeout(int soTimeout) {
   endpoint.setSoTimeout(soTimeout);
 }
コード例 #25
0
 public int getBacklog() {
   return endpoint.getBacklog();
 }
コード例 #26
0
 public void setUnlockTimeout(int unlockTimeout) {
   endpoint.setUnlockTimeout(unlockTimeout);
 }
コード例 #27
0
  /**
   * Send an action to the connector.
   *
   * @param actionCode Type of the action
   * @param param Action parameter
   */
  @Override
  public void actionInternal(ActionCode actionCode, Object param) {

    if (actionCode == ActionCode.REQ_SSL_ATTRIBUTE) {

      try {
        if (sslSupport != null) {
          Object sslO = sslSupport.getCipherSuite();
          if (sslO != null) request.setAttribute(SSLSupport.CIPHER_SUITE_KEY, sslO);
          sslO = sslSupport.getPeerCertificateChain(false);
          if (sslO != null) request.setAttribute(SSLSupport.CERTIFICATE_KEY, sslO);
          sslO = sslSupport.getKeySize();
          if (sslO != null) request.setAttribute(SSLSupport.KEY_SIZE_KEY, sslO);
          sslO = sslSupport.getSessionId();
          if (sslO != null) request.setAttribute(SSLSupport.SESSION_ID_KEY, sslO);
          request.setAttribute(SSLSupport.SESSION_MGR, sslSupport);
        }
      } catch (Exception e) {
        log.warn(sm.getString("http11processor.socket.ssl"), e);
      }

    } else if (actionCode == ActionCode.REQ_HOST_ADDR_ATTRIBUTE) {

      if ((remoteAddr == null) && (socket != null)) {
        InetAddress inetAddr = socket.getSocket().getInetAddress();
        if (inetAddr != null) {
          remoteAddr = inetAddr.getHostAddress();
        }
      }
      request.remoteAddr().setString(remoteAddr);

    } else if (actionCode == ActionCode.REQ_LOCAL_NAME_ATTRIBUTE) {

      if ((localName == null) && (socket != null)) {
        InetAddress inetAddr = socket.getSocket().getLocalAddress();
        if (inetAddr != null) {
          localName = inetAddr.getHostName();
        }
      }
      request.localName().setString(localName);

    } else if (actionCode == ActionCode.REQ_HOST_ATTRIBUTE) {

      if ((remoteHost == null) && (socket != null)) {
        InetAddress inetAddr = socket.getSocket().getInetAddress();
        if (inetAddr != null) {
          remoteHost = inetAddr.getHostName();
        }
        if (remoteHost == null) {
          if (remoteAddr != null) {
            remoteHost = remoteAddr;
          } else { // all we can do is punt
            request.remoteHost().recycle();
          }
        }
      }
      request.remoteHost().setString(remoteHost);

    } else if (actionCode == ActionCode.REQ_LOCAL_ADDR_ATTRIBUTE) {

      if (localAddr == null) localAddr = socket.getSocket().getLocalAddress().getHostAddress();

      request.localAddr().setString(localAddr);

    } else if (actionCode == ActionCode.REQ_REMOTEPORT_ATTRIBUTE) {

      if ((remotePort == -1) && (socket != null)) {
        remotePort = socket.getSocket().getPort();
      }
      request.setRemotePort(remotePort);

    } else if (actionCode == ActionCode.REQ_LOCALPORT_ATTRIBUTE) {

      if ((localPort == -1) && (socket != null)) {
        localPort = socket.getSocket().getLocalPort();
      }
      request.setLocalPort(localPort);

    } else if (actionCode == ActionCode.REQ_SSL_CERTIFICATE) {
      if (sslSupport != null) {
        /*
         * Consume and buffer the request body, so that it does not
         * interfere with the client's handshake messages
         */
        InputFilter[] inputFilters = inputBuffer.getFilters();
        ((BufferedInputFilter) inputFilters[Constants.BUFFERED_FILTER]).setLimit(maxSavePostSize);
        inputBuffer.addActiveFilter(inputFilters[Constants.BUFFERED_FILTER]);
        try {
          Object sslO = sslSupport.getPeerCertificateChain(true);
          if (sslO != null) {
            request.setAttribute(SSLSupport.CERTIFICATE_KEY, sslO);
          }
        } catch (Exception e) {
          log.warn(sm.getString("http11processor.socket.ssl"), e);
        }
      }
    } else if (actionCode == ActionCode.ASYNC_COMPLETE) {
      if (asyncStateMachine.asyncComplete()) {
        ((JIoEndpoint) endpoint).processSocketAsync(this.socket, SocketStatus.OPEN);
      }
    } else if (actionCode == ActionCode.ASYNC_SETTIMEOUT) {
      if (param == null) return;
      long timeout = ((Long) param).longValue();
      // if we are not piggy backing on a worker thread, set the timeout
      socket.setTimeout(timeout);
    } else if (actionCode == ActionCode.ASYNC_DISPATCH) {
      if (asyncStateMachine.asyncDispatch()) {
        ((JIoEndpoint) endpoint).processSocketAsync(this.socket, SocketStatus.OPEN);
      }
    }
  }