List of usage examples for org.apache.commons.collections ExtendedProperties ExtendedProperties
public ExtendedProperties()
From source file:com.cyclopsgroup.waterview.jelly.JellyScriptsRunner.java
/** * Main entry to run a script/* www . j a v a2 s . co m*/ * * @param args Script paths * @throws Exception Throw it out */ public static final void main(String[] args) throws Exception { List scripts = new ArrayList(); for (int i = 0; i < args.length; i++) { String path = args[i]; File file = new File(path); if (file.isFile()) { scripts.add(file.toURL()); } else { Enumeration enu = JellyScriptsRunner.class.getClassLoader().getResources(path); CollectionUtils.addAll(scripts, enu); } } if (scripts.isEmpty()) { System.out.println("No script to run, return!"); return; } String basedir = new File("").getAbsolutePath(); Properties initProperties = new Properties(System.getProperties()); initProperties.setProperty("basedir", basedir); initProperties.setProperty("plexus.home", basedir); WaterviewPlexusContainer container = new WaterviewPlexusContainer(); for (Iterator j = initProperties.keySet().iterator(); j.hasNext();) { String initPropertyName = (String) j.next(); container.addContextValue(initPropertyName, initProperties.get(initPropertyName)); } container.addContextValue(Waterview.INIT_PROPERTIES, initProperties); container.initialize(); container.start(); JellyEngine je = (JellyEngine) container.lookup(JellyEngine.ROLE); JellyContext jc = new JellyContext(je.getGlobalContext()); XMLOutput output = XMLOutput.createXMLOutput(System.out); for (Iterator i = scripts.iterator(); i.hasNext();) { URL script = (URL) i.next(); System.out.print("Running script " + script); ExtendedProperties ep = new ExtendedProperties(); ep.putAll(initProperties); ep.load(script.openStream()); for (Iterator j = ep.getKeys("script"); j.hasNext();) { String name = (String) j.next(); if (name.endsWith(".file")) { File file = new File(ep.getString(name)); if (file.exists()) { System.out.println("Runner jelly file " + file); jc.runScript(file, output); } } else if (name.endsWith(".resource")) { Enumeration k = JellyScriptsRunner.class.getClassLoader().getResources(ep.getString(name)); while (j != null && k.hasMoreElements()) { URL s = (URL) k.nextElement(); System.out.println("Running jelly script " + s); jc.runScript(s, output); } } } //jc.runScript( script, XMLOutput.createDummyXMLOutput() ); System.out.println("... Done!"); } container.dispose(); }
From source file:generate.tostring.velocity.VelocityFactory.java
/** * Returns a new instance of the VelocityEngine. * <p/>//from ww w .j av a 2s .com * The engine is initialized and outputs its logging to IDEA logging. * * @return a new velocity engine that is initialized. * @throws Exception error creating the VelocityEngine. */ public static VelocityEngine newVeloictyEngine() throws Exception { ExtendedProperties prop = new ExtendedProperties(); prop.addProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName()); prop.addProperty("runtime.log.logsystem.log4j.category", "GenerateToString"); VelocityEngine velocity = new VelocityEngine(); velocity.setExtendedProperties(prop); velocity.init(); return velocity; }
From source file:org.intellij.plugins.util.TemplateEngine.java
private void initVelocityProcess() { if (inited)/* w ww . j a v a 2 s.c om*/ return; try { ExtendedProperties extendedProperties = new ExtendedProperties(); extendedProperties.addProperty(VelocityEngine.RESOURCE_LOADER, "file,class"); extendedProperties.addProperty("file.resource.loader.class", org.apache.velocity.runtime.resource.loader.FileResourceLoader.class.getName()); extendedProperties.addProperty(VelocityEngine.INPUT_ENCODING, "UTF-8"); extendedProperties.addProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, getFileTemplatePath()); extendedProperties.addProperty(VelocityEngine.FILE_RESOURCE_LOADER_CACHE, "true"); extendedProperties.addProperty("file.resource.loader.modificationCheckInterval", "2"); extendedProperties.addProperty("class.resource.loader.class", TemplatesClasspathLoader.class.getName()); extendedProperties.addProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName()); extendedProperties.addProperty("runtime.log.logsystem.log4j.category", TemplateEngine.class.getName()); velocity.setExtendedProperties(extendedProperties); velocity.init(); inited = true; } catch (Exception e) { e.printStackTrace(); } }
From source file:com.maddyhome.idea.copyright.util.VelocityHelper.java
private static synchronized VelocityEngine getEngine() { if (instance == null) { try {/* ww w . ja v a 2s.c o m*/ VelocityEngine engine = new VelocityEngine(); ExtendedProperties extendedProperties = new ExtendedProperties(); extendedProperties.addProperty(VelocityEngine.RESOURCE_LOADER, "file"); extendedProperties.addProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); extendedProperties.addProperty("file.resource.loader.path", PathManager.getPluginsPath() + "/Copyright/resources"); extendedProperties.addProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName()); extendedProperties.addProperty("runtime.log.logsystem.log4j.category", CopyrightProjectPlugin.class.getName()); engine.setExtendedProperties(extendedProperties); engine.init(); instance = engine; } catch (Exception e) { } } return instance; }
From source file:autohit.common.deployment.KickConfigure.java
/** * Object main/*from ww w . j av a2 s . c o m*/ */ public void go(String it, String javaexec) { try { DeploymentConfigure dc = new DeploymentConfigure(); // validate it File f = new File(it + AutohitProperties.vKICK_VERIFICATION_FILE); if (!f.exists()) { help(); return; } props = new ExtendedProperties(); props.put(AutohitProperties.CONFIG_ROOT_CONFIG, it); props.put(AutohitProperties.CONFIG_JAVA_CONFIG, javaexec); dc.configure(AutohitProperties.vKICK_STORE, it, props); } catch (Exception e) { System.out.println("Catastrophic ERROR. System is likely corrupt."); System.out.println("The error is= " + e.getMessage()); return; } }
From source file:com.maddyhome.idea.copyright.pattern.VelocityHelper.java
private static synchronized VelocityEngine getEngine() { if (instance == null) { try {/*from w w w. j a v a 2s . c o m*/ VelocityEngine engine = new VelocityEngine(); ExtendedProperties extendedProperties = new ExtendedProperties(); extendedProperties.addProperty(RuntimeConstants.RESOURCE_LOADER, "file"); extendedProperties.addProperty(RuntimeConstants.PARSER_POOL_SIZE, "1"); extendedProperties.addProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader"); extendedProperties.addProperty("file.resource.loader.path", PathManager.getPluginsPath() + "/Copyright/resources"); extendedProperties.addProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName()); extendedProperties.addProperty("runtime.log.logsystem.log4j.category", CopyrightManager.class.getName()); engine.setExtendedProperties(extendedProperties); engine.init(); instance = engine; } catch (Exception ignored) { } } return instance; }
From source file:com.alibaba.citrus.service.velocity.CloneableEventCartridgeTests.java
@Before public void init() throws Exception { ExtendedProperties config = new ExtendedProperties(); rsvc = new RuntimeInstance(); rsvc.setConfiguration(config);//from w w w .j a v a2 s .c om rsvc.init(); eventCartridge = new CloneableEventCartridge(); handler = new MyHandler(); eventCartridge.addEventHandler(handler); }
From source file:com.alibaba.citrus.service.velocity.SpringResourceLoaderAdapterTests.java
@Before public void init() throws Exception { ExtendedProperties config = new ExtendedProperties(); RuntimeServices rsvc = new RuntimeInstance(); config.setProperty("path", "/templates"); config.setProperty("resource.loader", ""); rsvc.setConfiguration(config);// ww w.j av a 2 s . c o m rsvc.setProperty(RUNTIME_LOG_LOGSYSTEM, new Slf4jLogChute(log)); rsvc.setApplicationAttribute(SpringResourceLoaderAdapter.SPRING_RESOURCE_LOADER_KEY, factory); rsvc.init(); velocityLoader = new SpringResourceLoaderAdapter(); velocityLoader.commonInit(rsvc, config); velocityLoader.init(config); }
From source file:com.alibaba.citrus.service.velocity.PreloadedResourceLoaderTests.java
@Before public void init() throws Exception { ExtendedProperties config = new ExtendedProperties(); RuntimeServices rsvc = new RuntimeInstance(); config.setProperty("resource.loader", ""); config.setProperty(PreloadedResourceLoader.PRELOADED_RESOURCES_KEY, preloadingResources()); rsvc.setConfiguration(config);/*from w w w .j av a2 s . co m*/ rsvc.setProperty(RUNTIME_LOG_LOGSYSTEM, new Slf4jLogChute(log)); rsvc.init(); velocityLoader = new PreloadedResourceLoader(); velocityLoader.commonInit(rsvc, config); velocityLoader.init(config); }
From source file:autohit.universe.UniverseProperties.java
/** * Constructor. Build from an input stream. We will propagate any exception. * @param props input stream to the properties file *///from ww w . j ava 2s . c o m public UniverseProperties(InputStream props) throws Exception { try { prop = new ExtendedProperties(); prop.load(props); completeConstruction(); } catch (Exception e) { // FUBAR prop = null; throw e; } }