Package groovy.util

Examples of groovy.util.ConfigObject


            }
            else {
                this.config = new PropertySourcesConfig();
                if(ClassUtils.isPresent("Config", classLoader)) {
                    try {
                        ConfigObject co = new ConfigSlurper().parse(ClassUtils.forName("Config", classLoader));
                        this.config.merge(co);
                    } catch (ClassNotFoundException e) {
                        // ignore
                    }
                }
View Full Code Here


     * @return The currently bound GrailsApplication instance
     * @since 2.0
     */
    public static Map currentConfiguration() {
        GrailsApplication application = currentApplication();
        return application == null ? new ConfigObject() : application.getConfig();
    }
View Full Code Here

    }

    public void informOfClassChange(File file, @SuppressWarnings("rawtypes") Class cls) {
        if (cls != null && (cls.getName().equals(CONFIG_FILE) || cls.getName().equals(GrailsApplication.DATA_SOURCE_CLASS))) {
            ConfigSlurper configSlurper = ConfigurationHelper.getConfigSlurper(Environment.getCurrent().getName(), application);
            ConfigObject c;
            try {
                c = configSlurper.parse(file.toURI().toURL());
                application.getConfig().merge(c);
                application.configChanged();
                informPluginsOfConfigChange();
View Full Code Here

        String src = "Chinese text: \u3421\u3437\u343f\u3443\u3410\u3405\u38b3\u389a\u395e\u3947\u3adb\u3b5a\u3b67";
        // Sanity check the string loaded OK as unicode - it won't look right if you output it, default stdout is not UTF-8
        // on many OSes
        assertEquals(src.indexOf('?'), -1);

        ConfigObject config = new ConfigSlurper().parse("grails.views.gsp.encoding = \"UTF-8\"");

        buildMockRequest(config);
        ParsedResult output = null;
        try {
            output = parseCode("myTest4", src);
View Full Code Here

    public void contextInitialized(ServletContextEvent event) {
        try {
            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
            Object grailsApplication = createGrailsApplication(contextClassLoader);
            ConfigObject co = getConfig(grailsApplication);
            Log4jConfig.initialize(co);
        }
        catch (Throwable e) {
            LogLog.error("Error initializing log4j: " + e.getMessage(), e);
        }
View Full Code Here

        assertEquals("/layouts/application.gsp", d.getPage());
        assertEquals("application", d.getName());
    }

    public void testOverridingDefaultTemplateViaConfig() throws Exception {
            ConfigObject config = new ConfigSlurper().parse("grails.sitemesh.default.layout='otherApplication'");
            MutablePropertySources propertySources = new MutablePropertySources();
            propertySources.addLast(new MapPropertySource("grails", config));

            GrailsWebRequest webRequest = buildMockRequest(new PropertySourcesConfig(propertySources));
            webRequest.setAttribute(GrailsLayoutDecoratorMapper.RENDERING_VIEW, Boolean.TRUE, RequestAttributes.SCOPE_REQUEST);
View Full Code Here

   * @param secondary new default values
   * @return the merged configs
   */
  @SuppressWarnings("unchecked")
  private static ConfigObject mergeConfig(final ConfigObject currentConfig, final ConfigObject secondary) {
    ConfigObject config = new ConfigObject();
    if (secondary == null) {
      if (currentConfig != null) {
        config.putAll(currentConfig);
      }
    }
    else {
      if (currentConfig == null) {
        config.putAll(secondary);
      }
      else {
        config.putAll(secondary.merge(currentConfig));
      }
    }
    return config;
  }
View Full Code Here

   * @param className the name of the config class to load
   */
  private static void mergeConfig(final ConfigObject currentConfig, final String className) {
    GroovyClassLoader classLoader = new GroovyClassLoader(SpringSecurityUtils.class.getClassLoader());
    ConfigSlurper slurper = new ConfigSlurper(Environment.getCurrent().getName());
    ConfigObject secondaryConfig;
    try {
      secondaryConfig = slurper.parse(classLoader.loadClass(className));
    }
    catch (ClassNotFoundException e) {
      throw new RuntimeException(e);
    }

    _securityConfig = mergeConfig(currentConfig, (ConfigObject)secondaryConfig.getProperty("security"));
    ReflectionUtils.setSecurityConfig(_securityConfig);
  }
View Full Code Here

            throw new RuntimeException("Cannot load [" + location + "], it is not found or your location of the file " +
                                       "is incorrect. You have declared that your test [" + testClassName +"] requires " +
                                       "a configuration file, but the file cannot be loaded. Check the setting of the " +
                                       "org.rioproject.test.config system property");
        }
        ConfigObject config = new ConfigSlurper().parse(url);
        Map<String, Object> configMap = config.flatten();

        if (hasConfigurationFor(component, configMap)) {
            groups = getString(configMap.get(component + ".groups"));
            if (groups != null)
                System.setProperty(Constants.GROUPS_PROPERTY_NAME, groups);
View Full Code Here

TOP

Related Classes of groovy.util.ConfigObject

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.