Package com.caucho.vfs

Examples of com.caucho.vfs.WriteStream


  public void init(HttpServletResponse response)
  {
    _bodyStream = new BodyResponseStream();
   _stream = _bodyStream;
   
    _out = new WriteStream(_tempStream);
    _bodyStream.setWriter(_out.getPrintWriter());
   
    setResponse(response);
    _response = response;
View Full Code Here


   * complete the response.
   */
  public void close()
    throws IOException
  {
    WriteStream out = _out;
    _out = null;

    if (out != null)
      out.close();
  }
View Full Code Here

  }

  public String completeJsf()
    throws IOException
  {
    WriteStream out = _out;
    _out = null;

    if (out != null)
      out.flush();
   
    ReadStream rs = _tempStream.openRead();
    StringBuilder sb = new StringBuilder();
   
    int ch;
View Full Code Here

    try {
      HmuxStream stream = (HmuxStream) openReadWriteImpl();
      stream.setMethod("PROPFIND");
      stream.setAttribute("Depth", "1");

      WriteStream os = new WriteStream(stream);
      os.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
      os.println("<propfind xmlns=\"DAV:\"><prop>");
      os.println("<resourcetype/>");
      os.println("</prop></propfind>");
      os.flush();

      ReadStream is = new ReadStream(stream);
   
      ListHandler handler = new ListHandler(getPath());
      XmlParser parser = new XmlParser();
      parser.setContentHandler(handler);

      parser.parse(is);

      is.close();
      os.close();
      stream.close();

      ArrayList<String> names = handler.getNames();
      String []list = new String[names.size()];
      names.toArray(list);
View Full Code Here

  @Override
  protected WriteStream openWrite(HttpServletResponse response)
    throws IOException
  {
    WriteStream ws;
   
    // XXX: check if correct.  PHP doesn't expect the lower levels
    // to deal with the encoding, so this may be okay
    if (response instanceof CauchoResponse) {
      ws = Vfs.openWrite(((CauchoResponse) response).getResponseStream());
View Full Code Here

    } catch (Exception e) {
      log().log(Level.ALL, e.toString(), e);
    }
   
    // #4333 - check watchdog-manager.log can be written
    WriteStream testOut = logPath.openAppend();
    testOut.close();
   
    if (! logPath.canWrite()) {
      throw new ConfigException("Cannot open " + logPath.getNativePath()
                                + " required for Resin start. Please check permissions");
    }

    RotateStream logStream = RotateStream.create(logPath);
    logStream.setRolloverSize(64L * 1024 * 1024);
    logStream.init();
    WriteStream out = logStream.getStream();
    out.setDisableClose(true);

    EnvironmentStream.setStdout(out);
    EnvironmentStream.setStderr(out);

    LogHandlerConfig log = new LogHandlerConfig();
View Full Code Here

    public void request(InputStream is, OutputStream os)
      throws IOException
    {
      Thread.yield();

      WriteStream out = Vfs.openWrite(os);
      out.setDisableClose(true);

      ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
      try {
        _vfsStream.init(is, os);
        _conn.setStream(is, os);
        _conn.setLocalAddress(_localAddress);
        _conn.setLocalPort(_port);
        _conn.setRemoteAddress(_remoteAddress);
        _conn.setRemotePort(9666);
        // _conn.setSecure(_isSecure);

        try {
          Thread.sleep(10);
        } catch (Exception e) {
        }

        while (_request.handleRequest()) {
          out.flush();
        }
      } catch (EOFException e) {
      } finally {
        out.flush();

        Thread.currentThread().setContextClassLoader(oldLoader);
      }
    }
View Full Code Here

    try {
      _socket = new Socket(host, port);
      _socket.setSoTimeout(10000);
      SocketStream s = new SocketStream(_socket);
   
      _os = new WriteStream(s);
      _is = new ReadStream(s, _os);

      String line = _is.readLine();
     
      log.fine("smtp connection to " + host + ":" + port + " succeeded");
View Full Code Here

    throws MessagingException
  {
    Socket socket = _socket;
    _socket = null;

    WriteStream os = _os;
    _os = null;
   
    setConnected(false);

    try {
      if (os != null) {
        os.print("QUIT\r\n");
        os.flush();
      }
    } catch (IOException e) {
    }

    try {
View Full Code Here

    EnvironmentClassLoader envLoader
      = EnvironmentClassLoader.create(_system.getClassLoader());
   
    Thread thread = Thread.currentThread();
   
    WriteStream jvmOut = null;
    ServerSocket ss = null;
    Socket s = null;

    try {
      thread.setContextClassLoader(envLoader);
      envLoader.start();

      ss = new ServerSocket(0, 5, InetAddress.getByName("127.0.0.1"));

      int port = ss.getLocalPort();

      log.warning("Watchdog starting Resin[" + _watchdog.getId() + "]");

      jvmOut = createJvmOut();
     
      _process = createProcess(port, jvmOut);
     
      if (_process != null) {
        if (_process instanceof JniProcess)
          _pid = ((JniProcess) _process).getPid();
        else
          _pid = 0;

        InputStream stdIs = _process.getInputStream();
        _stdOs = _process.getOutputStream();

        WatchdogProcessLogThread logThread
          = new WatchdogProcessLogThread(stdIs, jvmOut);

        ThreadPool.getCurrent().start(logThread);

        s = connectToChild(ss);
       
        message(new StartInfoMessage(_watchdog.isRestart(),
                                     _watchdog.getRestartMessage()));

        _status = _process.waitFor();

        logStatus(_status);
      }
    } catch (Exception e) {
      log.log(Level.WARNING, e.toString(), e);

      try {
        Thread.sleep(5000);
      } catch (Exception e1) {
      }
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
    } finally {
      if (ss != null) {
        try {
          ss.close();
        } catch (Exception e) {
        }
      }

      try {
        if (s != null)
          s.close();
      } catch (Throwable e) {
        log.log(Level.FINER, e.toString(), e);
      }

      kill();

      if (jvmOut != null && ! _watchdog.isConsole()) {
        try {
          synchronized (jvmOut) {
            jvmOut.close();
          }
        } catch (Exception e) {
        }
      }
View Full Code Here

TOP

Related Classes of com.caucho.vfs.WriteStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.