當前位置: 首頁>>代碼示例>>Java>>正文


Java RuntimeConstants類代碼示例

本文整理匯總了Java中org.apache.velocity.runtime.RuntimeConstants的典型用法代碼示例。如果您正苦於以下問題:Java RuntimeConstants類的具體用法?Java RuntimeConstants怎麽用?Java RuntimeConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RuntimeConstants類屬於org.apache.velocity.runtime包,在下文中一共展示了RuntimeConstants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: VelocityDefaultConfigurationFactory

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
@Inject
public VelocityDefaultConfigurationFactory(@Optional final ServletContext servletContext) {
    String loader = "class";
    Velocity.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
    Velocity.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");

    if (servletContext != null) {
        Velocity.setProperty("webapp.resource.loader.class", WebappResourceLoader.class.getName());
        Velocity.setProperty("webapp.resource.loader.path", "/");
        Velocity.setApplicationAttribute("javax.servlet.ServletContext", servletContext);
        loader += ",webapp";
    }
    Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, loader);

    configuration = new Configuration();
}
 
開發者ID:Feng-Zihao,項目名稱:jersey-mvc-velocity,代碼行數:17,代碼來源:VelocityDefaultConfigurationFactory.java

示例2: velocityEngineFactoryBean

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
@Lazy
@Bean(name = "shibboleth.VelocityEngine")
public VelocityEngineFactoryBean velocityEngineFactoryBean() {
    final VelocityEngineFactoryBean bean = new VelocityEngineFactoryBean();

    final Properties properties = new Properties();
    properties.put(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, SLF4JLogChute.class.getName());
    properties.put(RuntimeConstants.INPUT_ENCODING, StandardCharsets.UTF_8.name());
    properties.put(RuntimeConstants.OUTPUT_ENCODING, StandardCharsets.UTF_8.name());
    properties.put(RuntimeConstants.ENCODING_DEFAULT, StandardCharsets.UTF_8.name());
    properties.put(RuntimeConstants.RESOURCE_LOADER, "file, classpath, string");
    properties.put(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, FileUtils.getTempDirectory().getAbsolutePath());
    properties.put(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, Boolean.FALSE);
    properties.put("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
    properties.put("string.resource.loader.class", StringResourceLoader.class.getName());
    properties.put("file.resource.loader.class", FileResourceLoader.class.getName());
    bean.setOverrideLogging(false);
    bean.setVelocityProperties(properties);
    return bean;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:21,代碼來源:CoreSamlConfiguration.java

示例3: createTable

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
@Override
public String createTable(Grammar grammar) {
    Velocity.setProperty(RuntimeConstants.OUTPUT_ENCODING, "UTF-8");
    Velocity.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
    Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
    Velocity.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());

    Velocity.init();
    VelocityContext context = new VelocityContext();
    context.put("grammar", grammar);

    context.put("nonterminalSymbols", grammar.getLhsSymbols());

    Template template = Velocity.getTemplate("/grammartools/PredictiveParsingTable.velo");
    StringWriter stringWriter = new StringWriter();
    template.merge(context, stringWriter);
    return stringWriter.toString().replaceAll("\n", "");
}
 
開發者ID:georgfedermann,項目名稱:compilers,代碼行數:19,代碼來源:LL1TableCreator.java

示例4: compile

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
/**
 * Compile takes an absolute path of the app and returns an absolute path
 * of the resulting Vertabrae.
 *
 * @param abs_path_from the absolute path where the resources of an application
 *                      lives.
 * @param abs_path_to   the absolute path to where the application should be
 *                      built to and served from.
 * @return              the absolute path to serve the application from
 */
public static String
    compile(Path abs_path_from, Path abs_path_to)
{
    System.out.println("[SPINE] Template path: " +  abs_path_from);
    velocity_engine.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, abs_path_from.resolve("templates").toString());
    velocity_engine.init();

    System.out.println("[SPINE] From path: " +  abs_path_from);
    System.out.println("[SPINE] To path: " + abs_path_to);
    
    try {
        Path dir = abs_path_from.resolve("content");

        Map<String, Vertabrae> file_names =
            extract_files(dir);

        generate_markup(abs_path_from, abs_path_to, file_names);
        static_files_copy(abs_path_from, abs_path_to);

    } catch (IOException e) {
        e.printStackTrace();
    }

    return abs_path_to.toAbsolutePath().toString();
}
 
