Blog

Brad Wood

September 23, 2013

Spread the word


Share your thoughts

One of the most powerful features of ColdBox are interceptors. They follow a publisher/subscriber model that lets you decouple your application code and latch on to keys points in the ColdBox framework. You can create and announce as many custom interception points as you like, but today I want to review the built-in points that the framework provides you.

All it takes is a simple CFC and a line of config code to register a new interceptor, or "listener" that will be invoked any time an interception point is reached that the CFC is listening for. You can run your own auditing, logging, or re-route the request. Please skim through these and keep them in mind as you build your ColdBox applications.

Application Life Cycle

  • afterConfigurationLoad - This occurs after the framework loads and your application's configuration file is read and loaded. 
  • onException - This occurs whenever an exception occurs in the system. This event also produces data you can use to respond to it.
  • onRequestCapture - This occurs once the FORM/URL variables are merged into the request collection. 
  • onInvalidEvent - This occurs once a missing handler or action is detected in the application.
  • applicationEnd - This occurs whenever the Application ends
  • sessionStart - This occurs when a user's session starts
  • sessionEnd - This occurs when a user's session ends
  • preProcess - This occurs after a request is received and made ready for processing. 
  • preEvent - This occurs before ANY event execution, whether it is the current event or called via the run event method.
  • postEvent - This occurs after ANY event execution, whether it is the current event or called via the run event method.
  • postProcess - This occurs after rendering, usually the last step in an execution. 

Object Creation

  • afterHandlerCreation - This occurs whenever a handler is created
  • afterInstanceCreation - This occurs whenever a wirebox object is created
  • afterPluginCreation - This occurs whenever a plugin object is created

Layout/View

  • preLayout - This occurs before any rendering or layout is executed
  • preRender - This occurs after the layout+view is rendered and this event receives the produced content
  • postRender - This occurs after the content has been rendered to the buffer output
  • preViewRender - This occurs before any view is rendered
  • postViewRender - This occurs after any view is rendered and passed the produced content
  • preLayoutRender - This occurs before any layout is rendered
  • postLayoutRender - This occurs after any layout is rendered and passed the produced content

Module

  • preModuleLoad - This occurs before any module is loaded in the system
  • postModuleLoad - This occurs after a module has been loaded in the system
  • preModuleUnload - This occurs before a module is unloaded from the system
  • postModuleUnload - This occurs after a module has been unloaded from the system

ORM

  • ORMPostNew - This method is called by the ColdBox Base ORM Service Layers after a new entity has been created via its new() method.
  • ORMPreLoad - This method is called before the load operation or before the data is loaded from the database
  • ORMPostLoad - This method is called after the load operation is complete
  • ORMPostDelete - This method is called after the delete operation is complete
  • ORMPreDelete - This method is called before the object is deleted
  • ORMPreUpdate - This method is called after the update operation is complete
  • ORMPostUpdate - This method is called just before the object is updated
  • ORMPreInsert - This method is called just before the object is inserted
  • ORMPostInsert - This method is called after the insert operation is complete

Many of these interception points come with additional data about the event. Please check the docs to see it all.

More info here: http://wiki.coldbox.org/wiki/Interceptors.cfm

P.S. Don't forget that you can also make any interceptor asynchronous by simply adding the "async" annotation to the your listening interceptor's method.

Add Your Comment

Recent Entries

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023