ConfigurationManagerUtils API

来源:互联网 发布:tomcat配置优化 编辑:程序博客网 时间:2024/06/03 14:15
       <span style="font-size:24px;">   public final class ConfigurationManagerUtils本类为系统的配置处理提供了一些公用的静态方法。本类的属性:1,Pattern globalSymbolPattern = Pattern.compile("\\$\\{(\\w+)\\}"):本属性是为对component中引用了globalproperty的value进行处理的Pattern,以便得到globalproperty中我们需要的value值。2,GLOBAL_COMMON_LOGLEVEL = "logLevel":所有component的共同logLevel property即属性。3,CM_FILE_SUFFIX = ".sxl":配置文件的默认后缀。本类的构造方法为私有的空构造方法,本类不能通过构造方法实例化。本类的方法:1,boolean validateConfiguration(ConfigurationManager cm):验证cm的所有的component的property-name是是否在其相应的ps的registeredProperties中存在。2,String stripGlobalSymbol(String symbol):通过使用了模式属性pattern。去掉component中引用了全局属性的”${}”符号,得到其{}内的字符串。3,editConfig(ConfigurationManager cm, String name):本法通过(从键盘输入)标准输入的方式,来设置name的component(ps)的rawproperty。Rawproperty是name必须在ps的RegisteredProperties中存在。输入.号即结束编辑属性。4,String getLogPrefix(ConfigurationManager cm):如果配置通过文件配置的,则返回的是文件的路径去掉后缀的部分字符串,但是保留了.号。否则得返回“S4CM.“。5,configureLogger(ConfigurationManager cm):配置logger。6,Map<String, String> fixDuplicateNames(ConfigurationManager baseCM, ConfigurationManager subCM):注意本方法只能够改变了subCM的componentname。本方法把subCM中的所有componentname,以componentname-componentname的形式放入到返回的map中,但是如果在baseCM中含有与subCM的componentname那么其放入的形式为componentname-componentname+1的形式放入Map中,并且对subCM的componentname进行重命名。7,String toXML(ConfigurationManager cm):本方法以xml文件的格式输出配置信息。相当于再重新返回成xml的配置形式。以字符串输出。包括globalproperty,component。8,String propSheet2XML(String instanceName, PropertySheet ps):本方法 把特定ps中的内容转换成与在配置文件中的相同格式(xml格式),即xml中component形式,并以字符串形式输出。9,void save(ConfigurationManager cm, File cmLocation):本方法把系统的配置信息以xml的形式输出到cmLocation文件中。10,showConfig(ConfigurationManager cm):本方法标准输出显示系统所有的component的配置信息。即显示系统配置信息。11,showConfig(ConfigurationManager cm, String name):本方法显示标准单个的component(configurable)的配置信息。12,applySystemProperties(Map<String, RawPropertyData> rawMap, Map<String, String> global):本法获得由系统输入的(在命令行下,就是启动程序时,在程序的后面输入的参数)component的配置信息。并放入相应的component的RawPropertyData中或globalproperty中。13,renameComponent(ConfigurationManager cm, String oldName, String newName):本法是对component(configurable)进行重命名,包括在包含此component的component(ps)中对此component(property)属性重命名,同时也包括对对本component的ps中的InstanceName进行重命名。如在GlobalProperty存在,则也对其name进行重命名。14,URL getResource(String name, PropertySheet ps):本方法得到特定ps中的特定资源字符串,并转换成URL输出。15,Pattern jarPattern = Pattern.compile("resource:(.*)", Pattern.CASE_INSENSITIVE):设置一个不区分大小写的模式,以便用于匹配。16,URL resourceToURL(String location):通过15的匹配把字符串转换为URL。以便找到指定的资源。17,isDerivedClass(Class<?> aClass, Class<?> possibleParent):如果aClass等于possibleParent或aClass是possibleParent的子类或者子接口返回为true,否则为false。18,isImplementingInterface(Class<?> aClass, Class<?> interfaceClass):本方法表示aClass是否是interfaceClass的子接口,即实现了interfaceClass表示的接口。19,isSubClass(Class<?> aClass, Class<?> possibleSuperclass):本方法表示aClass是否是possibleSuperclass的子类。20,ConfigurationManager getPropertyManager(PropertySheet ps):根据ps获得相应的CM。21,Map<String, List<PropertySheet>> listAllsPropNames(ConfigurationManager cm):本方法得到CM的所有component的PropertySheet和registeredProperties中的propname,即String为propertyname(propname)——propertyname所属的PropertySheet。22,dumpPropStructure(ConfigurationManager cm):标准输出PropStructure的结构信息,按21的存储形式。23,setProperty(ConfigurationManager cm, String propName, String propValue):本方法设置propName (component)的value为propValue 。Attempts to set the value of an arbitrary component-property. If the property-name is ambiguous  with respect to the given ConfiguratioManager an extended syntax (componentName->propName) can be used to access the property. Beside component properties it is also possible to modify the class of a configurable, but this is only allowed if the configurable under question has not been instantiated yet. Furthermore the user has to ensure to set allmandatory component properties.24,setProperty(ConfigurationManager cm, String componentName, String propName, String propValue):本方法用于设置一个特定ps(component)中的propName--propValue。设置后即生效。25,URL getURL(File file):获得一个file的URL。26,Collection<String> getNonInstaniatedComps(ConfigurationManager cm):获得位初始化得component即其ps中的configurable为null即没有初始化,我们运行程序时需要的是类的对象即实例。27,setClass(PropertySheet ps, Class<? extends Configurable> confClass):设定特定ps的ownerClass即Class类型对象。注意ps被实例化了出现异常。28,List<String> toStringList(Object obj):obj需是List<?>,并把obj中每一个转换成String,放入输出List<String>中输出。</span>

0 0
原创粉丝点击