@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(); } }
@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(); } }
@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()); }
@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; }
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; }