AgileEAS.NET平台提供了独立的配置文件,主要涉及一般配置信息、IOC对象配置信息、SL服务配置信息、WinService插件配置信息:
系统配置文件重有如下配置项定义:
<configSections>
<section name="EAS.Configurations" type="EAS.Configuration.ConfigHandler,EAS.Kernel" />
<section name="EAS.WinServices" type="EAS.WinService.ConfigHandler,EAS.WinService.Kernel" />
<section name="EAS.Objects" type="EAS.Objects.ConfigHandler,EAS.IOCContainer"/>
<section name="EAS.Services" type="EAS.ServiceLocators.ServiceConfigHandler,EAS.ServiceLocator" />
</configSections>
EAS.Configurations:一般配置信息
EAS.WinServices:Win Services插件配置信息
EAS.Objects:IOC容器对象配置信息
EAS.Services:服务发现与定位配置信息
一般配置信息
一般配置信息也可以称为公共配置信息定义,也就除其他专有配置信息之外的信息都可以写在这样,一般配置信息的定义采用Key-Value的方法进行配置:
<EAS.Configurations>
<ConfigurationItem name="DbConnectString" value=""/>
<ConfigurationItem name="WorkstationUser" value="Administrator;james" />
<ConfigurationItem name="LastUser" value="james" />
<ConfigurationItem name="SmartLogin" value="true" />
<ConfigurationItem name="Startup" value="" />
<ConfigurationItem name="SystemStyle" value="DevStyle" />
<ConfigurationItem name="NavigationStyle" value="TreeStyle" />
<ConfigurationItem name="NavigationExpand" value="true" />
<ConfigurationItem name="Desktop" value="Enabled" />
<ConfigurationItem name="MultiInstance" value="Enabled" />
</EAS.Configurations>
AgileEAS.NET平台提供了EAS.Configuration.Config类对一般配置信息进行一股读写:
public static string GetValue(string key)
public static void SetValue(string key, string value)。
容器对象的配置
IOC容器对象配置文件主要配置对象的定义、生存方法、生存周期信息,以及对象在之的存依赖关系,其配置信息如下:
<object name="MasterDbConnection" type="EAS.Data.Access.OleDbConnection"
assembly="EAS.Data" LifestyleType="Pooled:InitialSize = 1 | MaxSize = 10">
<property name="ConnectionString" type="string" value="..." />
</object>
<object name="OrmAccessor" assembly="EAS.Data"
type="EAS.Data.ORM.OrmAccessor" LifestyleType="Thread">
<property name="DbConnection" type="object" value="MasterDbConnection" />
</object>
<object name="CacheAccessor" assembly="EAS.Data"
type="EAS.Data.ORM.CacheAccessor" LifestyleType="Singleton">
</object>
<object name="MasterDataAccessor" assembly="EAS.Data"
type="EAS.Data.Access.OleDbAccessor" LifestyleType="Thread">
<property name="Connection" type="object" value="MasterDbConnection" />
</object>
<object name="MothodInvoker" assembly="EAS.Data"
type="EAS.Business.LocalMothodInvoker.LocalMothodInvoker"/>
上面的配置文件定义了5个对象及其生命周期以及对象之间的关系,比如OrmAccessor对象的属性DbConnection即为MasterDbConnection对象的一个实例。
在IOC配置中,需求定义对象的类型信息:程序集和类型,还需要定义对象的生存类型LifestyleType,目前在AgileEAS.NET平台中提供了如下的生存方式:
/// <summary> /// 枚举LifestyleType 组件的生存方式,即组件以何种生存周期在容器中生存。 /// </summary> public enum LifestyleType { /// <summary> /// Transient,组件在使用时创建、使用后销毁。 /// </summary> Transient = 0x00000000, /// <summary> /// Singleton,组件一旦自在,则在所有的客商端*享。 /// </summary> Singleton = 0x00000001, /// <summary> /// Thread,每一个客户端线程拥有单独的一个实例。 /// </summary> Thread = 0x00000002, /// <summary> /// Pooled,组件池,初始时分配一定数量的组件,客户请求时,分配一个空闲组件,用户使用完后交由池中。 /// </summary> Pooled = 0x00000003 }
服务定位配置信息
服务定位与发现的配置信息主要定义分布式技术服务的发现与定位配置,经如开发员定义了一个基于.NET Remoting技术的服务,客户端如何去动态的激活这个服务,我们来看看服务写位的配置文件:
<EAS.Services>
<Services>
<Service name="EAS.DataAccessService.Service" service-type="DotNetRemoting"
component="tcp://localhost:8000/EAS.DataAccessService"/>
<Service name="EAS.RMIService.Service" service-type="DotNetRemoting"
singleton="true" url="tcp://localhost:8000/EAS.RMIService"/>
<Service name="EAS.Cached.Service" service-type="DotNetRemoting"
Singleton=" true" url="tcp://localhost:8000/EAS.Cached"/>
<Service name="FileTransService"
service-type="WebService" component="FileTransService" />
<Service name="HelloWorldWebService" service-type="WebService"
Singleton="true" url="http://localhost/webservicetest/hello.asmx" />
</Services>
</EAS.Services>
Services配置节中的内部可以根据具体情况进行设置,AgileEAS.NET平台的Service locator支持LocalComponent、WebService、DotNetRemoting三种类型的,LocalComponent的服务组件定义必须定义到IOC容器中的某个组件实现名称如下:
<Service name="HelloWorld" service-type="LocalComponent" component="HelloWorld" />
WebService和DotNetRemoting的组件可以选择定义到IOC容器中的某个组件:
<Service name="FileTransService" service-type="WebService" component="FileTransService" />
也可以直接由SL动态生成服务代理(客户端):
<Service name="EAS.Cached.Service" service-type="DotNetRemoting" Singleton=" true"
url="tcp://localhost:8000/EAS.Cached"/>
<Service name="HelloWorldWebService" service-type="WebService" Singleton="true"
url="http://localhost/webservicetest/hello.asmx" />
Win服务配置文件
AgileEAS.NET提供了基于插件的Win Service开发,提供的配置文件如下:
<EAS.WinServices>
<Config port ="8000"/>
<WinServices>
<WinService name="EAS.Cached" key="EAS.Cached.Service"/>
<WinService name="EAS.RMIService"
key="EAS.Distributed.Remoting.RMIServiceAddIn"/>
<WinService name="EAS.DataAccessService"
key="EAS.Distributed.Remoting.DataAccessServiceAddIn"/>
</WinServices>
</EAS.WinServices>
在port参数中配置服务器运行的TCP端口,WinServices配置节中定义运行的WinService 插件:
<WinService name="EAS.Cached" key="EAS.Cached.Service"/>
这里我们定义了一个缓存服务,配置信息中配置了服务的名称为EAS.Cached他将在客户端调用的时间用到:
<Service name="EAS.Cached.Service" service-type="DotNetRemoting"
Singleton=" true" url="tcp://localhost:8000/EAS.Cached"/>
Key属性的值则指向IOC容器中的组件配置:
<object name="EAS.Cached.Service" assembly="EAS.Cached.ServiceAddIn"
type="EAS.Cached.ServiceAddIn" LifestyleType="Singleton">
<property name="MaxMemory" type="int" value="512" />
</object>
链接
QQ群:116773358