List of usage examples for org.apache.commons.collections ExtendedProperties putAll
public synchronized void putAll(Map<? extends K, ? extends V> t)
From source file:com.cyclopsgroup.waterview.jelly.JellyScriptsRunner.java
/** * Main entry to run a script//from ww w .ja va2s. c om * * @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:ca.simplegames.micro.viewers.velocity.VelocityViewRenderer.java
public void init() throws Exception { ExtendedProperties eprops = new ExtendedProperties(); eprops.putAll(velocityProperties); eprops.addProperty(RuntimeConstants.RESOURCE_LOADER, "micro"); eprops.setProperty("micro.resource.loader.description", "Micro internal resource loader."); eprops.setProperty("micro.resource.loader.class", "ca.simplegames.micro.viewers.velocity.MicroResourceLoader"); eprops.setProperty("runtime.log.logsystem.class", "ca.simplegames.micro.viewers.velocity.VelocityViewRenderer"); //eprops.setProperty("micro.resource.loader.repository", repository); if (resourceCacheEnabled) { eprops.setProperty("micro.resource.loader.cache", site.isProduction() ? "true" : "false"); eprops.setProperty("micro.resource.loader.modificationCheckInterval", Integer.toString(getResourceCacheInterval())); }// w w w. ja va2 s . co m // Apply properties to VelocityEngine. velocityEngine.setExtendedProperties(eprops); try { velocityEngine.init(); velocityEngine.setApplicationAttribute(ServletContext.class.getName(), site.getServletContext()); } catch (Exception ex) { log.error("Why does VelocityEngine throw a generic checked exception, after all?", ex); throw new VelocityException(ex.getMessage()); } //log.info("Resource loader: " + velocityEngine.getProperty(VelocityEngine.RESOURCE_LOADER)); }
From source file:com.metamesh.opencms.rfs.RfsAwareDumpLoader.java
/** * @see org.opencms.configuration.I_CmsConfigurationParameterHandler#initConfiguration() */// w w w. ja v a 2 s . c o m public void initConfiguration() { ExtendedProperties config = new ExtendedProperties(); config.putAll(m_configuration); String maxAge = config.getString("client.cache.maxage"); if (maxAge == null) { m_clientCacheMaxAge = -1; } else { m_clientCacheMaxAge = Long.parseLong(maxAge); } if (CmsLog.INIT.isInfoEnabled()) { if (maxAge != null) { CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_CLIENT_CACHE_MAX_AGE_1, maxAge)); } CmsLog.INIT.info( Messages.get().getBundle().key(Messages.INIT_LOADER_INITIALIZED_1, this.getClass().getName())); } }
From source file:org.apache.cayenne.access.DataRowStore.java
protected void initWithProperties(Map properties) { ExtendedProperties propertiesWrapper = new ExtendedProperties(); if (properties != null) { propertiesWrapper.putAll(properties); }/*from w ww .j a v a 2 s . c om*/ long snapshotsExpiration = propertiesWrapper.getLong(SNAPSHOT_EXPIRATION_PROPERTY, SNAPSHOT_EXPIRATION_DEFAULT); maxSize = propertiesWrapper.getInt(SNAPSHOT_CACHE_SIZE_PROPERTY, SNAPSHOT_CACHE_SIZE_DEFAULT); boolean notifyRemote = propertiesWrapper.getBoolean(REMOTE_NOTIFICATION_PROPERTY, REMOTE_NOTIFICATION_DEFAULT); String eventBridgeFactory = propertiesWrapper.getString(EVENT_BRIDGE_FACTORY_PROPERTY, EVENT_BRIDGE_FACTORY_DEFAULT); if (logger.isDebugEnabled()) { logger.debug("DataRowStore property " + SNAPSHOT_EXPIRATION_PROPERTY + " = " + snapshotsExpiration); logger.debug("DataRowStore property " + SNAPSHOT_CACHE_SIZE_PROPERTY + " = " + maxSize); logger.debug("DataRowStore property " + REMOTE_NOTIFICATION_PROPERTY + " = " + notifyRemote); logger.debug("DataRowStore property " + EVENT_BRIDGE_FACTORY_PROPERTY + " = " + eventBridgeFactory); } // init ivars from properties this.notifyingRemoteListeners = notifyRemote; this.snapshots = new ConcurrentLinkedHashMap.Builder<ObjectId, DataRow>().maximumWeightedCapacity(maxSize) .build(); // init event bridge only if we are notifying remote listeners if (notifyingRemoteListeners) { try { EventBridgeFactory factory = (EventBridgeFactory) Class.forName(eventBridgeFactory).newInstance(); Collection<EventSubject> subjects = Collections.singleton(getSnapshotEventSubject()); String externalSubject = EventBridge.convertToExternalSubject(getSnapshotEventSubject()); this.remoteNotificationsHandler = factory.createEventBridge(subjects, externalSubject, properties); } catch (Exception ex) { throw new CayenneRuntimeException("Error initializing DataRowStore.", ex); } startListeners(); } }
From source file:org.jpublish.view.velocity.VelocityViewRenderer.java
/** * Initialize the ViewRenderer./*from w w w . jav a 2s . c o m*/ * * @throws Exception Any Exception */ public void init() throws Exception { log.debug("init()"); // it may be necessary to put caching support here, in which case // the cache parameters should be specified in the view config. ExtendedProperties eprops = new ExtendedProperties(); eprops.putAll(velocityProperties); eprops.addProperty(RuntimeConstants.RESOURCE_LOADER, "jpublish"); eprops.setProperty("jpublish.resource.loader.description", "JPublish internal resource loader."); eprops.setProperty("jpublish.resource.loader.class", "org.jpublish.view.velocity.JPublishResourceLoader"); eprops.setProperty("jpublish.resource.loader.siteContext", siteContext); if (resourceCacheEnabled) { eprops.setProperty("jpublish.resource.loader.cache", "true"); eprops.setProperty("jpublish.resource.loader.modificationCheckInterval", Integer.toString(getResourceCacheInterval())); } // Apply properties to VelocityEngine. velocityEngine.setExtendedProperties(eprops); try { velocityEngine.init(); velocityEngine.setApplicationAttribute(ServletContext.class.getName(), siteContext.getServletContext()); } catch (IOException ex) { throw ex; } catch (VelocityException ex) { throw ex; } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { log.error("Why does VelocityEngine throw a generic checked exception, after all?", ex); throw new VelocityException(ex.getMessage()); } log.info("Resource loader: " + velocityEngine.getProperty(VelocityEngine.RESOURCE_LOADER)); }
From source file:org.objectstyle.cayenne.access.DataRowStore.java
protected void initWithProperties(Map properties) { ExtendedProperties propertiesWrapper = new ExtendedProperties(); if (properties != null) { propertiesWrapper.putAll(properties); }// www . j a v a 2s . c o m long snapshotsExpiration = propertiesWrapper.getLong(SNAPSHOT_EXPIRATION_PROPERTY, SNAPSHOT_EXPIRATION_DEFAULT); int snapshotsCacheSize = propertiesWrapper.getInt(SNAPSHOT_CACHE_SIZE_PROPERTY, SNAPSHOT_CACHE_SIZE_DEFAULT); boolean notifyRemote = propertiesWrapper.getBoolean(REMOTE_NOTIFICATION_PROPERTY, REMOTE_NOTIFICATION_DEFAULT); String eventBridgeFactory = propertiesWrapper.getString(EVENT_BRIDGE_FACTORY_PROPERTY, EVENT_BRIDGE_FACTORY_DEFAULT); if (logObj.isDebugEnabled()) { logObj.debug("DataRowStore property " + SNAPSHOT_EXPIRATION_PROPERTY + " = " + snapshotsExpiration); logObj.debug("DataRowStore property " + SNAPSHOT_CACHE_SIZE_PROPERTY + " = " + snapshotsCacheSize); logObj.debug("DataRowStore property " + REMOTE_NOTIFICATION_PROPERTY + " = " + notifyRemote); logObj.debug("DataRowStore property " + EVENT_BRIDGE_FACTORY_PROPERTY + " = " + eventBridgeFactory); } // init ivars from properties this.notifyingRemoteListeners = notifyRemote; // TODO: ENTRY EXPIRATION is not supported by commons LRU Map this.snapshots = new LRUMap(snapshotsCacheSize); // TODO: cache size should really be a sum of all result lists sizes... // so we must track it outside the LRUMap... this.snapshotLists = new LRUMap(snapshotsCacheSize); // init event bridge only if we are notifying remote listeners if (notifyingRemoteListeners) { try { EventBridgeFactory factory = (EventBridgeFactory) Class.forName(eventBridgeFactory).newInstance(); this.remoteNotificationsHandler = factory.createEventBridge(getSnapshotEventSubject(), properties); // listen to EventBridge EventManager.getDefaultManager().addListener(this, "processRemoteEvent", SnapshotEvent.class, getSnapshotEventSubject(), remoteNotificationsHandler); // start EventBridge - it will listen to all event sources for this // subject remoteNotificationsHandler.startup(EventManager.getDefaultManager(), EventBridge.RECEIVE_LOCAL_EXTERNAL); } catch (Exception ex) { throw new CayenneRuntimeException("Error initializing DataRowStore.", ex); } } }