[Tip of the Week] Superclass is Optional For Handlers, Plugins, and Interceptors

In ColdBox, Event Handlers, Interceptors, and Plugins are represented as CFCs. You are probably used to their signatures looking like this:

myhandler.cfc
component extends=“coldbox.system.EventHandler”{}

myInterceptor.cfc
component extends=“coldbox.system.Interceptor”{}

myPlugin.cfc
component extends=“coldbox.system.Plugin”{}

ColdBox is very flexible though and tries to help remove as much boilerplate code for you as possible. You can actually omit the “extends” attribute all-together from Handlers, Interceptors, and Plugins and Coldbox will automatically add Virtual Inheritance to the components at run time. That means all the methods you’re used to having available to you will still be there, but your code is light, clean, and insulated from internal class changes in the framework.

myhandler.cfc
component {}

myInterceptor.cfc
component {}

myPlugin.cfc
component {}

More info;
http://wiki.coldbox.org/wiki/Plugins.cfm#Component_Declaration
http://wiki.coldbox.org/wiki/Interceptors.cfm#How_do_they_work.3F
http://wiki.coldbox.org/wiki/EventHandlers.cfm#Constructors

P.S. You can tap into the power of Virtual Inheritance with WireBox for your own models as well. Check out this Wiki link: http://wiki.coldbox.org/wiki/WireBox.cfm#Virtual_Inheritance

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com