Java 类org.apache.velocity.runtime.log.NullLogChute 实例源码

项目:takes    文件:RsVelocity.java   
/**
 * Render it.
 * @param folder Template folder
 * @param template Page template
 * @param params Params for velocity
 * @return Page body
 * @throws IOException If fails
 */
private static InputStream render(final String folder,
    final InputStream template,
    final Map<CharSequence, Object> params) throws IOException {
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final Writer writer = new Utf8OutputStreamWriter(baos);
    final VelocityEngine engine = new VelocityEngine();
    engine.setProperty(
        RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,
        new NullLogChute()
    );
    engine.setProperty(
        "file.resource.loader.path",
        folder
    );
    engine.evaluate(
        new VelocityContext(params),
        writer,
        "",
        new Utf8InputStreamReader(template)
    );
    writer.close();
    return new ByteArrayInputStream(baos.toByteArray());
}
项目:tomee    文件:Container.java   
private void copyTemplateTo(final File targetDir, final String filename) throws Exception {
    final File file = new File(targetDir, filename);
    if (file.exists()) {
        return;
    }

    // don't break apps using Velocity facade
    final VelocityEngine engine = new VelocityEngine();
    engine.setProperty(Velocity.RUNTIME_LOG_LOGSYSTEM, new NullLogChute());
    engine.setProperty(Velocity.RESOURCE_LOADER, "class");
    engine.setProperty("class.resource.loader.description", "Velocity Classpath Resource Loader");
    engine.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
    engine.init();
    final Template template = engine.getTemplate("/org/apache/tomee/configs/" + filename);
    final VelocityContext context = new VelocityContext();
    context.put("tomcatHttpPort", Integer.toString(configuration.getHttpPort()));
    context.put("tomcatShutdownPort", Integer.toString(configuration.getStopPort()));
    final Writer writer = new FileWriter(file);
    template.merge(context, writer);
    writer.flush();
    writer.close();
}
项目:devhub-prototype    文件:TemplateEngine.java   
/**
 * Constructs a new {@link TemplateEngine} object, and initializes it. This
 * constructor will throw a {@link RuntimeException} if initializing fails.
 * 
 * @param path The path containing all the templates.
 * @param executor
 */
public TemplateEngine(Path path, ExecutorService executor) {
    this.executor = executor;
    try {
        this.path = path;
        this.modificationTimes = Maps.newHashMap();
        this.engine = new VelocityEngine();

        engine.setProperty("resource.loader", "string");
        engine.setProperty("runtime.log.logsystem.class", getPath(NullLogChute.class));
        engine.setProperty("string.resource.loader.class", getPath(StringResourceLoader.class));
        engine.setProperty("string.resource.loader.description", "Velocity StringResource loader");
        engine.setProperty("string.resource.loader.repository.class", getPath(StringResourceRepositoryImpl.class));
        engine.init();

        updateTemplates();

    } catch (Exception e) {
        LOG.error(e.getLocalizedMessage(), e);
        throw new DevHubException("Could not initialize the TemplateEngine", e);
    }
}
项目:urule    文件:RenderPageServletHandler.java   
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext=applicationContext;
    ve = new VelocityEngine();
    ve.setProperty(Velocity.RESOURCE_LOADER, "class");
    ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
    ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,new NullLogChute());
    ve.init();  
}
项目:ureport    文件:RenderPageServletAction.java   
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext=applicationContext;
    ve = new VelocityEngine();
    ve.setProperty(Velocity.RESOURCE_LOADER, "class");
    ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
    ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,new NullLogChute());
    ve.init();  
}
项目:uflo    文件:RenderPageServletHandler.java   
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext=applicationContext;
    ve = new VelocityEngine();
    ve.setProperty(Velocity.RESOURCE_LOADER, "class");
    ve.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
    ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,new NullLogChute());
    ve.init();  
}
项目:covito-coder    文件:VelocityImpl.java   
public VelocityImpl(){
    Properties props = new Properties();
    props.setProperty(Velocity.INPUT_ENCODING, "UTF-8");// 设置输入字符集
    props.setProperty(Velocity.OUTPUT_ENCODING, "UTF-8");// 设置输出字符集
    props.setProperty(Velocity.ENCODING_DEFAULT, "UTF-8");
    props.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, NullLogChute.class.getName());
    props.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, "templates/");
    engine.init(props);
}
项目:whois    文件:ResponseFactory.java   
@Autowired
public ResponseFactory(final DateTimeProvider dateTimeProvider) {
    this.dateTimeProvider = dateTimeProvider;

    velocityEngine = new VelocityEngine();
    velocityEngine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, new NullLogChute());
    velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
    velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
    velocityEngine.init();
}
项目:zhq    文件:TemplateProcessImpl.java   
public TemplateProcessImpl() {
    ve = new VelocityEngine();
    // 关闭错误日志输出
    ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM,
            new NullLogChute());
}