zoukankan      html  css  js  c++  java
  • 在Web应用程序中使用Castle ActiveRecord

    摘要:

      本文主要介绍在web应用程序中使用Castle ActiveRecord与在桌面应用程序或.Remoting程序中使用AR的一些区别,主要针对配置的不同。

      如果用户在Web Application使用AR,则在配置文件(Web.config或configfile.xml)中必须添加 isWeb="true" 属性,这样迫使ActiveRecord使用另一种策略来容纳实例对象,这么做非常必要,因为在web程序中不同的线程可以为同一web请求进行服务,节 省了内存的开销。

      具体的配置文件如下:

    <configuration>

        
    <activerecord 
            
    isWeb="true|false" 
            isDebug
    ="true|false" 
            threadinfotype
    ="custom thread info implementation"
            sessionfactoryholdertype
    ="custom session holder implementation"
            namingstrategytype
    ="custom namingstrategy implementation">

            
    <config>
                
    <add key="hibernate.connection.driver_class" value="NHibernate Driver" />
                
    <add key="hibernate.dialect"                 value="NHibernate Dialect" />
                
    <add key="hibernate.connection.provider"     value="NHibernate Connection Provider" />
                
    <add key="hibernate.connection.connection_string" value="connection string" />
            
    </config>

            
    <config type="Full Type name to Abstract Class that defines boundaries for different database">
                
    <add key="hibernate.connection.driver_class" value="NHibernate Driver" />
                
    <add key="hibernate.dialect"                 value="NHibernate Dialect" />
                
    <add key="hibernate.connection.provider"     value="NHibernate Connection Provider" />
                
    <add key="hibernate.connection.connection_string" value="connection string" />
            
    </config>

        
    </activerecord>

    </configuration>

    属性
    必需描述
      isWeb

    如果AR运行在ASP.NET应用程序中,该属性为true

      isDebug

    如果为true,强制AR写映射文件,用来帮助调试,该文件写到bin目录下

      threadinfotype

    Full qualified type name to a custom implementation of IThreadScopeInfo

    用户自定义的实现IThreadScopeInfo完全限定类型名称

     sessionfactoryholdertype

    用户自定义的实现ISessionFactoryHolder完全限定类型名称

      namingstrategytype

     用户自定义的实现INamingStrategy完全限定类型名称,这是一个NHibernate 接口

      虽然isWeb字段并不是必需,但是对程序的性能却有一定的影响。所以个人认为在asp.net web application中使用很有必要。

    文章就写到这里了,第一次写文,还请多多点评。不吝赐教!

    henry

  • 相关阅读:
    SD_WebImage-03-多线程+下载任务放入非主线程执行
    NSOperationQueue_管理NSOperation-02-多线程
    CALayer小结-基本使用00-UI进阶
    XMPP-UI进阶-01
    XMPP总结-UI进阶-00
    UI控件总结-UI初级
    转场动画-01-day4
    暂停-开始动画-核心动画-08-day4
    核心动画-04-CALayer隐式动画
    Android开发技术周报 Issue#71
  • 原文地址:https://www.cnblogs.com/repository/p/1353056.html
Copyright © 2011-2022 走看看