Spring.net + FluorineFx 項目搭建 之 一、搭建Spring環境(配置文件)

  一、搭建Spring.net環境

1.1 建工程及類庫

首先我們要建立解決方案,以及所需要的各種類庫。過程中,編寫一個用戶登陸的功能。

 

1.1.1 需要安裝的程序

Microsoft Visual Studio 2008。(開發環境,不用多說);
FX_setup.exe。(與Flex前臺通信的插件);
Enterprise Library。(企業類庫);
ODTwithODAC1110720.(Oracle客戶端);

 

1.1.2 建立各種功能項目

首先新建一個“空白解決方案”。然後依次一下類庫。

添加項目。    

序號

項目

類庫

名稱

用途

添加的引用

新建項目

FuorineFx ServiceLibrary

Li. FuorineFx

Flex通信相關

DataExtensionInterfaceService

新建網站

FluorineFx ASP.NET Web Site

Li.WebService

Flex通信相關

 

新建類庫

Aspect

Li. Aspect

代碼注入

 Data、

新建類庫

Data

Li.Data

實體類

 

新建類庫

DataAccess

Li. DataAccess

數據庫操作

 Data

新建類庫

Extension

Li. Extension

附加類方法

 

新建類庫

Interface

Li. Interface

藉口

 

新建類庫

Service

Li. Service

業務處理

 DataExtensionInterfaceService

 

最後把類庫的默認命名空間改成Li,這樣可以在裏面建包,名字不重複。

 

 

1.2 添加、更改配置文件

 

1.3.2 添加類庫配置文件

文件屬性,生成操作:嵌入資源。不改此項會報錯。


①Service類庫配置文件

<?xml version="1.0" encoding="utf-8"?>
      <objects xmlns="http://www.springframework.net">
</objects>

 


②DataAccess類庫配置文件

<?xml version="1.0" encoding="utf-8"?>
 <objects xmlns="http://www.springframework.net" xmlns:db="http://www.springframework.net/database">

  <object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
    <property name="ConfigSections" value="dbSettings" />
  </object>

  <db:provider id="dbProvider" provider="Oracle.DataAccess.Client" connectionString="DATA SOURCE=${db.source};PERSIST SECURITY INFO=True;USER ID=${db.user};PASSWORD=${db.password};MAX POOL SIZE=100" />

  <object id="adoTemplate" type="Spring.Data.Generic.AdoTemplate, Spring.Data">
    <property name="DbProvider" ref="dbProvider" />
    <property name="DataReaderWrapperType" value="Spring.Data.Support.NullMappingDataReader, Spring.Data" />
  </object>

  <object id="transactionManager" type="Spring.Data.Core.AdoPlatformTransactionManager, Spring.Data">
    <property name="DbProvider" ref="dbProvider" />
  </object>

</objects>

  

1.3.3 更改Web.config配置文件 

①在configSections中添加

sectionGroup name="spring" >

            <section name="parsers" type="Spring.Context.Support.NamespaceParsersSectionHandler, Spring.Core"/>

            <section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web"/>

            <section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core"/>

</sectionGroup>

 


②在configuration中添加

 

<spring>

  <parsers>

    <parser type="Spring.Aop.Config.AopNamespaceParser, Spring.Aop"/>

    <parser type="Spring.Data.Config.DatabaseNamespaceParser, Spring.Data"/>

    <parser type="Spring.Transaction.Config.TxNamespaceParser, Spring.Data"/>

  </parsers>

  <context type="Spring.Context.Support.WebApplicationContext, Spring.Web">

    <resource uri="config://spring/objects"/>

  </context>

  <objects xmlns="http://www.springframework.net" xmlns:aop="http://www.springframework.net/aop" xmlns:db="http://www.springframework.net/database" xmlns:tx="http://www.springframework.net/tx">

    <import resource="assembly://Li.DataAccess/Li.Config/Dao.xml"/>

    <import resource="assembly://Li.Service/Li.Config/Service.xml"/>  </objects>

</spring>

 


③在httpHandlers中添加

<remove path="*.aspx" verb="*"/>

<add path="*.aspx" verb="*" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>

 


④在httpModules中添加

<add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>

 


⑤在system.webServer 下的modules中添加

<remove name="Spring"/>

<add name="Spring" preCondition="integratedMode" type="Spring.Context.Support.WebSupportModule, Spring.Web"/>

 


⑥在system.webServer handlers中添加

 

<remove name="SpringContextMonitor"/>

<remove name="SpringPageHandler"/>

<add name="SpringContextMonitor" verb="*" path="ContextMonitor.ashx" preCondition="integratedMode" type="Spring.Web.Support.ContextMonitor, Spring.Web"/>

<add name="SpringPageHandler" verb="*" path="*.aspx" preCondition="integratedMode" type="Spring.Web.Support.PageHandlerFactory, Spring.Web"/>

 


⑦添加數據庫標籤

<!-- 新加數據庫標籤 -->

Ⅰ、在configSections中添加

<section name="dbSettings" type="System.Configuration.NameValueSectionHandler"/>

 

Ⅱ、在configuration中添加

  <dbSettings>

    <add key="db.source" value="192.1.1.108:1521/uims"/>

    <add key="db.user" value="uims"/>

    <add key="db.password" value="uims"/>

  </dbSettings>

 


⑧聲明代碼注入(此處在建立完相應的類後添加)
 

<object id="interceptorMethod" type="Li.Aspect.InterceptorMethod, Li.Aspect"/>

<object id="interceptorThrow" type="Li.Aspect.InterceptorThrow, Li.Aspect"/>

<object id="interceptorTransaction" type="Li.Aspect.InterceptorTransaction, Li.Aspect"/>

 

<!-- 聲明切入點1 -->

<object id="serviceMethodAttributePointcut" type="Spring.Aop.Support.AttributeMatchMethodPointcut, Spring.Aop">

  <property name="Attribute" value="Li.Attributes.GeneralAttribute, Li.Aspects"/>

</object>

 

<!-- 聲明切入點2 -->

<object id="transactionAttributePointcut" type="Spring.Aop.Support.AttributeMatchMethodPointcut, Spring.Aop">

  <property name="Attribute" value="Spring.Transaction.Interceptor.TransactionAttribute, Spring.Data"/>

</object>

 

<!--關聯切入點1-->

<aop:config>

  <aop:advisor advice-ref="interceptorMethod" pointcut-ref="serviceMethodAttributePointcut"/>

  <aop:advisor advice-ref="interceptorThrow" pointcut-ref="serviceMethodAttributePointcut"/>

</aop:config>

<tx:attribute-driven/>

<!--關聯切入點2-->

<aop:config>

  <aop:advisor advice-ref="interceptorTransaction" pointcut-ref="transactionAttributePointcut"/>

</aop:config>

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章