[coldbox-3.5.3] around handler for all handlers

what is the best way for this? want an aroundHandler for all handlers in a module.

currently have a preEvent in a module interceptor do a check but it has to see if getCurrentModule() is equal to the module name. i dont like hard coding names.

on topic, is there an intercept point i can use/create that will fire only if the event happens as part of the module?

Inheritance, probably. If you look at the Contentbox modules, all of the handlers extend the “BaseHandler”. You can call the THIS scope from the current handler. You can figure the preHandler() function for the base handler and then call super.preHandler() from the child preHander() method.

Jon

I would check into using an AOP advice. You can get pretty funky with the matcher DSL:

http://wiki.coldbox.org/wiki/WireBox-AOP.cfm#ClassMatcher_Annotation_DSL

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

i tried this way and was having problems with the notation because my handlers are nested in sub directories.

i guess i could do a full notation to the baseHandler.

You can check out the event pattern annotation which helps control when an interceptor runs.

http://wiki.coldbox.org/wiki/Interceptors.cfm#eventpattern_annotation

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

thanks brad.

this is what im looking for.

eventpattern annotation

void function preProcess(event,struct interceptData) eventPattern="^admin\."{}

although, not really cause the name is still hardcoded.

You’ll probably have to, unless you want inject a named instance or use a mixin. There is a #moduleMapping# variable that’s automatically created when the module is loaded by the framework, but it won’t work for inheritance.

Jon

thanks jon.

going to use full notation. if i ever have to refactor, having the name hard coded in the notation is easier to work with than in other syntax.

Are you planning on renaming your module on a regular basis?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

not if i have to!

but my OCD makes me plan for the worst.