PluginManager

Package: MachII.framework
Manages registered Plugins for the framework.
Method Summary
public void init(string configXML, AppManager appManager)
public void addPlugin(string pluginName, Plugin plugin)
public void configure()
public AppManager getAppManager()
public Plugin getPlugin(string pluginName)
public void handleException(EventContext eventContext, Exception exception)
public void postEvent(EventContext eventContext)
public void postProcess(EventContext eventContext)
public void postView(EventContext eventContext)
public void preEvent(EventContext eventContext)
public void preProcess(EventContext eventContext)
public void preView(EventContext eventContext)
public void setAppManager(AppManager appManager)
Method Detail
addPlugin

public void addPlugin( string pluginName, Plugin plugin )

Parameters:
string pluginName
Plugin plugin

Code:

	<cffunction name="addPlugin" access="public" returntype="void" output="false">
		<cfargument name="pluginName" type="string" required="true" />
		<cfargument name="plugin" type="MachII.framework.Plugin" required="true" />
		<cfset variables.plugins[arguments.pluginName] = arguments.plugin />
		<cfset variables.nPlugins = variables.nPlugins + 1 />
		<cfset variables.pluginArray[variables.nPlugins] = arguments.plugin />
	</cffunction> 

configure

public void configure( )

Parameters:

Code:

	<cffunction name="configure" access="public" returntype="void">
		<cfset var key = 0 />
		<cfloop collection="#variables.plugins#" item="key">
			<cfset getPlugin(key).configure() />
		</cfloop>
	</cffunction> 

getAppManager

public AppManager getAppManager( )

Parameters:

Code:

	<cffunction name="getAppManager" access="public" returntype="MachII.framework.AppManager" output="false">
		<cfreturn variables.appManager />
	</cffunction> 

getPlugin

public Plugin getPlugin( string pluginName )

Parameters:
string pluginName

Code:

	<cffunction name="getPlugin" access="public" returntype="MachII.framework.Plugin" output="false">
		<cfargument name="pluginName" type="string" required="true" />
		<cfreturn variables.plugins[arguments.pluginName] />
	</cffunction> 

handleException

public void handleException( EventContext eventContext, Exception exception )

Parameters:
EventContext eventContext
Exception exception

Code:

	<cffunction name="handleException" access="public" returntype="void" output="true">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfargument name="exception" type="MachII.util.Exception" required="true" />
		<cfset var aPlugin = 0 />
		<cfset var i = 0 />
		<cfloop index="i" from="1" to="#variables.nPlugins#">
			<cfset aPlugin = variables.pluginArray[i] />
			<cfset aPlugin.handleException(arguments.eventContext, arguments.exception) />
		</cfloop>
	</cffunction> 

init

public void init( string configXML, AppManager appManager )

Parameters:
string configXML
AppManager appManager

Code:

	<cffunction name="init" access="public" returntype="void" output="false">
		<cfargument name="configXML" type="string" required="true" />
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		
		<cfset var xnPlugins = 0 />
		<cfset var xnParams = 0 />
		<cfset var i = 0 />
		<cfset var j = 0 />
		<cfset var paramName = 0 />
		<cfset var paramValue = 0 />
		<cfset var plugin = 0 />
		<cfset var pluginName = 0 />
		<cfset var pluginType = 0 />
		<cfset var pluginParams = 0 />
		
		<cfset setAppManager(arguments.appManager) />
		
		<cfset xnPlugins = XMLSearch(configXML, "//plugins/plugin" ) />
		<cfloop from="1" to="#ArrayLen(xnPlugins)#" index="i">
			<cfset pluginName = xnPlugins[i].XmlAttributes['name'] />
			<cfset pluginType = xnPlugins[i].XmlAttributes['type'] />
			
			
			<cfset pluginParams = StructNew() />
			<cfset xnParams = XMLSearch(xnPlugins[i], "./parameters/parameter")>
			<cfloop from="1" to="#ArrayLen(xnParams)#" index="j">
				<cfset paramName = xnParams[j].XmlAttributes['name'] />
				<cfset paramValue = xnParams[j].XmlAttributes['value'] />
				
				<cfset StructInsert(pluginParams, paramName, paramValue, true) />
			</cfloop>
			
			<cfset plugin = CreateObject('component', pluginType) />
			<cfset plugin.init(arguments.appManager, pluginParams) />
			
			<cfset addPlugin(pluginName, plugin) />
		</cfloop>
	</cffunction> 

postEvent

public void postEvent( EventContext eventContext )

Parameters:
EventContext eventContext

Code:

	<cffunction name="postEvent" access="public" returntype="void" output="true">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfset var aPlugin = 0 />
		<cfset var i = 0 />
		<cfloop index="i" from="1" to="#variables.nPlugins#">
			<cfset aPlugin = variables.pluginArray[i] />
			<cfset aPlugin.postEvent(arguments.eventContext) />
		</cfloop>
	</cffunction> 

postProcess

public void postProcess( EventContext eventContext )

Parameters:
EventContext eventContext

Code:

	<cffunction name="postProcess" access="public" returntype="void" output="true">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfset var aPlugin = 0 />
		<cfset var i = 0 />
		<cfloop index="i" from="1" to="#variables.nPlugins#">
			<cfset aPlugin = variables.pluginArray[i] />
			<cfset aPlugin.postProcess(arguments.eventContext) />
		</cfloop>
	</cffunction> 

postView

public void postView( EventContext eventContext )

Parameters:
EventContext eventContext

Code:

	<cffunction name="postView" access="public" returntype="void" output="true">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfset var aPlugin = 0 />
		<cfset var i = 0 />
		<cfloop index="i" from="1" to="#variables.nPlugins#">
			<cfset aPlugin = variables.pluginArray[i] />
			<cfset aPlugin.postView(arguments.eventContext) />
		</cfloop>
	</cffunction> 

preEvent

public void preEvent( EventContext eventContext )

Parameters:
EventContext eventContext

Code:

	<cffunction name="preEvent" access="public" returntype="void" output="true">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfset var aPlugin = 0 />
		<cfset var i = 0 />
		<cfloop index="i" from="1" to="#variables.nPlugins#">
			<cfset aPlugin = variables.pluginArray[i] />
			<cfset aPlugin.preEvent(arguments.eventContext) />
		</cfloop>
	</cffunction> 

preProcess

public void preProcess( EventContext eventContext )

Parameters:
EventContext eventContext

Code:

	<cffunction name="preProcess" access="public" returntype="void" output="true">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfset var aPlugin = 0 />
		<cfset var i = 0 />
		<cfloop index="i" from="1" to="#variables.nPlugins#">
			<cfset aPlugin = variables.pluginArray[i] />
			<cfset aPlugin.preProcess(arguments.eventContext) />
		</cfloop>
	</cffunction> 

preView

public void preView( EventContext eventContext )

Parameters:
EventContext eventContext

Code:

	<cffunction name="preView" access="public" returntype="void" output="true">
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfset var aPlugin = 0 />
		<cfset var i = 0 />
		<cfloop index="i" from="1" to="#variables.nPlugins#">
			<cfset aPlugin = variables.pluginArray[i] />
			<cfset aPlugin.preView(arguments.eventContext) />
		</cfloop>
	</cffunction> 

setAppManager

public void setAppManager( AppManager appManager )

Parameters:
AppManager appManager

Code:

	<cffunction name="setAppManager" access="public" returntype="void" output="false">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfset variables.appManager = arguments.appManager />
	</cffunction>