Package org.ini4j

Examples of org.ini4j.Ini


    webapp.setFullPath(fullPath);
   
    /*
     * Create collections to hold our settings, frameworks and webapps for later processing
     */
    Ini ini = new Ini();
    File appSettings = new File(fullPath + "/src/main/webapp/adaptrex/app.config");
    if (!appSettings.exists()) return null;
    ini.load(new FileReader(appSettings));
   
    /*
     * Get our app name
     */
    Ini.Section settingsSection = ini.get(SETTINGS);
    webapp.setName(settingsSection.get("name"));
    webapp.setBasePackage(settingsSection.get(BASE_PACKAGE));
    webapp.setGlobalFolder(settingsSection.get(GLOBAL_FOLDER));
    webapp.setGlobalNamespace(settingsSection.get(GLOBAL_NAMESPACE));
   
   
    /*
     * Get information about our webapp's frameworks
     */
    Ini.Section frameworkSection = ini.get(FRAMEWORKS);
    if (frameworkSection.containsKey(ADAPTREXJS))
      webapp.setAdaptrex(env.getAdaptrexFrameworks().get(frameworkSection.get(ADAPTREXJS)));
    if (frameworkSection.containsKey(EXTJS))
      webapp.setExt(env.getExtFrameworks().get(frameworkSection.get(EXTJS)));
    if (frameworkSection.containsKey(SENCHA_TOUCH))
      webapp.setSenchaTouch(env.getSenchaTouchFrameworks().get(frameworkSection.get(SENCHA_TOUCH)));
    if (frameworkSection.containsKey(ORM))
      webapp.setOrm(frameworkSection.get(ORM));
    if (frameworkSection.containsKey(PRESENTATION))
      webapp.setPresentation(frameworkSection.get(PRESENTATION));
    if (frameworkSection.containsKey(DI))
      webapp.setDi(frameworkSection.get(DI));
     
   
    /*
     * Get our list of pages
     */
    Map<String,String> pagesSection = ini.get(PAGES);
    Map<String,Page> pages = webapp.getPages();
    if (pagesSection != null) {
      for (String key : pagesSection.keySet()) {
        String[] valueParts = pagesSection.get(key).split(",");
        String path = key.replace(".", "/");
View Full Code Here


    if (!configFile.exists()) {
      File adaptrexFolder = new File(webapp.getFullPath() + "/src/main/webapp/adaptrex");
      adaptrexFolder.mkdirs();
      configFile.createNewFile();
    }
    Ini ini = new Ini();
    ini.load(new FileReader(configFile));
   
    Ini.Section settingsSection = ini.get(SETTINGS);
    if (settingsSection == null) settingsSection = ini.add(SETTINGS);   
    settingsSection.put(NAME, webapp.getName());
    settingsSection.put(BASE_PACKAGE, webapp.getBasePackage());
    settingsSection.put(GLOBAL_NAMESPACE, webapp.getGlobalNamespace());
    settingsSection.put(GLOBAL_FOLDER, webapp.getGlobalFolder());
   
    Ini.Section frameworksSection = ini.get(FRAMEWORKS);
    if (frameworksSection == null) frameworksSection = ini.add(FRAMEWORKS);
   
    if (webapp.getAdaptrex() != null)
      frameworksSection.put(ADAPTREXJS, webapp.getAdaptrex().getFolderName());
    if (webapp.getExt() != null)
      frameworksSection.put(EXTJS, webapp.getExt().getFolderName());
    if (webapp.getSenchaTouch() != null)
      frameworksSection.put(SENCHA_TOUCH, webapp.getSenchaTouch().getFolderName());
    if (webapp.getOrm() != null)
      frameworksSection.put(ORM, webapp.getOrm());
    if (webapp.getPresentation() != null)
      frameworksSection.put(PRESENTATION, webapp.getPresentation());
    if (webapp.getDi() != null)
      frameworksSection.put(DI, webapp.getDi());
   
    Ini.Section pagesSection = ini.get(PAGES);
    if (pagesSection == null) pagesSection = ini.add(PAGES);
    pagesSection.clear();
    Map<String,Page> pages = webapp.getPages();
    for (String key : pages.keySet()) {
      Page page = pages.get(key);
      pagesSection.put(key, page.getNamespace() + "," + page.getFrameworkType());
    }
   
    ini.store(configFile);
  }
View Full Code Here

      throw new NullPointerException("null argument");
   
    if (cf == null)
      cf = ConfigurationFactory.newInstance();
   
    Ini ini = new Ini();
    ini.load(is);
   
    Configuration cfg = loadPipelineConfiguration(ini, context, cf);
    String pipeline_name = ini.get(SECT_GENERAL, OPT_PIPELINE_NAME);
    String module_url = ini.get(SECT_GENERAL, OPT_MODULE_NAME);
    String status_string = ini.get(SECT_GENERAL, OPT_STATUS);
    boolean status = status_string == null ? DEFAULT_STATUS : Boolean.parseBoolean(status_string);
   
    ModuleAttributes atts = loadAttributes(ini.get(SECT_ATTRIBUTES), context);
    Map<String,byte[]> input = loadSection(ini.get(SECT_INPUT), context);
    Map<String,byte[]> output = loadSection(ini.get(SECT_OUTPUT), context);

    if ((module_url==null) == (pipeline_name==null))
      throw new Exception(String.format("One of '%s' and '%s' must be specified (but not both).", OPT_PIPELINE_NAME, OPT_MODULE_NAME));
   
    if (pipeline_name != null)
View Full Code Here

                this.appClassPath = appClassDir.getAbsolutePath() + "/";
            }
            if (!file.exists()) {
                throw new MetamorphosisServerStartupException("File " + path + " is not exists");
            }
            final Ini conf = this.createIni(file);
            this.populateAttributes(conf);
        }
        catch (final IOException e) {
            throw new MetamorphosisServerStartupException("Parse configuration failed,path=" + path, e);
        }