開發者ID:varl,項目名稱:spine,代碼行數:36,代碼來源:SpineBinder.java

示例5: setUp

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
@Before
public void setUp() throws TikaException, IOException, SAXException {
    VelocityEngine engine = new VelocityEngine();
    engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
    engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
    engine.init();

    Templater templater = new Templater();
    templater.setEngine(engine);

    exporter = new HtmlExporter();
    exporter.setTemplater(templater);

    TikaProvider provider = new TikaProvider();
    Tika tika = provider.tika();

    transformer = new TikaTransformer();
    transformer.setTika(tika);
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:20,代碼來源:HtmlExporterTest.java

示例6: setUp

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
@Before
public void setUp() throws TikaException, IOException, SAXException {
    VelocityEngine engine = new VelocityEngine();
    engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
    engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
    engine.init();

    Templater templater = new Templater();
    templater.setEngine(engine);

    exporter = new PdfExporter();
    exporter.setTemplater(templater);

    TikaProvider provider = new TikaProvider();
    Tika tika = provider.tika();

    transformer = new TikaTransformer();
    transformer.setTika(tika);
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:20,代碼來源:PdfExporterTest.java

示例7: getEngine

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
public static VelocityEngine getEngine() {

        try {

            final Properties props =
                    new Properties();
            props.putAll(net.shibboleth.utilities.java.support.velocity.VelocityEngine.getDefaultProperties());
            props.setProperty(RuntimeConstants.INPUT_ENCODING, "UTF-8");
            props.setProperty(RuntimeConstants.OUTPUT_ENCODING, "UTF-8");
            props.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
            props.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, SLF4JLogChute.class.getName());

            final VelocityEngine velocityEngine =
                    net.shibboleth.utilities.java.support.velocity.VelocityEngine
                    .newVelocityEngine(props);
            return velocityEngine;
        } catch (final Exception e) {
            throw new TechnicalException("Error configuring velocity", e);
        }

    }
 
開發者ID:yaochi,項目名稱:pac4j-plus,代碼行數:22,代碼來源:VelocityEngineFactory.java

示例8: setUpVelocity

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
private static VelocityEngine setUpVelocity(final MavenProject project) {
  final String templateRoot = getTemplateRoot(project);

  final Properties config = new Properties();

  config.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath,file");
  config.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, templateRoot);
  config.setProperty(RuntimeConstants.VM_LIBRARY, "macros.vm");
  config.setProperty(RuntimeConstants.ENCODING_DEFAULT, UTF_8);
  config.setProperty(RuntimeConstants.INPUT_ENCODING, UTF_8);
  config.setProperty(RuntimeConstants.OUTPUT_ENCODING, UTF_8);

  final String resourceLoader = ClasspathResourceLoader.class.getName();
  config.setProperty("classpath.resource.loader.class", resourceLoader);

  final String includeHandler = OptionalIncludeEventHandler.class.getName();
  config.setProperty(RuntimeConstants.EVENTHANDLER_INCLUDE, includeHandler);


  VelocityEngine velocityEngine = new VelocityEngine();
  velocityEngine.init(config);
  return velocityEngine;
}
 
開發者ID:zaplatynski,項目名稱:fsm-packagetype,代碼行數:24,代碼來源:VelocityManager.java

示例9: VelocityGenerator

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
public VelocityGenerator(String packageName ) {
    this.packageName = packageName;
    this.javaClassGenerator = new JavaClassGenerator();

    velocityEngine = new VelocityEngine();

    velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
    velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());

    try {
        velocityEngine.init();
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("VelocityEngine can not initialize.");
        System.exit(0);
    }
}
 
開發者ID:wangdao,項目名稱:x-worker,代碼行數:18,代碼來源:VelocityGenerator.java

示例10: SQLGenerator

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
public SQLGenerator(String type) {
    this.type = type;

    this.javaClassGenerator = new JavaClassGenerator();

    velocityEngine = new VelocityEngine();

    velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
    velocityEngine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());

    try {
        velocityEngine.init();
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("VelocityEngine can not initialize.");
        System.exit(0);
    }
}
 
開發者ID:wangdao,項目名稱:x-worker,代碼行數:19,代碼來源:SQLGenerator.java

