Documentation home page

MachII.framework
Component Plugin

framework.BaseComponent
  |
  +--framework.Plugin

Base Plugin component.

Method Summary
public Plugin init(AppManager appManager, [struct parameters])
          Used by the framework for initialization. Do not override.
public void abortEvent([string message=""])
          Call this function to abort processing of the current event. When called, an AbortEventException exception is thrown, caught, and handled by the framework.
public void handleException(EventContext eventContext, Exception exception)
          Plugin point called when an exception occurs (before exception event is handled). Override to provide custom functionality.
public void postEvent(EventContext eventContext)
          Plugin point called after each Event is processed. Override to provide custom functionality.
public void postProcess(EventContext eventContext)
          Plugin point called after Event processing finishes. Override to provide custom functionality.
public void postView(EventContext eventContext)
          Plugin point called after each View is processed. Override to provide custom functionality.
public void preEvent(EventContext eventContext)
          Plugin point called before each Event is processed. Override to provide custom functionality.
public void preProcess(EventContext eventContext)
          Plugin point called before Event processing begins. Override to provide custom functionality.
public void preView(EventContext eventContext)
          Plugin point called before each View is processed. Override to provide custom functionality.

Methods inherited from framework.BaseComponent
setParameters, hasParameter, buildUrlToModule, isParameterDefined, buildUrl, announceEventInModule, setAppManager, getParameter, getProperty, getParameters, setProperty, getPropertyManager, bindValue, configure, getAppManager, setParameter, announceEvent
 

Method Detail

abortEvent

public void abortEvent([string message=""])
Call this function to abort processing of the current event. When called, an AbortEventException exception is thrown, caught, and handled by the framework.

Parameters:
[string message=""]

Code:
	<cffunction name="abortEvent" access="public" returntype="void" output="false"
		hint="Call this function to abort processing of the current event. When called, an AbortEventException exception is thrown, caught, and handled by the framework.">
		<cfargument name="message" type="string" required="false" default="" />
		<cfthrow type="AbortEventException" message="#arguments.message#" />
	</cffunction>

handleException

public void handleException(EventContext eventContext, Exception exception)
Plugin point called when an exception occurs (before exception event is handled). Override to provide custom functionality.

Parameters:
EventContext eventContext - The EventContext under which the exception was thrown/caught.
Exception exception - The Exception that was thrown/caught by the framework.

Code:
	<cffunction name="handleException" access="public" returntype="void" output="true"
		hint="Plugin point called when an exception occurs (before exception event is handled). Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext under which the exception was thrown/caught." />
		<cfargument name="exception" type="MachII.util.Exception" required="true"
			hint="The Exception that was thrown/caught by the framework." />
		
	</cffunction>

init

public Plugin init(AppManager appManager, [struct parameters])
Used by the framework for initialization. Do not override.

Parameters:
AppManager appManager
[struct parameters]

Code:
	<cffunction name="init" access="public" returntype="Plugin" output="false"
		hint="Used by the framework for initialization. Do not override.">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfargument name="parameters" type="struct" required="false" />
		
		<cfset super.init(arguments.appManager, arguments.parameters) />
		
		<cfreturn this />
	</cffunction>

postEvent

public void postEvent(EventContext eventContext)
Plugin point called after each Event is processed. Override to provide custom functionality.

Parameters:
EventContext eventContext - The EventContext the Event occurred in. Call arguments.eventContext.getCurrentEvent() to access the Event.

Code:
	<cffunction name="postEvent" access="public" returntype="void" output="true"
		hint="Plugin point called after each Event is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext the Event occurred in.  Call arguments.eventContext.getCurrentEvent() to access the Event." />
		
	</cffunction>

postProcess

public void postProcess(EventContext eventContext)
Plugin point called after Event processing finishes. Override to provide custom functionality.

Parameters:
EventContext eventContext - The EventContext of the processing.

Code:
	<cffunction name="postProcess" access="public" returntype="void" output="true"
		hint="Plugin point called after Event processing finishes. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		
	</cffunction>

postView

public void postView(EventContext eventContext)
Plugin point called after each View is processed. Override to provide custom functionality.

Parameters:
EventContext eventContext - The EventContext of the processing.

Code:
	<cffunction name="postView" access="public" returntype="void" output="true"
		hint="Plugin point called after each View is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		
	</cffunction>

