예제 #1
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());
  }
예제 #2
0
  public boolean insert(String xml) {
    try {
      m_config = DefaultSaxParser.parse(xml);

      return storeConfig();
    } catch (Exception e) {
      Cat.logError(e);
      return false;
    }
  }
예제 #3
0
  public void updateConfig() throws DalException, SAXException, IOException {
    Config config = m_configDao.findByName(CONFIG_NAME, ConfigEntity.READSET_FULL);
    long modifyTime = config.getModifyDate().getTime();

    synchronized (this) {
      if (modifyTime > m_modifyTime) {
        String content = config.getContent();
        AppSpeedConfig appConfig = DefaultSaxParser.parse(content);

        m_config = appConfig;
        m_modifyTime = modifyTime;
        updateData();
      }
    }
  }