On Thursday 05 Jul 2007, Tom Chiverton wrote:
> Yes, you could, but you've now modified the core Reactor framework :-)
> With AOP you can leave that alone, and if some people want their code to
> return real queries, they just don't apply the Advice.
Here's a concrete example. In a Manager CFC I have
<cffunction name="getAll" output="false">
<cfargument name="username" required="true">
<cfset var ret=structNew()>
<cfset
ret.data=variables.reactor.createGateway("plans").getByFields(creatorName=arguments.username,sortByFieldList="name")>
<cfset ret.result=true>
<cfreturn ret />
</cffunction>
<cffunction name="get" output="false">
<cfargument name="username" required="true">
<cfargument name="id" required="true" type="numeric">
<cfset var ret=structNew()>
<cfset
ret.data=variables.reactor.createRecord("plans").load(creatorName=arguments.username,id=arguments.id)>
<cfset ret.result=true>
<cfreturn ret />
</cffunction>
this CFC is exposed through ColdSpring's RemoteProxyBean, and the methods will
of course return a Record and a Query respectively in result.DATA, but we'd
rather it returned either a TO or an array of TO.
So we just configure some BeforeAdvice for the RemoteProxyBean
(via 'flashUtilityService'):
<bean id="reactorUtilityServicePlans"
class="com.halliwells.CFCs.aop.ReactorUtilityService">
<property name="queryObject">
<value>com.halliwells.CFCs.t3ster.data.To.planTo</value>
</property>
<property name="reactor">
<ref bean="reactor"/>
</property>
</bean>
<bean id="remotePlanService"
class="coldspring.aop.framework.RemoteFactoryBean">
<property name="target">
<ref bean="planManager" />
</property>
<property name="serviceName">
<value>RemotePlanService</value>
</property>
<property name="relativePath">
<value>/com/halliwells/CFCs/t3ster/service/</value>
</property>
<property name="beanFactoryName">
<value>beanFactory</value>
</property>
<property name="flashUtilityService">
<ref bean="reactorUtilityServicePlan" />
</property>
</bean>
The Advice itself is fairly easy, but I've got to see about getting it
released from work, or redo it as a clean-room implementation at home, or
something.
--
Tom Chiverton
Helping to enormously create open-source products
on: http://thefalken.livejournal.com
****************************************************
This email is sent for and on behalf of Halliwells LLP.
Halliwells LLP is a limited liability partnership registered in England and
Wales under registered number OC307980 whose registered office address is at St
James's Court Brown Street Manchester M2 2JF. A list of members is available
for inspection at the registered office. Any reference to a partner in relation
to Halliwells LLP means a member of Halliwells LLP. Regulated by the Law
Society.
CONFIDENTIALITY
This email is intended only for the use of the addressee named above and may be
confidential or legally privileged. If you are not the addressee you must not
read it and must not use any information contained in nor copy it nor inform
any person other than Halliwells LLP or the addressee of its existence or
contents. If you have received this email in error please delete it and notify
Halliwells LLP IT Department on 0870 365 8008.
For more information about Halliwells LLP visit www.halliwells.com.