Package org.huihoo.workflow.rules

Examples of org.huihoo.workflow.rules.ScriptContext


      return;

    }

    // Tell the class loader the root of the context
    ScriptContext scriptContext = ((Context) container).getScriptContext();

    // Assigning permissions for the work directory
    File workDir = (File) scriptContext.getAttribute(Globals.ATTR_WORK_DIR);
    if (workDir != null)
    {
      try
      {
        String workDirPath = workDir.getCanonicalPath();
        classLoader.addPermission(new FilePermission(workDirPath, "read,write"));
        classLoader.addPermission(
          new FilePermission(workDirPath + File.separator + "-", "read,write,delete"));
      }
      catch (IOException e)
      {
        // Ignore
      }
    }

    try
    {

      URL rootURL = scriptContext.getResource("/");
      classLoader.addPermission(rootURL);

      String contextRoot = scriptContext.getRealPath("/");
      try
      {
        contextRoot = (new File(contextRoot)).getCanonicalPath();
        classLoader.addPermission(contextRoot);
      }
      catch (IOException e)
      {
        // Ignore
      }

      URL classesURL = scriptContext.getResource("/WEB-INF/classes/");
      classLoader.addPermission(classesURL);
      URL libURL = scriptContext.getResource("/WEB-INF/lib/");
      classLoader.addPermission(libURL);

      if (libURL != null)
      {
        File rootDir = new File(contextRoot);
View Full Code Here


    if (!(container instanceof Context))
    {
      return;
    }

    ScriptContext scriptContext = ((Context) container).getScriptContext();
    if (scriptContext == null)
    {
      return;
    }

    // Loading the work directory
    File workDir = (File) scriptContext.getAttribute(Globals.ATTR_WORK_DIR);
    if (workDir == null)
    {
      log.info("No work dir for " + scriptContext);
    }
    else
    {
      log.debug(sm.getString("workflowLoader.deploy", workDir.getAbsolutePath()));
      classLoader.setWorkDir(workDir);
    }

    // Setting up the class repository (/WEB-INF/classes), if it exists
    String classesPath = "/WEB-INF/classes";

    String absoluteClassesPath = scriptContext.getRealPath(classesPath);
    if (absoluteClassesPath != null)
    {
      File classRepository = new File(absoluteClassesPath);
      // Adding the repository to the class loader
      log.debug(
        sm.getString("workflowLoader.classDeploy", classesPath, classRepository.getAbsolutePath()));

      classLoader.addRepository(classesPath + "/", classRepository);

    }

    // Setting up the JAR repository (/WEB-INF/lib), if it exists
    String libPath = "/WEB-INF/lib";
    String absoluteLibPath = scriptContext.getRealPath(libPath);

    if (absoluteLibPath != null)
    {
      classLoader.addJarPath(libPath, new File(absoluteLibPath));
View Full Code Here

    if (!(container instanceof Context))
    {
      return;
    }

    ScriptContext ScriptContext = ((Context) container).getScriptContext();

    if (ScriptContext == null)
    {
      return;
    }

    if (container instanceof StandardContext)
    {
      String baseClasspath = ((StandardContext) container).getCompilerClasspath();
      if (baseClasspath != null)
      {
        ScriptContext.setAttribute(Globals.ATTR_CLASS_PATH, baseClasspath);
        return;
      }
    }

    StringBuffer classpath = new StringBuffer();

    // Assemble the class path information from our class loader chain
    ClassLoader loader = getClassLoader();
    int n = 0;
    while (loader != null)
    {
      if (!(loader instanceof URLClassLoader))
      {
        String cp = getClasspath(loader);
        if (cp == null)
        {
          log.info("Unknown loader " + loader + " " + loader.getClass());
          break;
        }
        else
        {
          if (n > 0)
          {
            classpath.append(File.pathSeparator);
          }
          classpath.append(cp);
          n++;
        }

        break;
        //continue;
      }

      URL repositories[] = ((URLClassLoader) loader).getURLs();
      for (int i = 0; i < repositories.length; i++)
      {
        String repository = repositories[i].toString();
        if (repository.startsWith("file://"))
        {
          repository = repository.substring(7);
        }
        else if (repository.startsWith("file:"))
        {
          repository = repository.substring(5);
        }
        else
        {
          continue;
        }

        if (repository == null)
        {
          continue;

        }
        if (n > 0)
        {
          classpath.append(File.pathSeparator);
        }

        classpath.append(repository);
        n++;
      }

      loader = loader.getParent();
    }

    this.classpath = classpath.toString();

    // Store the assembled class path as a servlet context attribute
    ScriptContext.setAttribute(Globals.ATTR_CLASS_PATH, classpath.toString());
  }
View Full Code Here

   * Process the application configuration file, if it exists.
   */
  private void applicationConfig()
  {
    // Open the application workflow.xml file, if it exists
    ScriptContext servletContext = context.getScriptContext();
    InputStream stream = null;
    InputStream stream_config = null;
    if (servletContext != null)
    {
      stream = servletContext.getResourceAsStream(Constants.ApplicationWorkflowXml);
      stream_config = servletContext.getResourceAsStream(Constants.ApplicationWorkflowXml);
      if (stream == null)
      {
        log.info(sm.getString("contextConfig.applicationMissing") + " " + context);
      }
    }
    if (workflowDigester == null)
    {
      workflowDigester = createWorkflowDigester();
    }
    // Process the application org.huihoo.workflow.xml file
    synchronized (workflowDigester)
    {
      try
      {
        URL workflowURL = servletContext.getResource(Constants.ApplicationWorkflowXml);
        if (workflowURL != null)
        {
          //--------------------entire workflow application-----------------
          InputSource is = new InputSource(workflowURL.toExternalForm());
          is.setByteStream(stream);
          workflowDigester.clear();
          workflowDigester.setDebug(getDebug());
          workflowDigester.setUseContextClassLoader(false);
          workflowDigester.push(context);
          workflowDigester.parse(is);
          //--------------------script config of  workflow application ----------------- 
          Digester configDigester = createConfigDigester();
          is = new InputSource(workflowURL.toExternalForm());
          is.setByteStream(stream_config);
          configDigester.setDebug(getDebug());
          configDigester.setUseContextClassLoader(false);
          configDigester.addCallMethod("workflow-app/script-config/init-param", "addInitParameter", 2);
          configDigester.addCallParam("workflow-app/script-config/init-param/param-name", 0);
          configDigester.addCallParam("workflow-app/script-config/init-param/param-value", 1);
          configDigester.push(servletContext.getScriptConfig());
          configDigester.parse(is);
        }
        //--------------------create database
        UserDatabase userDatabase = null;
        CaseDatabase caseDatabase = null;
View Full Code Here

TOP

Related Classes of org.huihoo.workflow.rules.ScriptContext

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.