Standalone Mode Listener
Argument
Type
Execution Mode
Description
interceptData
struct
standalone-coldbox
The data structure passed in the event
1
component{
2
3
function configure(injector,properties){
4
variables.injector = arguments.injector;
5
variables.properties = arguments.properties;
6
7
log = variables.injector.getLogBox().getLogger( this );
8
}
9
10
function beforeInjectorShutdown(interceptData){
11
// Do my stuff here:
12
13
// I can use a log object because ColdBox is cool and injects one for me already.
14
log.info("DUDE, I am going down!!!");
15
}
16
17
function afterInstanceCreation(interceptData){
18
var target = arguments.interceptData.target;
19
var mapping = arguments.interceptData.mapping;
20
21
log.info("The object #mapping.getName()# has just been built, performing my awesome AOP processing on it.");
22
23
// process awesome AOP on this target
24
processAwesomeAOP( target );
25
}
26
}
Copied!
Please note the configure() method in the standalone listener. This is necessary when you are using Wirebox listeners outside of a ColdBox application. The configure() method receives two parameters:
    injector : An instance reference to the calling Injector where this listener will be registered with.
    properties : A structure of properties that passes through from the configuration file.
As you can see from the examples above, each Listener component can listen to multiple events. Now you might be asking yourself, in what order are these listeners executed in? Well, they are executed in the order they are declared in either the ColdBox configuration file as interceptors or the WireBox configuration file as listeners.
Caution Order is EXTREMELY important for interceptors/listeners. So please make sure you order them in the declaration file.
Copy link