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

Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024
Ortus February Newsletter 2024

Ortus February Newsletter 2024

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
March 06, 2024
Unveiling the Future of CFML Development - 3rd Round of Sessions

Unveiling the Future of CFML Development - 3rd Round of Sessions

Welcome back to our journey into the future of CFML development! As excitement continues to build for Into the Box 2024, we're thrilled to bring you the latest updates on what promises to be a transformative event. Continuing our blog post series, let's delve deeper into the third wave of session releases and discover the key surprises awaiting attendees. Learn More

Maria Jose Herrera
Maria Jose Herrera
March 01, 2024