Example usage for org.apache.commons.collections ExtendedProperties addProperty

List of usage examples for org.apache.commons.collections ExtendedProperties addProperty

Introduction

In this page you can find the example usage for org.apache.commons.collections ExtendedProperties addProperty.

Prototype

public void addProperty(String key, Object value) 

Source Link

Document

Add a property to the configuration.

Usage

From source file:generate.tostring.velocity.VelocityFactory.java

/**
 * Returns a new instance of the VelocityEngine.
 * <p/>/*from ww w .j a  v  a2s. c o  m*/
 * 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:com.maddyhome.idea.copyright.util.VelocityHelper.java

private static synchronized VelocityEngine getEngine() {
    if (instance == null) {
        try {/*www .ja v  a  2 s  . c om*/
            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:com.maddyhome.idea.copyright.pattern.VelocityHelper.java

private static synchronized VelocityEngine getEngine() {
    if (instance == null) {
        try {/*from  ww w.  j  a  v  a  2  s. 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:org.intellij.plugins.util.TemplateEngine.java

private void initVelocityProcess() {
    if (inited)/* www .  j  ava 2 s.  c o  m*/
        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.cyclopsgroup.waterview.velocity.VelocityEngine.java

/**
 * Overwrite or implement method initialize()
 * @see org.apache.avalon.framework.activity.Initializable#initialize()
 *//*from  w  ww.  j  ava  2 s .  c  o  m*/
public void initialize() throws Exception {
    ExtendedProperties props = new ExtendedProperties();
    if (initProperties != null) {
        for (Iterator i = initProperties.keySet().iterator(); i.hasNext();) {
            String name = (String) i.next();
            props.addProperty(name, initProperties.getProperty(name));
        }
    }
    props.load(getClass().getResourceAsStream("basevelocity.properties"));

    engine = new org.apache.velocity.app.VelocityEngine();
    engine.setExtendedProperties(props);
    engine.init();
}

From source file:ca.simplegames.micro.viewers.velocity.VelocityViewRenderer.java

public void init() throws Exception {
    ExtendedProperties eprops = new ExtendedProperties();
    eprops.putAll(velocityProperties);//from w w  w. ja  v  a 2s  . com
    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()));
    }

    // 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:org.github.bpark.generator.VelocityEngineFactory.java

/**
 * Creates a velocity engine, or returns an existing instance.
 *
 * @return the velocity engine./*from w ww .  ja va 2 s . com*/
 */
public static VelocityEngine getVelocityEngine() {
    if (engine == null) {
        ExtendedProperties prop = new ExtendedProperties();
        prop.addProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, SimpleLog4JLogSystem.class.getName());
        prop.addProperty("runtime.log.logsystem.log4j.category", "GenerateToString");
        engine = new VelocityEngine();
        engine.setExtendedProperties(prop);
        engine.init();
    }

    return engine;
}

From source file:org.jpublish.view.velocity.VelocityViewRenderer.java

/**
 * Initialize the ViewRenderer./* w  w w  . j  a v a  2s  . c om*/
 *
 * @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.kalypso.metadoc.configuration.ConfigurationUtils.java

/**
 * Add the value to the given property. If the property is already defined, it adds the value only if it is not
 * already existing in the list of values for that property.
 *//*from  www .  j  a  va  2s.c om*/
public static void addPropertyDistinct(final ExtendedProperties conf, final String property,
        final String value) {
    if (conf == null || value == null || property == null)
        return;

    final String[] array = conf.getStringArray(property);
    if (array == null || !Arrays.asList(array).contains(value))
        conf.addProperty(property, value);
}

From source file:org.sakaiproject.kernel.proxy.ProxyClientServiceImpl.java

/**
 * Create resources used by this component.
 * /*from w  ww  .ja v  a  2 s . c om*/
 * @param ctx
 * @throws Exception
 */
public void activate(ComponentContext ctx) throws Exception {
    velocityEngine = new VelocityEngine();
    velocityEngine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, new VelocityLogger(this.getClass()));

    velocityEngine.setProperty(VelocityEngine.RESOURCE_LOADER, JCR_RESOURCE_LOADER);
    velocityEngine.setProperty(JCR_RESOURCE_LOADER_CLASS, JcrResourceLoader.class.getName());
    ExtendedProperties configuration = new ExtendedProperties();
    configuration.addProperty(JCR_RESOURCE_LOADER_PATH + ProxyNodeSource.JCR_RESOURCE_LOADER_RESOURCE_SOURCE,
            this);
    velocityEngine.setExtendedProperties(configuration);
    velocityEngine.init();

    httpClientConnectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    // could set a whole load of connection properties
    httpClientConnectionManager.setParams(params);

    httpClient = new HttpClient(httpClientConnectionManager);
}