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 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
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
Here are a few options for altering the default event execution:
Use event.overrideEvent('myHandler.myAction')
to execute a different event than the default.
Use event.noExecution()
to halt execution of the current event. ONLY works when executed by interceptions before the main event. It will never work in pre/post advices.
You can fine tune these interception methods by leveraging two public properties in the handler:
this.prehandler_only
: A list of actions that preHandler()
will ONLY fire on
this.prehandler_except
: A list of actions that preHandler()
will NOT fire on
There are several simple implicit (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, just for you and without all the complicated setup involved! If you declared them, the framework will execute them.
See the documentation for more details.
Interceptor Method | Description |
| Executes before any requested action (In the same handler CFC) |
| Executes before the |
| Executes after any requested action (In the same handler CFC) |
| Executes after the |
| Executes around any request action (In the same handler CFC) |
| Executes around the |