That's a fantastic idea. Since I'm using ColdSpring as well as
Transfer (and all my Transfer proxies are defined in ColdSpring), I
wrote the following little filter to put a ColdSpring bean (grabbed
via factory method discussed in my previous email) into the event
object. Not sure how useful it is to anyone but me, but I figured I'd
throw it out there anyway:
<cfcomponent displayname="CreateColdSpringEventBeanFilter"
extends="MachII.framework.EventFilter"
output="false"
hint="Uses a factory/facade method to put an empty bean into the
event">
<!--- INITIALIZATION / CONFIGURATION --->
<cffunction name="configure" access="public" returntype="void"
output="false"
hint="Configures the filter.">
<!--- Put custom configuration for this filter here. --->
</cffunction>
<!--- PUBLIC FUNCTIONS --->
<cffunction name="filterEvent" access="public" returntype="boolean"
output="false"
hint="I am invoked by the Mach II framework.">
<cfargument name="event" type="MachII.framework.Event"
required="true"
hint="I am the current event object created by the Mach II
framework." />
<cfargument name="eventContext"
type="MachII.framework.EventContext" required="true"
hint="I am the current event context object created by the Mach II
framework." />
<cfargument name="paramArgs" type="struct" required="false"
default="#structNew()#"
hint="I am the structure containing the parameters specified in the
filter invocation in mach-ii.xml." />
<cfset var bean = paramArgs.bean />
<cfset var beanName = paramArgs.name />
<cfset var propManager = eventContext.getAppManager
().getPropertyManager() />
<cfset var csProp = propManager.getProperty("coldspringProperty") /
>
<cfset var eventBean = '' />
<cfset var beanFactory = '' />
<cfif IsStruct(csProp)>
<cfset beanFactory = getProperty(csProp.getParameter
("beanFactoryPropertyName")) />
<cfif IsStruct(beanFactory) AND StructKeyExists(beanFactory,
"getBean" )>
<cfset eventBean = beanFactory.getBean(bean) />
</cfif>
</cfif>
<cfset event.setArg(beanName, eventBean) />
<cfreturn true/>
</cffunction>
</cfcomponent>
Here's an example from mach-ii.xml:
<event-handler event="login.action" access="public">
<event-mapping event="pass" mapping="main.redirect"/>
<event-mapping event="fail" mapping="home.redirect"/>
<filter name="createColdSpringEventBeanFilter">
<parameter name="bean" value="blankUserObject"/>
<parameter name="name" value="user"/>
</filter>
<event-bean name="user" type="@cf.app.root@.model.UserModel"
reinit="false"
fields="email,password"/>
<notify listener="userListener" method="login"/>
</event-handler>
If anyone finds this helpful please let me know. I don't want to fill
up the group with useless garbage!
Thanks,
-Mike Rogers