フォトアルバム

2011年10月

            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

なかのひと

373news.com

google Search

  • Google
    blog.ganymean.org
    WWW

Google Analytics

« Spring | メイン | ColdSpringAOP »

ModelGlue+ColdSpringAOP

Model-Glue + ColdSpringAOP連携アプリケーション ggcc9
じっくりながめてみた。
Model-Glue + tartan連携アプリケーション ggcc8 と比べてみると
ColdSpringAOPのAOP機能ではなく、bean(VO)機能によって
ずいぶんシンプルコードがシンプルになったなーという印象。
 


最初に、ColdSpringAOP用定義ファイルggcc.xmlのなかで、
dsn,各種のDAOやGateway用のmodelをbean定義し、

<beans>
<bean id="dsn" class="ggcc9.beans.dsn">
<property name="dsn" type="string">
<value>corfield</value>
</property>
<property name="user" type="string">
<value>root</value>
</property>
<property name="password" type="string">
<value>visual</value>
</property>
</bean>

<bean id="userDAO" class="ggcc9.model.userDAO">
<property name="dsn">
<ref bean="dsn"/>
</property>
</bean>

<bean id="userGateway" class="ggcc9.model.userGateway">
<property name="dsn">
<ref bean="dsn"/>
</property>
</bean>



</beans>

次に、ColdSpring.modelglue.Autowire.cfcをmodelGlue.xmlのコントローラー
<controller name="csaw" type="coldspring.modelglue.AutoWire"/>
で最初にコールすることによって、簡単な手続きでmodelをbean化、
最後に、各コントローラーにおいて、bean化されたmodelのsetterを定義する。
以下は、コントローラー userManager.cfc の一例。

<cfcomponent extends="ModelGlue.Core.Controller" output="false" hint="I manage user identity">
<!---
the following setters are called by ColdSpring during autowiring:
--->
<cffunction name="setUserDAO" returntype="void" access="public" output="false">
<cfargument name="dao" type="ggcc9.model.userDAO" required="true" />
     <cfset variables.dao = arguments.dao />
</cffunction>

<cffunction name="setUserGateway" returntype="void" access="public" output="false">
<cfargument name="gateway" type="ggcc9.model.userGateway" required="true" />
     <cfset variables.gateway = arguments.gateway />
</cffunction>

<!---
end of autowired setters
--->
<cffunction name="setIdentity" returntype="ModelGlue.Core.Event" access="public" output="false"
hint="I set a user's identity cookie and update their membership record">
    <cfargument name="event" type="ModelGlue.Core.Event" required="yes" />

    <cfset var userID = arguments.event.getValue("userID") />
    <cfset var uuid = createUUID() />
    <cfset var user = createObject("component","ggcc9.beans.userBean").init(userID,uuid) />
    <cfcookie name="GGCCUser" value="#uuid#" expires="never" />
    <cfset session.userID = userID />
    <cfset variables.dao.update(user) />
    <cfreturn arguments.event />
</cffunction>

<cffunction name="getMembers" returntype="ModelGlue.Core.Event" access="public" output="false"
hint="I return a query object containing all of the members' information">
    <cfargument name="event" type="ModelGlue.Core.Event" required="yes" />

    <cfset var users = variables.gateway.getMembers() />
    <cfset arguments.event.setValue("users",users) />
    <cfreturn arguments.event />
</cffunction>


</cfcomponent>

AOP機能の紹介は、次回にします。

トラックバック

このページのトラックバックURL:
http://app.synapse-blog.jp/t/trackback/190195/6025777

ModelGlue+ColdSpringAOPを参照しているブログ:

コメント

コメントを投稿

コメントは記事の投稿者が承認するまで表示されません。

ログイン

  • コントロールパネルへのログイン
    アカウント:

    パスワード:

更新ブログ

最近のトラックバック

Google

ブログ powered by TypePad
Member since 04/2005