예제 #1
0
  @Override
  public void initialize() throws InitializationException {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();

      m_domainGroup = DefaultSaxParser.parse(content);
      m_configId = config.getId();
    } catch (DalNotFoundException e) {
      try {
        String content =
            Files.forIO()
                .readFrom(
                    this.getClass().getResourceAsStream("/config/default-domain-group-config.xml"),
                    "utf-8");
        Config config = m_configDao.createLocal();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        m_configDao.insert(config);

        m_domainGroup = DefaultSaxParser.parse(content);
        m_configId = config.getId();
      } catch (Exception ex) {
        Cat.logError(ex);
      }
    } catch (Exception e) {
      Cat.logError(e);
    }
    if (m_domainGroup == null) {
      m_domainGroup = new DomainGroup();
    }
  }
예제 #2
0
  @Override
  public void initialize() throws InitializationException {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();

      m_thirdPartyConfig = DefaultSaxParser.parse(content);
      m_configId = config.getId();
    } catch (DalNotFoundException e) {
      try {
        String content = m_getter.getConfigContent(CONFIG_NAME);
        Config config = m_configDao.createLocal();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        m_configDao.insert(config);

        m_thirdPartyConfig = DefaultSaxParser.parse(content);
        m_configId = config.getId();
      } catch (Exception ex) {
        Cat.logError(ex);
      }
    } catch (Exception e) {
      Cat.logError(e);
    }
    if (m_thirdPartyConfig == null) {
      m_thirdPartyConfig = new ThirdPartyConfig();
    }
  }
예제 #3
0
  @Override
  public void initialize() {
    try {
      Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
      String content = config.getContent();

      m_configId = config.getId();
      m_config = DefaultSaxParser.parse(content);
      m_modifyTime = config.getModifyDate().getTime();
      updateData();
    } catch (DalNotFoundException e) {
      try {
        String content = m_fetcher.getConfigContent(CONFIG_NAME);
        Config config = m_configDao.createLocal();

        config.setName(CONFIG_NAME);
        config.setContent(content);
        m_configDao.insert(config);
        m_configId = config.getId();
        m_config = DefaultSaxParser.parse(content);
      } catch (Exception ex) {
        Cat.logError(ex);
      }
    } catch (Exception e) {
      Cat.logError(e);
    }
    if (m_config == null) {
      m_config = new AppSpeedConfig();
    }
    Threads.forGroup("cat").start(new ConfigReloadTask());
  }
예제 #4
0
  private boolean storeConfig() {
    synchronized (this) {
      try {
        Config config = m_configDao.createLocal();

        config.setId(m_configId);
        config.setKeyId(m_configId);
        config.setName(CONFIG_NAME);
        config.setContent(m_domainGroup.toString());
        m_configDao.updateByPK(config, ConfigEntity.UPDATESET_FULL);
      } catch (Exception e) {
        Cat.logError(e);
        return false;
      }
    }
    return true;
  }