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

BoxLang 1.0.0 Beta 23 Launched

BoxLang 1.0.0 Beta 23 Launched

The latest release of BoxLang, Beta 23, marks a significant step forward in our journey to create the ultimate dynamic language for the JVM. Packed with powerful new features, important bug fixes, and thoughtful optimizations, this update is designed to make your development experience smoother, faster, and more reliable, especially after now starting to take 100s of comments and bug reports from our community.

Luis Majano
Luis Majano
November 23, 2024
TestBox Latest Updates and News!

TestBox Latest Updates and News!

We’re thrilled to have launched the new TestBox website and TestBox 6.0! If you haven’t had a chance to explore yet, visit TestBox to discover updated documentation, powerful resources, and features that make testing more efficient than ever.

Maria Jose Herrera
Maria Jose Herrera
November 21, 2024
Is Your ColdFusion Application Ready for the Future?

Is Your ColdFusion Application Ready for the Future?

In a rapidly evolving digital world, maintaining performance, security, and scalability for ColdFusion applications is more challenging than ever. Whether you're using Lucee or Adobe ColdFusion, legacy systems can become a bottleneck for growth, innovation, and user satisfaction. The need to future-proof your ColdFusion applications has never been more critical.

But where do you start?


The Hidden Costs of an Outdated ColdFusion Application

As you...

Cristobal Escobar
Cristobal Escobar
November 21, 2024