Examples of VelocityEngine


Examples of org.apache.velocity.app.VelocityEngine

  }

  private void init() {
    Properties p = null;
    try {
      ve = new VelocityEngine();
      p = new Properties();
      p.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
      //p.setProperty(RuntimeConstants.RUNTIME_LOG, OLATContext.getUserdataRoot() + "logs/velocity.log.txt");
      p.setProperty("runtime.log.logsystem.log4j.category", "syslog");
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

  @Override
  public VelocityEngine getVelocityEngine() {
    if (velocityEngine == null) {
          try {
              velocityEngine = new VelocityEngine("WEB-INF/velocity.properties");
        velocityEngine.init();
      } catch (Exception e) {
              log.error("Can't init velocity engine. " + e.getMessage());
      }
    }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

      return false;
    }
    try
    {
      File daemonTemplate = new File(_daemonTemplate);
      VelocityEngine ve = new VelocityEngine();
      ve.setProperty(VelocityEngine.RESOURCE_LOADER, "file");
      ve.setProperty("file.resource.loader.path", daemonTemplate.getParent());
      ve.setProperty("runtime.log.logsystem.class", VelocityLog.class.getCanonicalName());
      // TODO find a way to set a non static logger
      VelocityLog.setLogger(_logger);
      ve.init();
      Template t = ve.getTemplate(daemonTemplate.getName());
      VelocityContext context = new VelocityContext();
      context.put("w_name", _name);
      context.put("w_long_name", _displayName);
      context.put("w_start_cmd", toStrCommand(_startCmd));
      context.put("w_stop_cmd", toStrCommand(_stopCmd));
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

      return false;
    }
    try
    {
      File daemonTemplate = new File(_plistTemplate);
      VelocityEngine ve = new VelocityEngine();
      ve.setProperty(VelocityEngine.RESOURCE_LOADER, "file");
      ve.setProperty("file.resource.loader.path", daemonTemplate.getParent());
      ve.setProperty("runtime.log.logsystem.class", VelocityLog.class.getCanonicalName());
      ve.init();
      Template t = ve.getTemplate(daemonTemplate.getName());
      VelocityContext context = new VelocityContext();
      context.put("name", _plistName);
      context.put("command", Arrays.asList(_execCmd.split(" ")));
      context.put("autoStart", "AUTOMATIC".equals(_config.getString("wrapper.ntservice.starttype", DEFAULT_SERVICE_START_TYPE)));
      FileWriter writer = new FileWriter(_plistFile);
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

      return false;
    }
    try
    {
      File daemonTemplate = new File(_plistTemplate);
      VelocityEngine ve = new VelocityEngine();
      ve.setProperty(VelocityEngine.RESOURCE_LOADER, "file");
      ve.setProperty("file.resource.loader.path", daemonTemplate.getParent());
      ve.setProperty("runtime.log.logsystem.class", VelocityLog.class.getCanonicalName());
      ve.init();
      Template t = ve.getTemplate(daemonTemplate.getName());
      VelocityContext context = new VelocityContext();
      context.put("name", _plistName);
      context.put("command", Arrays.asList(_execCmd.split(" ")));
      context.put("autoStart", "AUTOMATIC".equals(_config.getString("wrapper.ntservice.starttype", DEFAULT_SERVICE_START_TYPE)));
      FileWriter writer = new FileWriter(_plistFile);
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

        if (context == null) {
            throw new IllegalStateException("context was not set");
        }

        // setup velocity
        VelocityEngine velocity = new VelocityEngine();
        velocity.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, sourceDir.getAbsolutePath());
        velocity.init();

        List plans = new LinkedList();
        findPlans(sourceDir, plans);
        for (Iterator iterator = plans.iterator(); iterator.hasNext();) {
            File plan = (File) iterator.next();
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

       
        final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        try {
          Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
         
          velocity = new VelocityEngine();
         
          // include the Sling resource loader for Velocity
          Properties props = new Properties();
          props.put("sling.resource.loader.description", "Sling Resource Loader for Velocity");
          props.put("sling.resource.loader.class", "org.apache.sling.scripting.velocity.SlingResourceLoader");
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

    }
  }
 
  private VelocityEngine createVelocityEngine() {
    try {
      VelocityEngine result = new VelocityEngine();
      result.setProperty("output.encoding", "utf-8");
      result.setProperty("file.resource.loader.path",
          servletContext.getRealPath("/") + "/WEB-INF/templates/");
      result.setProperty("velocimacro.context.localscope", true);
     
      // Turn off Velocity logging
      result.setProperty("runtime.log.logsystem.class",
          "org.apache.velocity.runtime.log.NullLogSystem");
     
      // XML-escape *all* references inserted into templates
      result.setProperty("eventhandler.referenceinsertion.class", EscapeXmlReference.class.getName());
     
      // Enable caching
      result.setProperty("file.resource.loader.cache", true);
     
      result.init();
      return result;
    } catch (Exception ex) {
      throw new RuntimeException(ex);
    }
  }
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

    @Override
    public void render(HttpServletRequest request, HttpServletResponse response,
            AppProperties properties)
            throws ServletException, IOException {

        VelocityEngine engine = (VelocityEngine)properties.getProperty(CONFIG_PROPERTY);
       
        Template template = engine.getTemplate(templateName);
       
        try {
           
            template.merge(new VelocityContext(attributes), response.getWriter());
           
View Full Code Here

Examples of org.apache.velocity.app.VelocityEngine

    public void initialize(InitParams initParams, AppResources resources,
            AppPropertyCollector collector) {
       
        //String ftlPath = getVMPath(initParams); //TODO use path
       
        VelocityEngine engine = new VelocityEngine();
        engine.setProperty("resource.loader", "mojave");
        //TODO replace with MojaveResourceLoader
        // see org.apache.velocity.tools.view.servlet.WebappLoader
        engine.setProperty("mojave.resource.loader.instance", new FileResourceLoader());
        Vector<String> path = new Vector<String>();
        path.add("src/test/resources/standard/WEB-INF/vm");
        engine.setProperty("mojave.resource.loader.path", path);
        engine.init();
       
        collector.addProperty(VM.CONFIG_PROPERTY, engine);
       
        readVMErrorFile(initParams, collector);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.