| | |
| | | package com.dy.pipIrrGlobal.util; |
| | | |
| | | import com.dy.common.util.ConfigXml; |
| | | import com.dy.common.util.ConfigXml4Springboot; |
| | | import org.jdom2.Document; |
| | | import org.springframework.boot.context.event.ApplicationReadyEvent; |
| | | |
| | | import java.net.URL; |
| | | import org.springframework.core.io.ResourceLoader; |
| | | |
| | | /** |
| | | * @Author: liurunyu |
| | |
| | | * 实始化 |
| | | */ |
| | | @SuppressWarnings("unused ") |
| | | protected void init() { |
| | | this.init(null); |
| | | protected void init(ResourceLoader resourceLoader) { |
| | | this.doInit(resourceLoader); |
| | | } |
| | | /** |
| | | * 实始化 |
| | | */ |
| | | @SuppressWarnings("unused ") |
| | | protected void init(ApplicationReadyEvent event) { |
| | | protected void doInit(ResourceLoader resourceLoader) { |
| | | try { |
| | | URL configFileURL = OrgListenerSupport.class.getResource("/init-config.xml"); |
| | | ConfigXml configXml = new ConfigXml(); |
| | | Document doc = configXml.createDom(configFileURL); |
| | | ConfigXml4Springboot configXml = new ConfigXml4Springboot() ; |
| | | Document doc = configXml.createDom(resourceLoader, "init-config.xml") ; |
| | | this.doInit(configXml, doc); |
| | | } catch (Exception e) { |
| | | System.out.println("系统启动时,初始化配置出错 !"); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | private void doInit(ConfigXml configXml, Document doc) throws Exception { |
| | | private void doInit(ConfigXml4Springboot configXml, Document doc) throws Exception { |
| | | if (configXml != null && doc != null) { |
| | | for (int num = 1; num <= 10000; num++) { |
| | | if (configXml.existElement(doc, "config.orgs.org" + num)) { |
| | | String orgTag = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "tag", null, false, null); |
| | | String orgName = configXml.getSetAttrTxt(doc, "config.orgs.org" + num, "name", null, false, null); |
| | | Boolean enable = configXml.getSetAttrBoolean(doc, "config.orgs.org" + num, "enable", null, null); |
| | | if(enable != null && enable.booleanValue()){ |
| | | Org.OrgVo vo = new Org().new OrgVo() ; |
| | | vo.tag = orgTag ; |
| | | vo.name = orgName ; |
| | | Org.OrgList.add(vo) ; |
| | | } |
| | | }else{ |
| | | break ; |
| | | } |