I've tried to use WireBox AOP in my application, but I faced out with
the following exception: Unable to invoke CFC - Cannot invoke method
udfPointer on an object of type coldfusion.runtime.Struct with named
arguments. Use ordered arguments instead.
I've used the following components and setting:
In the WireBox.cfc
map('MyService')
.to('model.MyService')
.asSingleton().noAutowire();
mapAspect("MyAspect")
.to("model.aspects.MyAspect");
bindAspect(classes=match().mappings('MyService')
,methods=match().any(),aspects="MyAspect");
My aspect implementation is pretty simple:
<cfcomponent output="false"
implements="coldbox.system.aop.MethodInterceptor">
<cffunction name="init" access="public" output="false" >
<cfreturn this >
</cffunction>
<cffunction name="invokeMethod" access="public" output="false"
returntype="Any" >
<cfargument name="invocation" type="any">
<cfscript>
var refLocal = {};
refLocal.results = arguments.invocation.proceed();
if( structKeyExists(refLocal,"results") ){
return refLocal.results;
}
</cfscript>
</cffunction>
My service component is :
<cfcomponent output="false">
<cffunction name="myMethod" access="public" returntype="Any" >
<cfargument name="arg1" type="string" />
<cfargument name="arg2" type="any" />
<cfscript>
return "result";
</cfscript>
</cffunction>
</cfcomponent>
In handler I have the following lines:
<cfcomponent name="MyHandler"
extends="coldbox.system.EventHandler"
output="false">
<cffunction name="myRemoteMethod"
access="remote" returntype="string"
output="false">
<cfargument name="argument1" type="string" required="true">
<cfargument name="argument2" type="string" required="true">
<cfscript>
var service = getPlugin("ioc").getBean("MyService");
return service.myMethod(argument1, argument2);
</cfscript>
</cffunction>
</cfcomponent>
IOC plugin is configured in the following way:
ioc = {
framework = "wirebox",
definitionFile = "#appMapwithDots#config.WireBox"
};
In general I've tried to follow all suggestions from
http://wiki.coldbox.org/wiki/WireBox-AOP.cfm.
Any ideas?
Thanks,
Slava.