⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 magic8ballrequest.java

📁 RESIN 3.2 最新源码
💻 JAVA
字号:
package example;import com.caucho.util.L10N;import java.util.logging.Logger;import java.util.logging.Level;import com.caucho.vfs.*;import com.caucho.server.port.ServerRequest;import com.caucho.server.connection.Connection;import java.io.IOException;/** * Protocol specific information for each request.  An instance of this * object may be reused to reduce memory allocations. */public class Magic8BallRequest implements ServerRequest {  static protected final Logger log =     Logger.getLogger(Magic8BallRequest.class.getName());  static final L10N L = new L10N(Magic8BallRequest.class);  Connection _conn;  Magic8BallProtocol _protocol;  // the parser is reset for each request  Parser _parser = new Parser();  Magic8Ball _magic8ball = new Magic8Ball();  /**   *   */  public Magic8BallRequest(Magic8BallProtocol protocol, Connection conn)  {    _protocol = protocol;    _conn = conn;  }  /**   * Initialize the connection.  At this point, the current thread is the   * connection thread.   */  public void init()  {  }  /**   * Handle a new connection.  The controlling Server may call   * handleRequest again after the connection completes, so the   * implementation must initialize any variables for each connection.   */  public boolean handleRequest() throws IOException  {    ReadStream readStream = _conn.getReadStream();    WriteStream writeStream = _conn.getWriteStream();    try {      _parser.init(readStream);      AbstractCommand cmd = null;      do {        String result = null;        String error = null;        cmd = _parser.nextCommand();        if (_parser.isError()) {          error = _parser.getError();        }        else if (cmd != null) {          result = cmd.act(_magic8ball);          if (cmd.isError())            error = cmd.getError();        }        if (error != null) {          writeStream.print("ERROR: ");          writeStream.println(_parser.getError());          break;        }        else if (result != null) {          writeStream.print("RESULT: ");          writeStream.println(result);        }      } while (cmd != null);    } catch (Throwable e) {      log.log(Level.WARNING, e.toString(), e);    }    return false;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -