Package com.caucho.vfs

Examples of com.caucho.vfs.WriteStream


                  HttpServletRequest request,
                  HttpServletResponse response,
                  ServletContext application)
    throws IOException
  {
    WriteStream logStream = getLogStream();

    if (logStream == null)
      return;

    Throwable t = e;
    while (t != null) {
      e = t;
       
      if (e instanceof ServletException)
        t = ((ServletException) e).getRootCause();
      else if (e instanceof ExceptionWrapper)
        t = ((ExceptionWrapper) e).getRootCause();
      else
        t = null;
    }

    CharBuffer cb = CharBuffer.allocate();

    QDate.formatLocal(cb, Alarm.getCurrentTime(), "[%Y/%m/%d %H:%M:%S] ");

    cb.append(message);

    logStream.log(cb.close());

    if (e != null && ! (e instanceof CompileException))
      logStream.log(e);

    logStream.flush();
  }
View Full Code Here


  public AbstractSocketLink()
  {
    _readStream = new ReadStream();
    _readStream.setReuseBuffer(true);
    _writeStream = new WriteStream();
    _writeStream.setReuseBuffer(true);
  }
View Full Code Here

  {
    if (_isWriteClosed.getAndSet(true))
      return;

    try {
      WriteStream out = _controller.getWriteStream();
   
      out.write(0x81);
      out.write(0x00);
      out.flush();
    } catch (IOException e) {
      log.log(Level.WARNING, e.toString(), e);
    } finally {
      disconnect();
    }
View Full Code Here

  }
 
  void flush()
    throws IOException
  {
    WriteStream out = _controller.getWriteStream();
   
    out.flush();
  }
View Full Code Here

      s = "null";

    OutputStream out = _out;
   
    if (out instanceof WriteStream) {
      WriteStream wOut = (WriteStream) out;

      wOut.print(s);
    }
    else {
      int length = s.length();

      if (_buffer == null)
View Full Code Here

  {
    if (_isWriteClosed.getAndSet(true))
      return;

    try {
      WriteStream out = getWriteStream();
   
      out.write(0x81);
      out.write(0x00);
      out.flush();
    } catch (IOException e) {
      log.log(Level.WARNING, e.toString(), e);
    } finally {
      disconnect();
    }
View Full Code Here

  }
 
  void flush()
    throws IOException
  {
    WriteStream out = getWriteStream();
   
    out.flush();
  }
View Full Code Here

        if (archivePath == null) {
          createArchive(deployPath, plan, archiveIs);
          archivePath = deployPath;
        }
        else {
          WriteStream deployStream = deployPath.openWrite();

          try {
            deployStream.writeFile(archivePath);
          }
          finally {
            deployStream.close();
          }
        }

        mxbean.update();
View Full Code Here

    }
    else {
      earFileName = null;
    }

    WriteStream archiveStream =  null;
    ZipInputStream zipInputStream = null;
    ZipOutputStream zipOutputStream = null;

    try {
      archiveStream = archivePath.openWrite();
      zipOutputStream = new ZipOutputStream(archiveStream);

      zipInputStream = new ZipInputStream(archiveIs);

      ZipEntry zipEntry = zipInputStream.getNextEntry();

      TreeSet<String> entryNames = new TreeSet<String>();

      int copyCount = 0;

      while (zipEntry != null) {
        if (log.isLoggable(Level.FINEST))
          log.log(Level.FINEST, L.l("jsr88 copying entry {0}", zipEntry));

        entryNames.add(zipEntry.getName());

        zipOutputStream.putNextEntry(zipEntry);

        try {
          for (int ch = zipInputStream.read(); ch != -1; ch = zipInputStream.read())
            zipOutputStream.write(ch);
        } catch (IOException e) {
          // XXX: unexpected end of ZLIB input stream.
          log.log(Level.WARNING, L.l("exception copying entry {0}", zipEntry), e);
        }

        zipEntry = zipInputStream.getNextEntry();

        copyCount++;
      }

      if (log.isLoggable(Level.FINER))
        log.log(Level.FINER, L.l("copied {0} entries", copyCount));

      if (archiveIs.read() != -1) {
        if (log.isLoggable(Level.FINE))
          log.log(Level.FINE, L.l("unexpected data at end of archive"));

        while (archiveIs.read() != -1) {}
      }

      int fileCount = 0;

      for (DeploymentPlan.PlanFile file : plan.getFileList()) {
        String zipEntryName = file.getPath();
        if (zipEntryName.startsWith("/"))
          zipEntryName = zipEntryName.substring(1);

        if (log.isLoggable(Level.FINEST))
          log.log(Level.FINEST, L.l("jsr88 plan file {0} output to {1}", file, zipEntryName));

        if (entryNames.contains(zipEntryName))
          log.log(Level.WARNING, L.l("plan file {0} overwrites existing file", zipEntryName));

        entryNames.add(zipEntryName);

        zipEntry = new ZipEntry(zipEntryName);
        zipOutputStream.putNextEntry(zipEntry);
        file.writeToStream(zipOutputStream);

        fileCount++;
      }

      if (log.isLoggable(Level.FINER))
        log.log(Level.FINER, L.l("created {0} entries from plan", fileCount));

      zipInputStream.close();
      zipInputStream = null;

      zipOutputStream.close();
      zipOutputStream = null;

      archiveStream.close();
      archiveStream = null;
    }
    finally {
      if (zipInputStream != null) {
        try {
          zipInputStream.close();
        }
        catch (Exception ex) {
          log.log(Level.FINER, ex.toString(), ex);
        }
      }

      if (zipOutputStream != null) {
        try {
          zipOutputStream.close();
        }
        catch (Exception ex) {
          log.log(Level.FINER, ex.toString(), ex);
        }
      }

      if (archiveStream != null) {
        try {
          archiveStream.close();
        }
        catch (Exception ex) {
          log.log(Level.FINER, ex.toString(), ex);
        }
      }
View Full Code Here

  }
 
  public void switchToHmtp(boolean isUnidir)
  {
    try {
      WriteStream out = getOutputStream();

      if (isUnidir)
        out.write(HmuxRequest.HMUX_TO_UNIDIR_HMTP);
      else
        out.write(HmuxRequest.HMUX_SWITCH_TO_HMTP);
            
      out.write(0);
      out.write(1);
      boolean isAdmin = true;
      out.write(isAdmin ? 1 : 0);
      out.flush();
    } catch (IOException e) {
      throw new BamException(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.