View Full Code Here


    public void loadFromString(final String str) {
        try {
            StringReader reader = new StringReader(str);
            final Ini conf = new Ini(reader);
            this.populateAttributes(conf);
        }
        catch (final IOException e) {
            throw new MetamorphosisServerStartupException("Parse configuration failed,path=" + this.path, e);
        }
View Full Code Here

        }
    }


    private Ini createIni(final File file) throws IOException, InvalidFileFormatException {
        final Ini conf = new Ini(file);
        this.lastModified = file.lastModified();
        this.configFileChecksum = org.apache.commons.io.FileUtils.checksumCRC32(file);
        this.propertyChangeSupport.firePropertyChange("configFileChecksum", null, null);
        return conf;
    }
View Full Code Here

    public void reload() {
        final File file = new File(this.path);
        if (file.lastModified() != this.lastModified) {
            try {
                log.info("Reloading topics......");
                final Ini conf = this.createIni(file);
                MetaConfig.this.populateTopicsConfig(conf);
                log.info("Reload topics successfully");
            }
            catch (final Exception e) {
                log.error("Reload config failed", e);
View Full Code Here

            if (this.isConfigFileChanged(true)) {
                logger.info("Reloading configuration......");
//                Properties props = Utils.getResourceAsProperties(this.configPath, "GBK");
//                this.populateConfig(props);
                File iniFile = Utils.getResourceAsFile(this.configPath);
                final Ini iniConfig = new Ini();
                iniConfig.load(iniFile);
                this.populateConfig(iniConfig);
                logger.info(this.toString());
                logger.info("wwList:"+this.getWangwangList().toString());
                logger.info("Reload topics successfully");
            }
View Full Code Here

  //add by liuqingjie.pt
    public void loadInis(String resource) throws IOException {
        this.configPath = resource;
        this.isConfigFileChanged(true);
        File iniFile = Utils.getResourceAsFile(resource);
        final Ini iniConfig = new Ini();
        //ini4j������/��ʱ�����䵱���ָ��ַ���������ķָ��ַ�
        iniConfig.getConfig().setPathSeparator('+');
        iniConfig.getConfig().setFileEncoding(Charset.forName("GBK"));
    iniConfig.load(iniFile);
        this.populateConfig(iniConfig);
    }
View Full Code Here

TOP

Related Classes of org.ini4j.Ini

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.