preEvent

public void preEvent(EventContext eventContext)
Plugin point called before each Event is processed. Override to provide custom functionality.

Parameters:
EventContext eventContext - The EventContext the Event occurred in. Call arguments.eventContext.getCurrentEvent() to access the Event.

Code:
	<cffunction name="preEvent" access="public" returntype="void" output="true"
		hint="Plugin point called before each Event is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext the Event occurred in.  Call arguments.eventContext.getCurrentEvent() to access the Event." />
		
	</cffunction>

preProcess

public void preProcess(EventContext eventContext)
Plugin point called before Event processing begins. Override to provide custom functionality.

Parameters:
EventContext eventContext - The EventContext of the processing.

Code:
	<cffunction name="preProcess" access="public" returntype="void" output="true"
		hint="Plugin point called before Event processing begins. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		
	</cffunction>

preView

public void preView(EventContext eventContext)
Plugin point called before each View is processed. Override to provide custom functionality.

Parameters:
EventContext eventContext - The EventContext of the processing.

Code:
	<cffunction name="preView" access="public" returntype="void" output="true"
		hint="Plugin point called before each View is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		
	</cffunction>

Full Component Code:
<!---
License:
Copyright 2007 GreatBizTools, LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Copyright: GreatBizTools, LLC
Author: Ben Edwards (ben@ben-edwards.com)
$Id: Plugin.cfc 482 2007-09-05 02:07:07Z pfarrell $

Created version: 1.0.0
Updated version: 1.1.0

Notes:
All user-defined plugins extend this base plugin component.
--->
<cfcomponent 
	displayname="Plugin" 
	extends="MachII.framework.BaseComponent"
	output="false"
	hint="Base Plugin component.">

	<!---
	PROPERTIES
	--->

	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" returntype="Plugin" output="false"
		hint="Used by the framework for initialization. Do not override.">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfargument name="parameters" type="struct" required="false" />
		
		<cfset super.init(arguments.appManager, arguments.parameters) />
		
		<cfreturn this />
	</cffunction>

	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="abortEvent" access="public" returntype="void" output="false"
		hint="Call this function to abort processing of the current event. When called, an AbortEventException exception is thrown, caught, and handled by the framework.">
		<cfargument name="message" type="string" required="false" default="" />
		<cfthrow type="AbortEventException" message="#arguments.message#" />
	</cffunction>

	<!---
	PLUGIN POINT FUNCTIONS called from EventContext
	--->
	<cffunction name="preProcess" access="public" returntype="void" output="true"
		hint="Plugin point called before Event processing begins. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		<!--- Override to provide custom functionality. --->
	</cffunction>
	
	<cffunction name="preEvent" access="public" returntype="void" output="true"
		hint="Plugin point called before each Event is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext the Event occurred in.  Call arguments.eventContext.getCurrentEvent() to access the Event." />
		<!--- Override to provide custom functionality. --->
	</cffunction>
	
	<cffunction name="postEvent" access="public" returntype="void" output="true"
		hint="Plugin point called after each Event is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext the Event occurred in.  Call arguments.eventContext.getCurrentEvent() to access the Event." />
		<!--- Override to provide custom functionality. --->
	</cffunction>
	
	<cffunction name="preView" access="public" returntype="void" output="true"
		hint="Plugin point called before each View is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		<!--- Override to provide custom functionality. --->
	</cffunction>
	
	<cffunction name="postView" access="public" returntype="void" output="true"
		hint="Plugin point called after each View is processed. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		<!--- Override to provide custom functionality. --->
	</cffunction>
	
	<cffunction name="postProcess" access="public" returntype="void" output="true"
		hint="Plugin point called after Event processing finishes. Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext of the processing." />
		<!--- Override to provide custom functionality. --->
	</cffunction>
	
	<cffunction name="handleException" access="public" returntype="void" output="true"
		hint="Plugin point called when an exception occurs (before exception event is handled). Override to provide custom functionality.">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true"
			hint="The EventContext under which the exception was thrown/caught." />
		<cfargument name="exception" type="MachII.util.Exception" required="true"
			hint="The Exception that was thrown/caught by the framework." />
		<!--- Override to provide custom functionality. --->
	</cffunction>

</cfcomponent>