[coldbox-3.6.0] Do Aspects mapped to handlers trigger on Init()

This question came up as part of a recent problem I had and I though I had better ask about this. If I bind an aspect using a mapper to any cfc in any “handlers” sub-directory, does it trigger on the creation of the handler by the framework. I assume there is an injected init() going on behind the scenes (if there is not then the answer is obviously no) so there was a concern that the creation process might be causing a premature action being taken by the aspect that I would not want. Of course the biggest reason for this (think “requireauthentication”) is that it’s easier to apply some meta attribute to the whole component as opposed to the individual methods it contains.

Mike

Yes Mike,

All handlers, plugins, interceptors are auto-inited. If they do not have an init() method, we inject and mix one in.

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

Thanks for confirming that for me Luis.

So that leaves the question…perhaps in the order things are done (though I cannot see that clearly through the trees), will an aspect trigger on init if mapped to run on any method in a handler cfc? If it does, I don’t see how I can prevent it other than by matching to other methods in the cfc because there does not seem to be a not matcher in the binding of an aspect.

Mike

signature0.jpg

Well, the methods matcher can match against the methods so why don’t you do a regex for anything that is NOT init. You can use negative lookaheads in regex

methods=match().regex( “((?!init).)*” )

That should match any method that is not INIT

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

signature0.jpg

heh…always out of the box…what a great idea.

I am going to assume that by proxy, the answer to my question is yes, the init is just as valid a trigger for an aspect mapped to components as any other method signature in the class.

Mike

signature0.jpg

signature0.jpg

Yes definitely. Because you can wrap constructors too and get funky

signature0.jpg

Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

signature0.jpg

signature0.jpg