Package com.caucho.vfs

Examples of com.caucho.vfs.Depend


  {
    _cacheDepends = new ArrayList<Depend>();
    for (int i = 0; i < depends.size(); i++) {
      Path path = depends.get(i);

      Depend depend = new Depend(path);
      depend.setRequireSource(getRequireSource());

      if (! _cacheDepends.contains(depend))
        _cacheDepends.add(depend);
    }
  }
View Full Code Here


      for (int i = 0; i < depends.size(); i++) {
        PersistentDependency dependency = depends.get(i);

        if (dependency instanceof Depend) {
          Depend depend = (Depend) dependency;
          long modified = depend.getLastModified();
          if (lastModified < modified)
            lastModified = modified;
        }
      }

      for (int i = 0; cacheDepends != null && i < cacheDepends.size(); i++) {
        Depend depend = cacheDepends.get(i);
        long modified = depend.getLastModified();
        if (lastModified < modified)
          lastModified = modified;
      }

      return lastModified;
View Full Code Here

        return null;

      StaticPage page = new StaticPage(staticPath, true);

      for (int i = 0; i < dependList.size(); i++) {
        Depend depend = dependList.get(i);

        if (depend.isModified())
          return null;

        page._caucho_addDepend(depend);
      }
View Full Code Here

    if (_path == null)
      return;
   
    try {
      _lastCheck = Alarm.getCurrentTime();
      _depend = new Depend(_path);

      if (log.isLoggable(Level.FINE))
  log.fine(this + " loading users from " + _path);
     
      _userMap = new Hashtable<String,PasswordUser>();
View Full Code Here

    if (_path == null)
      return;
   
    try {
      _lastCheck = Alarm.getCurrentTime();
      _depend = new Depend(_path);

      if (log.isLoggable(Level.FINE))
  log.fine(this + " loading users from " + _path);
     
      _roleMap = new Hashtable<String,Role>();
View Full Code Here

      return;
   
    synchronized (this) {
      try {
  _lastCheck = Alarm.getCurrentTime();
  _depend = new Depend(_path);

  if (log.isLoggable(Level.FINE))
    log.fine(this + " loading users from " + _path);
     
  _userMap = new Hashtable<String,PasswordUser>();
View Full Code Here

      _depends.add(path);

      if (_dependList == null)
        _dependList = new ArrayList<Depend>();

      _dependList.add(new Depend(path));
    }
  }
View Full Code Here

  {
    if (_dependList == null)
      return false;

    for (int i = 0; i < _dependList.size(); i++) {
      Depend depend = _dependList.get(i);

      if (depend.isModified())
        return true;
    }

    return false;
  }
View Full Code Here

  /**
   * Adds a dependency.
   */
  public void addDepend(Path path)
  {
    Depend depend = new Depend(path);

    depend.setRequireSource(_quercus.isRequireSource());

    _dependList.add(depend);
    _depend.add(depend);
  }
View Full Code Here

      parent.mkdirs();
    } catch (Throwable e) {
    }

    Path dependPath = expandDir.lookup("META-INF/resin-war.digest");
    Depend depend = null;

    // XXX: change to a hash
    if (dependPath.canRead()) {
      ReadStream is = null;
      try {
        is = dependPath.openRead();

        String line = is.readLine();

        long digest;

        if (line != null) {
          digest = Long.parseLong(line.trim());

          depend = new Depend(archivePath, digest);

          if (! depend.isModified())
            return true;
        }
      } catch (Throwable e) {
        log.log(Level.FINE, e.toString(), e);
      } finally {
        if (is != null)
          is.close();
      }
    }

    if (depend == null)
      depend = new Depend(archivePath);

    try {
      if (log.isLoggable(Level.INFO))
        getLog().info("expanding " + archivePath + " to " + expandDir);

      removeExpandDirectory(expandDir);

      expandDir.mkdirs();

      ReadStream rs = archivePath.openRead();
      ZipInputStream zis = new ZipInputStream(rs);

      try {
        ZipEntry entry = zis.getNextEntry();

        byte []buffer = new byte[1024];

        while (entry != null) {
          String name = entry.getName();
          Path path = expandDir.lookup(name);

          if (entry.isDirectory())
            path.mkdirs();
          else {
            long entryLength = entry.getSize();
            long length = entryLength;

            // XXX: avoids unexpected end of ZLIB input stream.
            // XXX: This should be a really temp. workaround.
            int bufferLen = buffer.length;

            // XXX: avoids unexpected end of ZLIB input stream.
            if (length < 0) {
              // bufferLen = 1;
              length = Long.MAX_VALUE / 2;
            }
            else if (length < bufferLen) {
              bufferLen = (int) length;
            }

            long lastModified = entry.getTime();
            path.getParent().mkdirs();

            WriteStream os = path.openWrite();
            int len = 0;
            try {
              if (bufferLen == 1) {
                for (int ch = zis.read(); ch != -1; ch = zis.read())
                  os.write(ch);
              }
              else {
                while ((len = zis.read(buffer, 0, bufferLen)) > 0) {
                  os.write(buffer, 0, len);

                  // XXX: avoids unexpected end of ZLIB input stream.
                  /*
                  if (len < bufferLen) {
                    for (int ch = zis.read(); ch != -1; ch = zis.read())
                      os.write(ch);

                    break;
                  }
                  */

                  length -= len;

                  if (length < bufferLen) {
                    bufferLen = (int) length;
                  }
                }
              }
            } catch (IOException e) {
              Exception ex = new Exception("IOException when expanding entry "+entry+" in "+archivePath+", entry.length: "+entryLength+" entry.compressed: "+entry.getCompressedSize()+", bufferLen: "+bufferLen+", read len: "+len+", remaining: "+length,e);

              log.log(Level.FINE, ex.toString(), ex);
            } finally {
              os.close();
            }

            if (lastModified > 0)
              path.setLastModified(lastModified);
          }

          try {
            entry = zis.getNextEntry();
          } catch (IOException e) {
            log.log(Level.FINE, e.toString(), e);

            // XXX: avoids unexpected end of ZLIB input stream.
            break;
          }
        }
      } finally {
        try {
          zis.close();
        } catch (IOException e) {
        }

        rs.close();
      }
    } catch (IOException e) {
      log.log(Level.WARNING, e.toString(), e);
      // If the jar is incomplete, it should throw an exception here.
      return false;
    }

    try {
      dependPath.getParent().mkdirs();
      WriteStream os = dependPath.openWrite();

      os.println(depend.getDigest());

      os.close();
    } catch (Throwable e) {
      log.log(Level.WARNING, e.toString(), e);
    }
View Full Code Here

TOP

Related Classes of com.caucho.vfs.Depend

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.