コード例 #1
0
  private static void addAttachIfNecessary(Config config, Log log) {

    String srcName = null, trgName = null;
    String archBits = (SystemUtil.getJREArch() == SystemUtil.ARCH_64) ? "64" : "32";

    // Windows
    if (SystemUtil.isWindows()) {
      trgName = "attach.dll";
      srcName = "windows" + archBits + "/" + trgName;
    }
    // Linux
    else if (SystemUtil.isLinux()) {
      trgName = "libattach.so";
      srcName = "linux" + archBits + "/" + trgName;
    }
    // Solaris
    else if (SystemUtil.isSolaris()) {
      trgName = "libattach.so";
      srcName = "solaris" + archBits + "/" + trgName;
    }
    // Mac OSX
    else if (SystemUtil.isMacOSX()) {
      trgName = "libattach.dylib";
      srcName = "macosx" + archBits + "/" + trgName;
    }

    if (srcName != null) {

      // create dll if necessary
      Resource binDir = getBinDirectory(config);
      Resource trg = binDir.getRealResource(trgName);
      if (!trg.exists() || trg.length() == 0) {
        log.info("Instrumentation", "deploy /resource/bin/" + srcName + " to " + trg);
        InputStream src = InfoImpl.class.getResourceAsStream("/resource/bin/" + srcName);
        try {
          IOUtil.copy(src, trg, true);
        } catch (IOException e) {
          log.log(Log.LEVEL_ERROR, "Instrumentation", e);
        }
      }

      // set directory to library path
      SystemUtil.addLibraryPathIfNoExist(binDir, log);
    }
  }
コード例 #2
0
  private static Resource createToolsJar(Config config) throws IOException {
    Resource dir = getDeployDirectory(config);

    String os = "bsd"; // used for Mac OS X
    if (SystemUtil.isWindows()) {
      os = "windows";
    } else if (SystemUtil.isLinux()) { // not MacOSX
      os = "linux";
    } else if (SystemUtil.isSolaris()) {
      os = "solaris";
    }
    String name = "tools-" + os + "-" + TOOLS_VERSION + ".jar";
    Resource trg = dir.getRealResource(name);

    if (!trg.exists() || trg.length() == 0) {

      InputStream jar = InfoImpl.class.getResourceAsStream("/resource/lib/" + name);
      IOUtil.copy(jar, trg, true);
    }
    return trg;
  }