> For the complete documentation index, see [llms.txt](https://wirebox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wirebox.ortusbooks.com/usage/wirebox-event-model/wirebox-listeners/standalone-mode-listener.md).

# Standalone Mode Listener

![](https://content.gitbook.com/content/MtgLfPeIR8KWTwoO8bDr/blobs/tui5RKuzxjB4DmCUO7TW/standalonelistener.jpg)

In standalone mode, the listener is a simple class with a `configure()` method and any methods that match the name of the events. Each of these methods receive the following arguments:

| Argument | Type   | Description                            |
| -------- | ------ | -------------------------------------- |
| `data`   | struct | The data structure passed in the event |

### Example:

{% tabs %}
{% tab title="BoxLang" %}

```js
class{

    function configure( injector,properties ){
        variables.injector = arguments.injector;
        variables.properties = arguments.properties;

        log = variables.injector.getLogBox().getLogger( this );
    }

    function beforeInjectorShutdown( data ){
        // Do my stuff here:

        // I can use a log object because ColdBox is cool and injects one for me already.
        log.info("DUDE, I am going down!!!");
    }

    function afterInstanceCreation( data ){
        var target = arguments.data.target;
        var mapping = arguments.data.mapping;

        log.info("The object #mapping.getName()# has just been built, performing my awesome AOP processing on it.");

        // process awesome AOP on this target
        processAwesomeAOP( target );
    }
}
```

{% endtab %}

{% tab title="CFML" %}

```cfscript
component{

    function configure( injector,properties ){
        variables.injector = arguments.injector;
        variables.properties = arguments.properties;

        log = variables.injector.getLogBox().getLogger( this );
    }

    function beforeInjectorShutdown( data ){
        // Do my stuff here:

        // I can use a log object because ColdBox is cool and injects one for me already.
        log.info("DUDE, I am going down!!!");
    }

    function afterInstanceCreation( data ){
        var target = arguments.data.target;
        var mapping = arguments.data.mapping;

        log.info("The object #mapping.getName()# has just been built, performing my awesome AOP processing on it.");

        // process awesome AOP on this target
        processAwesomeAOP( target );
    }
}
```

{% endtab %}
{% endtabs %}

Please note the `configure()` method in the standalone listener. This is necessary when using Wirebox listeners outside of a ColdBox application. The `configure()` method receives two parameters:

* `injector` : An instance reference to the calling Injector with which this listener will be registered.
* `properties` : A structure of properties that passes through from the configuration file.

As you can see from the examples above, each class can listen to multiple events.

### Order of Execution

Now, you might ask yourself, in what order are these listeners executed? They are executed in the order they are declared in either the ColdBox configuration file as interceptors or the WireBox configuration file as listeners.

{% hint style="danger" %}
**Caution** Order is EXTREMELY important for interceptors/listeners. So please make sure you order them in the declaration file.
{% endhint %}

### Declaration

You will declare the listeners in the Binder using the `listeners` struct or method approach

* [Data Approach](/configuration/configuring-wirebox/data-configuration-settings.md#listeners)
* [Programmatic Approach](/configuration/configuring-wirebox/programmatic-configuration.md)

```cfscript
function configure(){
    // Declarative Approach
    wirebox = {
    
        // Register all event listeners here, they are created in the specified order
        listeners = [
            { 
                class="models.MyAuditLog", 
                name="MyAuditLog", 
                properties={ logLevel : "MAX" } 
            }
        ]   
    }
    
    // Programmatic approach
    listener( 
        class      : "models.MyAuditLog", 
        name       : "MyAuditLog", 
        properties : { logLevel : "MAX" }
    );

}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wirebox.ortusbooks.com/usage/wirebox-event-model/wirebox-listeners/standalone-mode-listener.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
