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

Ortus June 2024 Newsletter!

Ortus June 2024 Newsletter!

Welcome to the latest edition of the Ortus Newsletter! This month, we're excited to bring you highlights from our sessions at CFCamp and Open South Code, as well as a sneak peek into our upcoming events. Discover the latest developments in BoxLang, our dynamic new JVM language, and catch up on all the insightful presentations by our expert team. Let's dive in!

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang June 2024 Newsletter!

BoxLang June 2024 Newsletter!

We're thrilled to bring you the latest updates and exciting developments from the world of BoxLang. This month, we're diving into the newest beta release, introducing a new podcast series, showcasing innovative integrations, and sharing insights from recent events. Whether you're a seasoned developer or just getting started, there's something here for everyone to explore and enjoy.

Maria Jose Herrera
Maria Jose Herrera
June 28, 2024
BoxLang 1.0.0 Beta 3 Launched

BoxLang 1.0.0 Beta 3 Launched

We are thrilled to announce the release of BoxLang 1.0.0-Beta 3! This latest beta version is packed with exciting new features and essential bug fixes, including robust encryption functionality, enhanced Java interoperability, and more efficient event handling. Key highlights include the introduction of query caching capabilities, seamless coercion of Java Single Abstract Method (SAM) interfaces from BoxLang functions, and support for virtual thread executors. So, let’s dive into the details of what’s new in BoxLang 1.0.0-Beta 3 and how you can start leveraging these updates today!

Luis Majano
Luis Majano
June 28, 2024