Package com.caucho.vfs

Examples of com.caucho.vfs.TempOutputStream


   */
  @Override
  public String addTree(GitTree tree)
    throws IOException
  {
    TempOutputStream treeOut = new TempOutputStream();

    tree.toData(treeOut);
   
    int treeLength = treeOut.getLength();
   
    InputStream is = treeOut.openRead();
   
    try {
      TempOutputStream os = new TempOutputStream();
      String type = "tree";

      String contentHash = GitSystem.writeData(os, type, is, treeLength);

      writeRawGitFile(contentHash, os.openInputStream());
     
      return contentHash;
    } finally {
      is.close();
    }
View Full Code Here


                   long expireTime)
  {
    StoreConnection conn = null;
   
    try {
      TempOutputStream os = new TempOutputStream();
     
      Hessian2Output out = new Hessian2Output(os);
      out.writeObject(payload);
      out.close();
   
      conn = getConnection();

      PreparedStatement sendStmt = conn.prepareSend();

      sendStmt.setBytes(1, queueHash);
      sendStmt.setString(2, msgId);
      sendStmt.setBinaryStream(3, os.openInputStream(), 0);
      sendStmt.setInt(4, priority);
      sendStmt.setLong(5, expireTime);

      sendStmt.executeUpdate();
View Full Code Here

       long expireTime)
  {
    StoreConnection conn = null;
   
    try {
      TempOutputStream os = new TempOutputStream();
     
      Hessian2Output out = new Hessian2Output(os);
      out.writeObject(payload);
      out.close();
   
      conn = getConnection();

      PreparedStatement sendStmt = conn.prepareSend();

      sendStmt.setBytes(1, queueHash);
      sendStmt.setString(2, msgId);
      sendStmt.setBinaryStream(3, os.openInputStream(), 0);
      sendStmt.setInt(4, priority);
      sendStmt.setLong(5, expireTime);

      sendStmt.executeUpdate();
View Full Code Here

      Cipher cipher = initCipher(cookie, Cipher.ENCRYPT_MODE);
     
      SelfEncryptedCookie cookieObj
  = new SelfEncryptedCookie(cookie, createTime);

      TempOutputStream tos = new TempOutputStream();
      Hessian2Output hOut = new Hessian2Output(tos);

      hOut.writeObject(cookieObj);

      hOut.close();

      TempOutputStream cipherOut = new TempOutputStream();
      CipherOutputStream cOut
  = new CipherOutputStream(cipherOut, cipher);

      tos.writeToStream(cOut);
      tos.destroy();

      cOut.close();

      byte []encryptedData = cipherOut.toByteArray();

      cipherOut.destroy();

      return encryptedData;
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
View Full Code Here

    if (cache == null)
      return null;

    try {
      TempOutputStream os = new TempOutputStream();

      if (cache.get(id, os)) {
        InputStream is = os.getInputStream();

        StringWriter writer = new StringWriter();

        HessianDebugInputStream dis
          = new HessianDebugInputStream(is, new PrintWriter(writer));

        int ch;
        while ((ch = dis.read()) >= 0) {
        }

        return writer.toString();
      }

      os.close();
    } catch (Exception e) {
      log.log(Level.FINE, e.toString(), e);

      return e.toString();
    }
View Full Code Here

          && cacheEntry.getValueHashKey() != null
          && cacheEntry.getValueHashKey().equals(entry.getValueHashKey())) {
        return true;
      }

      TempOutputStream os = new TempOutputStream();

      if (cache.get(_id, os)) {
        InputStream is = os.getInputStream();

        SessionDeserializer in = _manager.createSessionDeserializer(is);

        if (log.isLoggable(Level.FINE)) {
          log.fine(this + " session load valueHash="
View Full Code Here

      if (! _manager.isPersistenceEnabled())
        return;

      _isModified = false;

      TempOutputStream os = new TempOutputStream();
      SessionSerializer out = _manager.createSessionSerializer(os);

      store(out);

      out.close();

      _manager.addSessionSaveSample(os.getLength());

      _cacheEntry = _manager.getCache().put(_id, os.getInputStream(),
                                            _idleTimeout);

      if (log.isLoggable(Level.FINE)) {
        log.fine(this + " session save valueHash="
                 + (_cacheEntry != null ? _cacheEntry.getValueHashKey() : null));
      }

      os.close();
    } catch (Exception e) {
      log.log(Level.WARNING, this + ": can't serialize session", e);
    }
  }
View Full Code Here

  protected HashKey writeData(HashKey oldValueHash,
                              Object value,
                              CacheSerializer serializer)
  {
    TempOutputStream os = null;

    try {
      os = new TempOutputStream();

      Sha256OutputStream mOut = new Sha256OutputStream(os);
      DeflaterOutputStream gzOut = new DeflaterOutputStream(mOut);

      serializer.serialize(value, gzOut);

      gzOut.finish();
      mOut.close();

      byte[] hash = mOut.getDigest();

      HashKey valueHash = new HashKey(hash);

      if (valueHash.equals(oldValueHash))
        return valueHash;

      int length = os.getLength();

      StreamSource source = new StreamSource(os);
      if (! _dataStore.save(valueHash, source, length)) {
        throw new IllegalStateException(L.l("Can't save the data '{0}'",
                                       valueHash));
      }

      return valueHash;
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      if (os != null)
        os.close();
    }
  }
View Full Code Here

  protected HashKey writeData(HashKey oldValueHash,
                              InputStream is)
    throws IOException
  {
    TempOutputStream os = null;

    try {
      os = new TempOutputStream();

      Sha256OutputStream mOut = new Sha256OutputStream(os);

      WriteStream out = Vfs.openWrite(mOut);

      out.writeStream(is);

      out.close();

      mOut.close();

      byte[] hash = mOut.getDigest();

      HashKey valueHash = new HashKey(hash);

      if (valueHash.equals(oldValueHash)) {
        os.destroy();
        return valueHash;
      }

      int length = os.getLength();
      StreamSource source = new StreamSource(os);

      if (! _dataStore.save(valueHash, source, length))
        throw new RuntimeException(L.l("Can't save the data '{0}'",
                                       valueHash));

      return valueHash;
    } catch (RuntimeException e) {
      throw e;
    } catch (Exception e) {
      throw new RuntimeException(e);
    } finally {
      if (os != null)
        os.close();
    }
  }
View Full Code Here

                            CacheSerializer serializer)
  {
    if (valueKey == null || valueKey == HashManager.NULL)
      return null;

    TempOutputStream os = null;

    try {
      os = new TempOutputStream();

      WriteStream out = Vfs.openWrite(os);

      if (! _dataStore.load(valueKey, out)) {
        requestClusterData(valueKey, flags);

        if (! _dataStore.load(valueKey, out)) {
          out.close();
          System.out.println("MISSING_DATA: " + valueKey);
       
          return null;
        }
      }

      out.close();

      InputStream is = os.openInputStream();

      try {
        InflaterInputStream gzIn = new InflaterInputStream(is);

        Object value = serializer.deserialize(gzIn);

        gzIn.close();

        return value;
      } finally {
        is.close();
      }
    } catch (Exception e) {
      log.log(Level.WARNING, e.toString(), e);
     
      return null;
    } finally {
      if (os != null)
        os.close();
    }
  }
View Full Code Here

TOP

Related Classes of com.caucho.vfs.TempOutputStream

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.