@Override
    public Config findByPK(int keyId, Readset<Config> readset) throws DalException {
      Config config = new Config();

      config.setId(keyId);
      config.setModifyDate(new Date());
      config.setContent(new Company().toString());
      return config;
    }
    @Override
    public Config findByName(String name, Readset<Config> readset) throws DalException {
      Config config = new Config();

      config.setName(name);
      Company company = new Company();
      ProductLine productLine = new ProductLine("Test");

      company.addProductLine(productLine);
      config.setContent(company.toString());
      config.setModifyDate(new Date());
      return config;
    }
예제 #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
  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();
      }
    }
  }
예제 #5
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;
  }
예제 #6
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();
    }
  }
예제 #7
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();
    }
  }