Package org.apache.commons.configuration.interpol

Examples of org.apache.commons.configuration.interpol.ConfigurationInterpolator


        boolean success;
        do
        {
            // do this in a loop because the ConfigurationInterpolator
            // instance may be changed by another thread
            ConfigurationInterpolator ciOld = getInterpolator();
            ConfigurationInterpolator ciNew =
                    (ciOld != null) ? ciOld : new ConfigurationInterpolator();
            ciNew.registerLookups(lookups);
            success = interpolator.compareAndSet(ciOld, ciNew);
        } while (!success);
    }
View Full Code Here


    public void setDefaultLookups(Collection<? extends Lookup> lookups)
    {
        boolean success;
        do
        {
            ConfigurationInterpolator ciOld = getInterpolator();
            ConfigurationInterpolator ciNew =
                    (ciOld != null) ? ciOld : new ConfigurationInterpolator();
            Lookup confLookup = findConfigurationLookup(ciNew);
            if (confLookup == null)
            {
                confLookup = new ConfigurationLookup(this);
            }
            else
            {
                ciNew.removeDefaultLookup(confLookup);
            }
            ciNew.addDefaultLookups(lookups);
            ciNew.addDefaultLookup(confLookup);
            success = interpolator.compareAndSet(ciOld, ciNew);
        } while (!success);
    }
View Full Code Here

    public void setParentInterpolator(ConfigurationInterpolator parent)
    {
        boolean success;
        do
        {
            ConfigurationInterpolator ciOld = getInterpolator();
            ConfigurationInterpolator ciNew =
                    (ciOld != null) ? ciOld : new ConfigurationInterpolator();
            ciNew.setParentInterpolator(parent);
            success = interpolator.compareAndSet(ciOld, ciNew);
        } while (!success);
    }
View Full Code Here

     * @since 2.0
     */
    protected void cloneInterpolator(AbstractConfiguration orgConfig)
    {
        interpolator = new AtomicReference<ConfigurationInterpolator>();
        ConfigurationInterpolator orgInterpolator = orgConfig.getInterpolator();
        List<Lookup> defaultLookups = orgInterpolator.getDefaultLookups();
        Lookup lookup = findConfigurationLookup(orgInterpolator, orgConfig);
        if (lookup != null)
        {
            defaultLookups.remove(lookup);
        }

        installInterpolator(orgInterpolator.getLookups(), defaultLookups);
    }
View Full Code Here

     * @param value the value to interpolate
     * @return the value with variables substituted
     */
    protected Object interpolate(Object value)
    {
        ConfigurationInterpolator ci = getInterpolator();
        return (ci != null) ? ci.interpolate(value) : value;
    }
View Full Code Here

     * @return the newly created interpolator object
     * @since 1.4
     */
    protected ConfigurationInterpolator createInterpolator()
    {
        ConfigurationInterpolator interpol = new ConfigurationInterpolator();
        interpol.setDefaultLookup(new StrLookup()
        {
            public String lookup(String var)
            {
                Object prop = resolveContainerStore(var);
                return (prop != null) ? prop.toString() : null;
View Full Code Here

     * Tests accessing and manipulating the interpolator object.
     */
    public void testGetInterpolator()
    {
        config.addProperty("var", "${echo:testVar}");
        ConfigurationInterpolator interpol = config.getInterpolator();
        interpol.registerLookup("echo", new StrLookup()
        {
            public String lookup(String varName)
            {
                return "Value of variable " + varName;
            }
View Full Code Here

         * @param config the newly created configuration instance
         */
        private void installInterpolator(ConfigurationDeclaration decl,
                AbstractConfiguration config)
        {
            ConfigurationInterpolator parent = new ConfigurationInterpolator();
            parent.setDefaultLookup(decl.getConfigurationBuilder().combinedConfigLookup);
            config.getInterpolator().setParentInterpolator(parent);
        }
View Full Code Here

            return super.interpolate(base);
        }
        else
        {
            SubsetConfiguration config = new SubsetConfiguration(parent, "");
            ConfigurationInterpolator interpolator = config.getInterpolator();
            getInterpolator().registerLocalLookups(interpolator);
            if (parent instanceof AbstractConfiguration)
            {
                interpolator.setParentInterpolator(((AbstractConfiguration) parent).getInterpolator());
            }
            return config.interpolate(base);
        }
    }
View Full Code Here

     * @param config the configuration to test
     */
    public static void testGetInterpolator(AbstractConfiguration config)
    {
        config.addProperty("var", "${echo:testVar}");
        ConfigurationInterpolator interpol = config.getInterpolator();
        interpol.registerLookup("echo", new StrLookup()
        {
            @Override
            public String lookup(String varName)
            {
                return "Value of variable " + varName;
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.interpol.ConfigurationInterpolator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.