Bboss aop 架構在1.0.6版本中增加全局屬性配置管理功能,并提供了相應的接口來擷取這些屬性,本節詳細介紹。
bboss 項目下載下傳位址:
https://sourceforge.net/project/showfiles.php?group_id=238653屬性配置
Bboss aop中可以在業務元件的配置檔案配置系統全局屬性,使用者可以在
n manager-provider.xml配置
n manager-xxxx-provider.xml中配置
n 專名的manager-xxx-propeties.xml配置,需要導入到manager-provider.xml檔案中
下面是manager-provider.xml的一個例子:
<manager-config>
<properties>
<property name="cluster_enable" value="true"/>
<property name="cluster_mbean_enable" value="true"/>
<property name="cluster_name" value="Cluster"/>
</properties>
<managerimport file="com/chinacreator/spi/properties/properties.xml" />
<managerimport file="com/chinacreator/spi/rpc/service-assemble.xml" />
</manager-config>
其中單獨配置了幾個屬性,同時導入了一個檔案
com/chinacreator/spi/properties/properties.xml
其内容為:
<property name="int_enable" value="1"/>
<property name="cluster_str" value="cluster_str"/>
屬性擷取
BaseSPIProvider元件中提供了如下接口用來擷取全局屬性的值:
public static String getProperty(String name) ;
public static int getIntProperty(String name) ;
public static boolean getBooleanProperty(String name);
public static String getProperty(String name, String defaultValue);
public static int getIntProperty(String name, int defaultValue) ;
public static boolean getBooleanProperty(String name, boolean defaultValue) ;
通過上述接口,你可以擷取以下類型的屬性:
String
Int
Boolean
并且可以指定預設值,具體用法就不舉例了。