示例11: renderTemplate

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
/**
 * Return the String representation of the template rendered using Velocity.
 *
 * @param context context use to render the template
 * @param templateFileName file name of the template in the classpath
 * @throws TemplateRenderException if there is an error with the template
 */
public static String renderTemplate(String templateFileName,
                                    VelocityContext context)
    throws TemplateRenderException {
  VelocityEngine ve = new VelocityEngine();
  ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
  ve.setProperty("classpath.resource.loader.class",
      ClasspathResourceLoader.class.getName());

  StringWriter sw = new StringWriter();

  try {
    ve.mergeTemplate(templateFileName, "UTF-8", context, sw);
  } catch (ResourceNotFoundException
      | ParseErrorException
      | MethodInvocationException e) {
    throw new TemplateRenderException("Error rendering template file: " + templateFileName, e);
  }

  return sw.toString();
}
 
開發者ID:airbnb,項目名稱:reair,代碼行數:28,代碼來源:VelocityUtils.java

示例12: render

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
/**
 * 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());
}
 
開發者ID:yegor256,項目名稱:takes,代碼行數:32,代碼來源:RsVelocity.java

示例13: checkVelocity

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public synchronized void checkVelocity() {
	if (velocityInitialized) { 
		return;
	}
	velocityInitialized = true;
	ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "string");
	ve.setProperty("resource.loader.class",
			"org.apache.velocity.runtime.resource.loader.StringResourceLoader");
	ve.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
			"org.apache.velocity.runtime.log.Log4JLogChute");
	ve.setProperty("runtime.log.logsystem.log4j.logger",
			"net.sf.taverna.t2.activities.interaction.velocity.InteractionVelocity");
	ve.init();
	ve.loadDirective(RequireDirective.class.getName());
	ve.loadDirective(ProduceDirective.class.getName());
	ve.loadDirective(NotifyDirective.class.getName());

	loadTemplates();

	interactionTemplate = ve.getTemplate(INTERACTION_TEMPLATE_NAME);
	if (interactionTemplate == null) {
		logger.error("Could not open interaction template "
				+ INTERACTION_TEMPLATE_NAME);
	}
}
 
開發者ID:apache,項目名稱:incubator-taverna-common-activities,代碼行數:27,代碼來源:InteractionVelocity.java

示例14: produceEngine

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
/**
 * @return produz uma instancia do velocity template para uso no sistema
 */
@Produces
VelocityEngine produceEngine() {

    final VelocityEngine engine = new VelocityEngine();

    // manda carregar os recursos dos resources
    engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "class");
    engine.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());

    final Properties properties = new Properties();

    // joga os logs do velocity no log do server
    properties.put("runtime.log.logsystem.class",
            "org.apache.velocity.runtime.log.SimpleLog4JLogSystem");
    properties.put("runtime.log.logsystem.log4j.category", "velocity");
    properties.put("runtime.log.logsystem.log4j.logger", "velocity");

    engine.init(properties);

    return engine;
}
 
開發者ID:arthurgregorio,項目名稱:web-budget,代碼行數:25,代碼來源:VelocityProducer.java

示例15: process

import org.apache.velocity.runtime.RuntimeConstants; //導入依賴的package包/類
@Override public boolean process( Set<? extends TypeElement> annotations, RoundEnvironment roundEnv ) {
  ModelCollector collector = new ModelCollector( processingEnv.getMessager() );

  processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Start processing JNI Proxies" );
  JNIElementVisitor elementVisitor = new JNIElementVisitor( processingEnv.getMessager() );
  for ( TypeElement annotation : annotations ) {
    for ( Element element : roundEnv.getElementsAnnotatedWith( annotation ) ) {
      element.accept( elementVisitor, collector );
    }
  }
  VelocityEngine engine = new VelocityEngine();
  engine.setProperty( RuntimeConstants.RESOURCE_LOADER, "classpath" );
  engine.setProperty( "classpath.resource.loader.class", ClasspathResourceLoader.class.getName() );
  engine.init();

  GeneralGenerator generalGenerator = new GeneralGenerator( processingEnv, engine );

  for ( JNIProxyClass proxyClass : collector.getClasses() ) {
    proxyClass.accept( generalGenerator );
  }
  return true;
}
 
開發者ID:geertcl,項目名稱:JNIBridgeGenerator,代碼行數:23,代碼來源:JNIProxyProcessor.java


注:本文中的org.apache.velocity.runtime.RuntimeConstants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。