Around advices are the most powerful of all as you completely hijack the requested action with your own action that looks, smells and feels exactly as the requested action. This is usually referred to as a proxy design pattern.
This will allow you to run both before and after advices but also surround the method call with whatever logic you want like transactions
, try/catch
blocks, locks
or even decide to NOT execute the action at all.
You can do it globally by using the aroundHandler()
method or targeted to a specific action around{actionName}()
.
Examples
The arguments received by these interceptors are:
event
: The request context reference
targetAction
: The function pointer to the action that got the around interception. It will be your job to execute it (Look at samples)
eventArguments
: The struct of extra arguments sent to an action if any
rc
: The RC reference
prc
: The PRC Reference
You can fine tune these interception methods by leveraging two public properties in the handler:
this.aroundhandler_only
: A list of actions that the aroundHandler()
action will fire ONLY!
this.aroundhandler_except
: A list of actions that the aroundHandler()
action will NOT fire on
With this interceptor you can intercept local event actions and execute things before the requested action executes. You can do it globally by using the preHandler()
method or targeted to a specific action pre{actionName}()
.
The arguments received by these interceptors are:
event
: The request context reference
action
: The action name that was intercepted
eventArguments
: The struct of extra arguments sent to an action if executed via runEvent()
rc
: The RC reference
prc
: The PRC Reference
You can fine tune these interception methods by leveraging two public properties in the handler:
this.prehandler_only
: A list of actions that the preHandler()
action will fire ONLY!
this.prehandler_except
: A list of actions that the preHandler()
action will NOT fire on
With this interceptor you can intercept local event actions and execute things after the requested action executes. You can do it globally by using the postHandler()
method or targeted to a specific action post{actionName}()
.
The arguments received by these interceptors are:
event
: The request context reference
action
: The action name that was intercepted
eventArguments
: The struct of extra arguments sent to an action if executed via runEvent()
rc
: The RC reference
prc
: The PRC Reference
You can fine tune these interception methods by leveraging two public properties in the handler:
this.posthandler_only
: A list of actions that the postHandler()
action will fire ONLY!
this.posthandler_except
: A list of actions that the postHandler()
action will NOT fire on
There are several simple implicit AOP (Aspect Oriented Programming) interceptor methods, usually referred to as advices, that can be declared in your event handler that the framework will use in order to execute them before/after and around an event as its fired from the current handler.
This is great for intercepting calls, pre/post processing, localized security, logging, RESTful conventions, and much more. Yes, you got that right, Aspect Oriented Programming just for you and without all the complicated setup involved! If you declared them, the framework will execute them.
Interceptor Method
Description
preHandler()
Executes before any requested action (In the same handler CFC)
pre{action}()
Executes before the {action}
requested ONLY
postHandler()
Executes after any requested action (In the same handler CFC)
post{action}()
Executes after the {action}
requested ONLY
aroundHandler()
Executes around any request action (In the same handler CFC)
around{action}()
Executes around the {action}
requested ONLY