本文整理匯總了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();
}
示例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;
}
示例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", "");
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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());
}
示例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);
}
}
示例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;
}
示例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;
}