Example #1
0
  public static lucee.runtime.type.Struct call(PageContext pc, String strDialect)
      throws PageException {
    int dialect = ConfigWebUtil.toDialect(strDialect, -1);
    if (dialect == -1)
      throw new FunctionException(
          pc, "GetTagList", 1, "dialect", "invalid dialect [" + strDialect + "] defintion");

    return _call(pc, dialect);
  }
  private static Resource getDeployDirectory(Config config) {
    Resource dir = ConfigWebUtil.getConfigServerDirectory(config);
    if (dir == null || !dir.isWriteable() || !dir.isReadable())
      dir =
          ResourceUtil.toResource(
              CFMLEngineFactory.getClassLoaderRoot(SystemUtil.getLoaderClassLoader()));

    return dir;
  }
 private static Resource getBinDirectory(Config config) {
   Resource dir = ConfigWebUtil.getConfigServerDirectory(config);
   if (dir == null || !dir.isWriteable() || !dir.isReadable())
     dir =
         ResourceUtil.toResource(
             CFMLEngineFactory.getClassLoaderRoot(SystemUtil.getLoaderClassLoader()));
   else {
     dir = dir.getRealResource("bin");
     if (!dir.exists()) dir.mkdir();
   }
   return dir;
 }
Example #4
0
  @Override
  public ResourceProvider init(String scheme, Map args) {
    this.scheme = scheme;
    this.args = args;

    // CFC Path
    cfcPath = Caster.toString(args.get("cfc"), null);
    if (StringUtil.isEmpty(cfcPath, true)) cfcPath = Caster.toString(args.get("component"), null);
    cfcPath = ConfigWebUtil.fixComponentPath(cfcPath);

    // use Streams for data
    Boolean _useStreams = Caster.toBoolean(args.get("use-streams"), null);
    if (_useStreams == null) _useStreams = Caster.toBoolean(args.get("usestreams"), null);

    if (_useStreams != null) useStreams = _useStreams.booleanValue();

    return this;
  }
  public static synchronized Instrumentation getInstrumentation(final Config config) {

    final Log log = config.getLog("application");
    final CFMLEngine engine = ConfigWebUtil.getEngine(config);
    Instrumentation instr = _getInstrumentation(log, config);

    // agent already exist
    if (instr != null) return instr;

    AccessController.doPrivileged(
        new PrivilegedAction<Object>() {
          @Override
          public Object run() {
            ClassLoader ccl = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
            try {

              JavaVendor vendor = JavaVendor.getCurrentVendor();
              Resource toolsJar = null;
              // When running on IBM, the attach api classes are packaged in vm.jar which is a part
              // of the default vm classpath.
              RefBoolean useOurOwn = new RefBooleanImpl(true);
              // if (!vendor.isIBM()) {
              // If we can't find the tools.jar and we're not on IBM we can't load the agent.
              toolsJar = findToolsJar(config, log, useOurOwn);
              if (toolsJar == null) {
                return null;
              }
              // }
              log.info("Instrumentation", "tools.jar used:" + toolsJar);

              // add the attach native library
              if (useOurOwn.toBooleanValue()) addAttachIfNecessary(config, log);

              Class<?> vmClass = loadVMClass(toolsJar, log, vendor);
              log.info(
                  "Instrumentation",
                  "loaded VirtualMachine class:" + (vmClass == null ? "null" : vmClass.getName()));
              if (vmClass == null) {
                return null;
              }
              String agentPath = createAgentJar(log, config).getAbsolutePath();
              if (agentPath == null) {
                return null;
              }
              log.info("Instrumentation", "try to load agent (path:" + agentPath + ")");
              loadAgent(config, log, agentPath, vmClass);
              // log.info("Instrumentation","agent loaded (path:"+agentPath+")");

            } catch (IOException ioe) {
              log.log(Log.LEVEL_ERROR, "Instrumentation", ioe);
            } finally {
              Thread.currentThread().setContextClassLoader(ccl);
            }
            return null;
          } // end run()
        });
    // If the load(...) agent call was successful, this variable will no
    // longer be null.
    instr = _getInstrumentation(log, config);
    if (instr == null) {
      try {
        Resource agentJar = createAgentJar(log, config);
        throw new PageRuntimeException(
            new ApplicationException(
                Constants.NAME
                    + " was not able to load a Agent dynamically! "
                    + "You need to load one manually by adding the following to your JVM arguments [-javaagent:\""
                    + (agentJar)
                    + "\"]"));
      } catch (IOException ioe) {
        ioe.printStackTrace();
      }
    }
    return instr;
  }