All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.logicbus.models.servant.ServantManager Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.logicbus.models.servant;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import com.logicbus.backend.PathPatternSupport;
import org.apache.commons.lang3.StringUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.anysoft.util.Factory;
import com.anysoft.util.IOTools;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import com.anysoft.util.Settings;
import com.anysoft.util.XmlTools;
import com.anysoft.util.resource.ResourceFactory;
import com.logicbus.models.catalog.Path;
import com.logicbus.backend.ServantRegistry;

/**
 * 服务规格管理器
 * 
 * 
* 服务规格管理器负责从服务目录中读取服务规格信息,可支持一到多个服务目录.配置文件地址可以从web.xml或者全局参数中读取,参数包括:
* * - master.servant.config 配置文件URL地址,缺省为:java:///com/logicbus/models/servant/default.xml
* - secondary.servant.config 配置文件备用URL地址,缺省为:java:///com/logicbus/models/servant/default.xml
* * 缺省的配置文件内容如下:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * * * * * * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * *
* * 由于{@link ServantManager}在查找服务时是一个一个服务目录查找的,因此配置文件中的服务目录次序就很重要,如果配置在前面,将优先被搜索到. * 例如配置了服务目录A和服务目录B,而A和B中都包含了服务/demo/logicbus/Helloworld,由于A配置在前面,将永远搜索到A提供的/demo/logicbus/Helloworld, * 而B中提供的/demo/logicbus/Helloworld服务则永远不会被调用.
* * @author duanyy * * @version 1.6.7.9 [20170201 duanyy]
* - 采用SLF4j日志框架输出日志
* * @version 1.6.7.20
* - 改造ServantManager模型,增加服务配置监控机制
* * @version 1.6.14.12 [20210617 duanyy]
* - 部分功能迁移到基类
*/ public class ServantManager extends ServantRegistry.Abstract{ /** * 缺省配置文件 */ protected static final String DEFAULT = "java:///com/logicbus/models/servant/servantcatalog.default.xml#com.logicbus.backend.server.LogicBusApp"; /** * Constructor * */ public ServantManager(){ } @Override public void configure(Properties p) { super.configure(p); String configFile = PropertiesConstants.getString(p,"servant.config.master",DEFAULT,false); String secondaryFile = PropertiesConstants.getString(p,"servant.config.secondary",DEFAULT,false); InputStream in = null; try { ResourceFactory rf = Settings.getResourceFactory(); in = rf.load(configFile,secondaryFile, null); Document doc = XmlTools.loadFromInputStream(in); if (doc != null) { loadConfig(p, doc.getDocumentElement()); } } catch (Exception ex){ logger.error("Error occurs when load xml file,source=" + configFile, ex); }finally { IOTools.closeStream(in); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy