Package com.caucho.vfs

Examples of com.caucho.vfs.Path


  protected Class<?> loadClass(String name, boolean resolve)
    throws ClassNotFoundException
  {
    String className = name.replace('.', '/') + ".class";

    Path path = _resinJar.lookup(className);

    int length = (int) path.getLength();

    if (length > 0
        && (className.startsWith("com/caucho/bootjni")
            || className.equals("com/caucho/vfs/JniFileStream.class")
            || className.equals("com/caucho/vfs/JniServerSocketImpl.class"))) {
      byte []buffer = new byte[length];

      try {
        ReadStream is = null;
        try {
          is = path.openRead();

          is.readAll(buffer, 0, buffer.length);

          Class<?> cl = defineClass(name, buffer, 0, buffer.length,
                                 (CodeSource) null);
View Full Code Here


   * Returns the full library path for the name.
   */
  @Override
  public String findLibrary(String name)
  {
    Path path = _libexec.lookup("lib" + name + ".so");

    if (path.canRead()) {
      return path.getNativePath();
    }
   
    path = _libexec.lookup("lib" + name + ".jnilib");

    if (path.canRead()) {
      return path.getNativePath();
    }

    return super.findLibrary(name);
  }
View Full Code Here

    return _rootDirectory;
  }

  public Path getLogDirectory()
  {
    Path logDirectory = _args.getLogDirectory();

    if (logDirectory != null)
      return logDirectory;
    if (_watchdogLog != null && _watchdogLog.getLogDirectory() != null)
      return _watchdogLog.getLogDirectory();
View Full Code Here

  String getJavaExe()
  {
    if (_javaExe != null)
      return _javaExe.getNativePath();

    Path javaHome = Vfs.lookup(System.getProperty("java.home"));

    if (javaHome.getTail().equals("jre"))
      javaHome = javaHome.getParent();

    if (javaHome.lookup("bin/javaw.exe").canRead())
      return javaHome.lookup("bin/javaw").getNativePath();
    else if (javaHome.lookup("bin/java.exe").canRead())
      return javaHome.lookup("bin/java").getNativePath();
    else if (javaHome.lookup("bin/java").canRead())
      return javaHome.lookup("bin/java").getNativePath();

    javaHome = Vfs.lookup(System.getProperty("java.home"));

    if (javaHome.lookup("bin/javaw.exe").canRead())
      return javaHome.lookup("bin/javaw").getNativePath();
    else if (javaHome.lookup("bin/java.exe").canRead())
      return javaHome.lookup("bin/java").getNativePath();
    else if (javaHome.lookup("bin/java").canRead())
      return javaHome.lookup("bin/java").getNativePath();

    return "java";
  }
View Full Code Here

    Vfs.setPwd(_args.getRootDirectory());
   
    boolean isLogDirectoryExists = getLogDirectory().exists();

    Path logPath = getLogDirectory().lookup("watchdog-manager.log");
   
    try {
      getLogDirectory().mkdirs();
    } 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();
    log.setName("");
    log.setPath(logPath);
    log.init();

    Thread thread = Thread.currentThread();
    thread.setContextClassLoader(_system.getClassLoader());

    ThreadPool.getThreadPool().setIdleMin(4);
    ThreadPool.getThreadPool().setPriorityIdleMin(4);

    ResinELContext elContext = _args.getELContext();
   
    Resin resin = Resin.createWatchdog(_system);
   
    if (_args.getDataDirectory() != null)
      resin.setDataDirectory(_args.getDataDirectory());
   
    resin.preConfigureInit();
   
    // XXX: needs to be config

    InjectManager cdiManager = InjectManager.create();

    Config.setProperty("resinHome", elContext.getResinHome());
    Config.setProperty("resin", elContext.getResinVar());
    Config.setProperty("server", elContext.getServerVar());
    Config.setProperty("java", elContext.getJavaVar());
    Config.setProperty("system", System.getProperties());
    Config.setProperty("getenv", System.getenv());

    ResinConfigLibrary.configure(cdiManager);

    _watchdogPort = _args.getWatchdogPort();
   
    readConfig(_args);
   
    WatchdogChild server = null;
   
    String serverId = _args.getServerId();

    if (_args.isDynamicServer()) {
      serverId = _args.getDynamicServerId();
    }
     
    server = _watchdogMap.get(_args.getServerId());

    if (server == null)
      throw new IllegalStateException(L().l("'{0}' is an unknown server",
                                            serverId));
   
    JniBoot boot = new JniBoot();
    Path logDirectory = getLogDirectory();

    if (boot.isValid()) {
      if (! isLogDirectoryExists) {
        logDirectory.mkdirs();

        boot.chown(logDirectory, server.getUserName(), server.getGroupName());
      }
    }

View Full Code Here

    return _args.getRootDirectory();
  }

  Path getLogDirectory()
  {
    Path logDirectory = _args.getLogDirectory();

    if (logDirectory != null)
      return logDirectory;
    else
      return getRootDirectory().lookup("log");
View Full Code Here

    if (depends == null)
      return 0;

    long lastModified = 0;
    for (int i = 0; i < depends.size(); i++) {
      Path path = (Path) depends.get(i);

      long time = path.getLastModified();
      if (time > lastModified)
        lastModified = time;
    }

    return lastModified;
View Full Code Here

                                WriteStream out)
    throws IOException
  {
    // watchdog/0210
    // Path pwd = rootDirectory;
    Path chroot = _watchdog.getChroot();
    Path processPwd = _watchdog.getPwd();

    HashMap<String,String> env = buildEnv();

    ArrayList<String> jvmArgs = buildJvmArgs();

    ArrayList<String> resinArgs = buildResinArgs(socketPort);

    addCommandLineArguments(jvmArgs, resinArgs);

    jvmArgs.add("com.caucho.server.resin.Resin");

    jvmArgs.addAll(resinArgs);

    if (_watchdog.isVerbose()) {
      logVerboseArguments(out, jvmArgs);

      logVerboseEnvironment(out, env);
    }

    Boot boot = getJniBoot();
    if (boot != null) {
      boot.clearSaveOnExec();

      ArrayList<QServerSocket> boundSockets = new ArrayList<QServerSocket>();

      try {
        if (_watchdog.getUserName() != null) {
          for (TcpSocketLinkListener port : _watchdog.getPorts()) {
            QServerSocket ss = port.bindForWatchdog();

            if (ss == null)
              continue;

            boundSockets.add(ss);

            if (ss.setSaveOnExec()) {
              jvmArgs.add("-port");
              jvmArgs.add(String.valueOf(ss.getSystemFD()));
              jvmArgs.add(String.valueOf(port.getAddress()));
              jvmArgs.add(String.valueOf(port.getPort()));
            }
            else {
              ss.close();
            }
          }
        }

        String chrootPath = null;

        if (chroot != null)
          chrootPath = chroot.getNativePath();

        Process process = boot.exec(jvmArgs, env,
                                    chrootPath,
                                    processPwd.getNativePath(),
                                    _watchdog.getUserName(),
                                    _watchdog.getGroupName());

        if (process != null) {
          return process;
        }
      } catch (ConfigException e) {
        log.warning(e.getMessage());
      } catch (Throwable e) {
        log.log(Level.WARNING, e.toString(), e);
      } finally {
        for (int i = 0; i < boundSockets.size(); i++) {
          try {
            boundSockets.get(i).close();
          } catch (Throwable e) {
          }
        }
      }
    }

    if (_watchdog.getUserName() != null) {
      if (_watchdog.isConsole())
        throw new ConfigException(L.l("<user-name> requires compiled JNI started with 'start'.  Resin cannot use <user-name> when started as a console process."));
      else
        throw new ConfigException(L.l("<user-name> requires compiled JNI."));
    }

    if (_watchdog.getGroupName() != null) {
      if (_watchdog.isConsole())
        throw new ConfigException(L.l("<group-name> compiled JNI started with 'start'.  Resin cannot use <group-name> when started as a console process."));
      else
        throw new ConfigException(L.l("<group-name> compiled JNI."));
    }

    ProcessBuilder builder = new ProcessBuilder();

    builder.directory(new File(processPwd.getNativePath()));

    builder.environment().putAll(env);

    builder = builder.command(jvmArgs);
View Full Code Here

  {
    HashMap<String,String> env = new HashMap<String,String>();

    env.putAll(System.getenv());
   
    Path resinHome = _watchdog.getResinHome();

    ArrayList<String> classPathList = new ArrayList<String>();
    classPathList.addAll(_watchdog.getJvmClasspath());
    String classPath
      = WatchdogArgs.calculateClassPath(classPathList, resinHome);

    env.put("CLASSPATH", classPath);

    if (_watchdog.is64bit()) {
      WatchdogClient.appendEnvPath(env,
                                   "LD_LIBRARY_PATH",
                                   resinHome.lookup("libexec64").getNativePath());
      WatchdogClient.appendEnvPath(env,
                                   "LD_LIBRARY_PATH_64",
                                   resinHome.lookup("libexec64").getNativePath());
      WatchdogClient.appendEnvPath(env,
                    "DYLD_LIBRARY_PATH",
                    resinHome.lookup("libexec64").getNativePath());
      if (CauchoSystem.isWindows())
        WatchdogClient.appendEnvPath(env,
                      "Path",
                      resinHome.lookup("win64").getNativePath());
    }
    else {
      WatchdogClient.appendEnvPath(env,
                    "LD_LIBRARY_PATH",
                    resinHome.lookup("libexec").getNativePath());
      WatchdogClient.appendEnvPath(env,
                    "DYLD_LIBRARY_PATH",
                    resinHome.lookup("libexec").getNativePath());

      if (CauchoSystem.isWindows())
        WatchdogClient.appendEnvPath(env,
                      "Path",
                      resinHome.lookup("win32").getNativePath());
    }

    return env;
  }
View Full Code Here

    String systemClassLoader = _watchdog.getSystemClassLoader();
    if (systemClassLoader != null && ! "".equals(systemClassLoader)) {
      jvmArgs.add("-Djava.system.class.loader=" + systemClassLoader);
    }
   
    Path resinHome = _watchdog.getResinHome();
   
    if (! isEndorsed) {
      String endorsed = System.getProperty("java.endorsed.dirs");
      String resinEndorsed = resinHome.getNativePath() + File.separator + "endorsed";
     
     
      if (endorsed != null)
        endorsed = endorsed + File.pathSeparator + resinEndorsed;
      else
        endorsed = resinEndorsed;
     
      jvmArgs.add("-Djava.endorsed.dirs=" + endorsed);
    }
   
    // #2567
    jvmArgs.add("-Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl");
    jvmArgs.add("-Djava.awt.headless=true");

    jvmArgs.add("-Dresin.home=" + resinHome.getFullPath());

    if (! _watchdog.hasXss())
      jvmArgs.add("-Xss1m");

    if (! _watchdog.hasXmx())
View Full Code Here

TOP

Related Classes of com.caucho.vfs.Path

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.