Need to know the best practice for accessing ColdSpring services
within the Framework-One controller. This currently works but does
not seem quite right. Is there a better way to obtain access to your
ColdSpring service layer within the controller?
Application.cfc
<cfset bf =
createObject('component','coldspring.beans.DefaultXmlBeanFactory').init()/
>
<cfset bf.loadBeans(expandPath('/expertportal/questions/config/
ColdSpring.xml'))/>
<cfset setBeanFactory(bf)/>
ColdSpring.xml
<bean id="Question" class="org.app.model.questions.Question"
singleton="false"/>
<bean id="QuestionDAO" parent="parentDAO"
class="org.app.db.questions.QuestionDAO" singleton="true"/>
<bean id="QuestionGateway" parent="parentGateway"
class="org.app.db.questions.QuestionGateway" singleton="true"/>
<bean id="QuestionService" class="org.app.service.questions.Question"
singleton="true">
<property name="DAO">
<ref bean="QuestionDAO"/>
</property>
<property name="Gateway">
<ref bean="QuestionGateway"/>
</property>
</bean>
question.cfc [controller]
<cffunction name="init" access="public" returntype="void"
output="false">
<cfargument name="fw" type="any" required="true"/>
<cfset variables.fw = arguments.fw/>
</cffunction>
<cffunction name="disciplines" access="public" returntype="void"
output="false">
<cfargument name="rc" type="struct" required="true"/>
<cfset rc.test =
variables.fw.getBeanFactory().getBean('QuestionService').getQuestionDisciplines()/
>
</cffunction>
As you can see I am passing the framework into the init method and
then accessing my service using getBeanFactory().getBean() and setting
the results, a query, to the request context.
Do you fellows see a better way?
--
You received this message because you are subscribed to the Google Groups "framework-one" group.
To post to this group, send email to
framew...@googlegroups.com.
To unsubscribe from this group, send email to
framework-on...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/framework-one?hl=en.