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

Partner with BoxLang and Ortus at Into the Box 2025: Empowering the Future of Modern Software Development!

Partner with BoxLang and Ortus at Into the Box 2025: Empowering the Future of Modern Software Development!

At Ortus Solutions, we’ve always been at the forefront of innovation in the ColdFusion ecosystem. From pioneering modern ColdFusion practices to developing cutting-edge tools and frameworks, we’ve been passionate to help and sup[port the community into shaping the future of web development.That’s why we decided to build BoxLang, our new JVM programming language that not only builds on the strengths of ColdFusion but takes modern software development to the next level.

Maria Jose Herrera
Maria Jose Herrera
December 23, 2024
Why BoxLang When You Have Kotlin, Groovy, Scala, and more…

Why BoxLang When You Have Kotlin, Groovy, Scala, and more…

As we approach a stable release of BoxLang and our continued marketing reaches more folks, many have asked about its purpose. Why create a new language when the JVM ecosystem already includes established languages like Kotlin, Groovy, and Scala, to name a few.

Luis Majano
Luis Majano
December 18, 2024