Skip to content

What are plugins and what do they do in Mach II?

thofrey edited this page Jul 23, 2013 · 2 revisions

A plugin is a developer-defined CFC that extends the Mach-II framework. The plugin architecture provides robust extensibility for plugin point for cross-cutting event actions. This means each defined plugin point fires on every request and matching point area. Plugins are useful for executing application wide business login such as loading locale resource bundles before views, checking that the request is secured through SSL or loading specific args into the eventobject on each request.

There are nine versatile plugin points plus the configure() method that only runs when the framework loads the plugin into memory. The plugin points are:

Plugin Point Name Called...
preProcess at the beginning of the request before Event processing begins
preEvent before each Event is processed
postEvent after each Event is processed
preView before each View is processed
postView after each View is processed
postProcess at the end of the request after all Event processing has completed
handleException when an exception occurs (before the exception event is announced and handled)

Plugin points added in Mach-II 1.6 and requires use of Application.cfc and the MachII.mach-ii bootstrapper:

Plugin Point Name Called...
onSessionStart when a session starts
onSessionEnd when a session ends

All plugins require that a configure() method be defined – even if the body of the method does no configuration. Plugins that provide interoperability between other frameworks like Reactor or ColdSpring typically only use the configure() method for connectivity to Mach-II and do not implement any of the seven plugin points. Mach-II introspects all plugins when they are loaded into the framework and checks which plugin points are utilized. This is save processing time on each request. Only implement plugin points that you wish to use to save processing cycles.

For more information, see our Introduction to Plugins.

Back to FAQs

Clone this wiki locally