EventContext

Package: MachII.framework
Handles event-command execution and event processing mechanism for an event lifecycle.

<!--- License: Copyright 2008 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: EventContext.cfc 1090 2008-10-06 05:57:22Z peterfarrell $ Created version: 1.0.0 Updated version: 1.6.0 Notes: --->

Method Summary
public EventContext init(RequestHandler requestHandler, SizedQueue eventQueue)

Initalizes the event-context.

public void addHTMLHeadElement(string text)

Adds a HTML head element.

public void addHTMLHeadElementCallback(any callback, string method)

Adds callback to notify when addHTMLHeadElement is run.

public void addHTTPHeader([string name=""], [string value=""], [numeric statusCode="0"], [string statusText=""], [string charset=""])

Adds a HTTP header. You must use named arguments or addHTTPHeaderByName/addHTTPHeaderByStatus helper methods.

public void addHTTPHeaderByName(string name, string value, [string charset])

Adds a HTTP header by name/value.

public void addHTTPHeaderByStatus(string statuscode, [string statustext])

Adds a HTTP header by statusCode/statusText.

public void addHTTPHeaderCallback(any callback, string method)

Adds callback to notify when addHTMLHeadElement is run.

public void announceEvent(string eventName, [struct eventArgs="#StructNew()#"], [string moduleName="#getAppManager().getModuleName()#"])

Queues an event for the framework to handle.

public void clearEventMappings()

Clears the current event mappings.

public void clearEventQueue()

Clears the event queue.

public void displayView(Event event, string viewName, [string contentKey=""], [string contentArg=""], [boolean append="false"])

Displays a view.

public boolean executeSubroutine(string subroutineName, Event event)

Executes a subroutine.

public AppManager getAppManager()

Sets the appManager that pertains to context of currently executing event.

public Event getCurrentEvent()

Gets the current event object.

public numeric getEventCount()

Returns the number of events that have been processed for this context.

public struct getEventMapping(string eventName)

Gets an event mapping by the event name.

private SizedQueue getEventQueue()
public string getExceptionEventName()
private Log getLog()

Gets the log.

public Event getNextEvent()

Peeks at the next event in the queue.

public Event getPreviousEvent()

Returns the previous handled event.

public any getRequestHandler()
private any getViewContext()
public void handleException(Exception exception, [boolean clearEventQueue="true"], [any missingEvent=""])

Handles an exception.

public boolean hasCurrentEvent()

Checks if the current event has an event object.

public boolean hasMoreEvents()

Checks if there are more events in the queue.

public boolean hasNextEvent()

Peeks at the next event in the queue.

public boolean hasPreviousEvent()

Returns whether or not getPreviousEvent() can be called to return an event.

public boolean isEventMappingDefined(string eventName)

Checks if an event mapping is defined.

public void removeHTMLHeadElementCallback(any callback)

Removes callback to notify when addHTMLHeadElement is run.

public void removeHTTPHeaderCallback(any callback)

Removes callback to notify when addHTTPHeaderCallback is run.

private void setAppManager(AppManager appManager)

Sets the appManager that pertains to context of currently executing event.

private void setCurrentEvent(Event currentEvent)
public void setEventMapping(string eventName, string mappingName, [string mappingModuleName="#getAppManager().getModuleName()#"])

Sets an event mapping.

private void setEventQueue(SizedQueue eventQueue)
public void setExceptionEventName(string exceptionEventName)
private void setLog(LogFactory logFactory)

Uses the log factory to create a log.

private void setPreviousEvent(Event previousEvent)
private void setRequestHandler(RequestHandler requestHandler)
public void setup(AppManager appManager, [any currentEvent=""])

Sets up the event-context.

private void setViewContext(ViewContext viewContext)
Method Detail
addHTMLHeadElement

public void addHTMLHeadElement( string text )

Adds a HTML head element.

Parameters:
string text

Code:

	<cffunction name="addHTMLHeadElement" access="public" returntype="void" output="false"
		hint="Adds a HTML head element.">
		<cfargument name="text" type="string" required="true" />
		
		<cfset var i = 0 />
		
		<cfhtmlhead text="#arguments.text#" />
		
		
		<cfloop from="1" to="#ArrayLen(variables.HTMLHeadElementCallbacks)#" index="i">
			<cfinvoke component="#variables.HTMLHeadElementCallbacks[i].callback#"
				method="#variables.HTMLHeadElementCallbacks[i].method#" 
				argumentcollection="#arguments#" />
		</cfloop>
	</cffunction> 

addHTMLHeadElementCallback

public void addHTMLHeadElementCallback( any callback, string method )

Adds callback to notify when addHTMLHeadElement is run.

Parameters:
any callback
string method

Code:

	<cffunction name="addHTMLHeadElementCallback" access="public" returntype="void" output="false"
		hint="Adds callback to notify when addHTMLHeadElement is run.">
		<cfargument name="callback" type="any" required="true" />
		<cfargument name="method" type="string" required="true" />
		<cfset ArrayAppend(variables.HTMLHeadElementCallbacks, arguments) />
	</cffunction> 

addHTTPHeader

public void addHTTPHeader( [string name=""], [string value=""], [numeric statusCode="0"], [string statusText=""], [string charset=""] )

Adds a HTTP header. You must use named arguments or addHTTPHeaderByName/addHTTPHeaderByStatus helper methods.

Parameters:
[string name=""]
[string value=""]
[numeric statusCode="0"]
[string statusText=""]
[string charset=""]

Code:

	<cffunction name="addHTTPHeader" access="public" returntype="void" output="false"
		hint="Adds a HTTP header. You must use named arguments or addHTTPHeaderByName/addHTTPHeaderByStatus helper methods.">
		<cfargument name="name" type="string" required="false" default="" />
		<cfargument name="value" type="string" required="false" default="" />
		<cfargument name="statusCode" type="numeric" required="false" default="0" />
		<cfargument name="statusText" type="string" required="false" default="" />
		<cfargument name="charset" type="string" required="false" default="" />
		
		<cfset var i = 0 />
		
		<cfif Len(arguments.name)>
			<cfif Len(arguments.charset)>
				<cfheader name="#arguments.name#" 
					value="#arguments.value#" 
					charset="#arguments.charset#" />			
			<cfelse>
				<cfheader name="#arguments.name#" 
					value="#arguments.value#" />
			</cfif>
		<cfelseif arguments.statusCode NEQ 0>
			<cfheader statuscode="#arguments.statusCode#" 
				statustext="#arguments.statusText#" />
		<cfelse>
			<cfthrow type="MachII.framework.invalidHTTPHeaderArguments"
				message="The method addHTTPHeader required arguments must be 'name,value' or 'statusCode'."
				detail="Passed arguments:#arguments.toString()#" />
		</cfif>
		
		
		<cfloop from="1" to="#ArrayLen(variables.HTTPHeaderCallbacks)#" index="i">
			<cfinvoke component="#variables.HTTPHeaderCallbacks[i].callback#"
				method="#variables.HTTPHeaderCallbacks[i].method#" 
				argumentcollection="#arguments#" />
		</cfloop>
	</cffunction> 

addHTTPHeaderByName

public void addHTTPHeaderByName( string name, string value, [string charset] )

Adds a HTTP header by name/value.

Parameters:
string name
string value
[string charset]

Code:

	<cffunction name="addHTTPHeaderByName" access="public" returntype="void" output="false"
		hint="Adds a HTTP header by name/value.">
		<cfargument name="name" type="string" required="true" />
		<cfargument name="value" type="string" required="true" />
		<cfargument name="charset" type="string" required="false" />
		<cfset addHTTPHeader(argumentcollection=arguments) />
	</cffunction> 

addHTTPHeaderByStatus

public void addHTTPHeaderByStatus( string statuscode, [string statustext] )

Adds a HTTP header by statusCode/statusText.

Parameters:
string statuscode
[string statustext]

Code:

	<cffunction name="addHTTPHeaderByStatus" access="public" returntype="void" output="false"
		hint="Adds a HTTP header by statusCode/statusText.">
		<cfargument name="statuscode" type="string" required="true" />
		<cfargument name="statustext" type="string" required="false" />
		<cfset addHTTPHeader(argumentcollection=arguments) />
	</cffunction> 

addHTTPHeaderCallback

public void addHTTPHeaderCallback( any callback, string method )

Adds callback to notify when addHTMLHeadElement is run.

Parameters:
any callback
string method

Code:

	<cffunction name="addHTTPHeaderCallback" access="public" returntype="void" output="false"
		hint="Adds callback to notify when addHTMLHeadElement is run.">
		<cfargument name="callback" type="any" required="true" />
		<cfargument name="method" type="string" required="true" />
		<cfset ArrayAppend(variables.HTTPHeaderCallbacks, arguments) />
	</cffunction> 

announceEvent

public void announceEvent( string eventName, [struct eventArgs="#StructNew()#"], [string moduleName="#getAppManager().getModuleName()#"] )

Queues an event for the framework to handle.

Parameters:
string eventName
[struct eventArgs="#StructNew()#"]
[string moduleName="#getAppManager().getModuleName()#"]

Code:

	<cffunction name="announceEvent" access="public" returntype="void" output="true"
		hint="Queues an event for the framework to handle.">
		<cfargument name="eventName" type="string" required="true" />
		<cfargument name="eventArgs" type="struct" required="false" default="#StructNew()#" />
		<cfargument name="moduleName" type="string" required="false" default="#getAppManager().getModuleName()#" />
		
		<cfset var mapping = "" />
		<cfset var nextEvent = "" />
		<cfset var nextModuleName = arguments.moduleName />
		<cfset var nextEventName = arguments.eventName />
		<cfset var exception = "" />
		<cfset var missingEvent = "" />
		<cfset var log = getLog() />
		
		<cftry>
			
			<cfif isEventMappingDefined(arguments.eventName)>
				<cfset mapping = getEventMapping(arguments.eventName) />
				<cfset nextModuleName = mapping.moduleName />
				<cfset nextEventName = mapping.eventName />
				
				<cfif log.isDebugEnabled()>
					<cfset log.debug("Announcing event '#nextEventName#' in module '#nextModuleName#' mapped from '#arguments.eventName#'.") />
				</cfif>
			<cfelse>
				<cfif log.isDebugEnabled()>
					<cfset log.debug("Announcing event '#nextEventName#' in module '#nextModuleName#'.") />
				</cfif>
			</cfif>
			
			
			<cfset nextEvent = getAppManager().getEventManager().createEvent(nextModuleName, nextEventName, arguments.eventArgs, getRequestHandler().getRequestEventName(), getRequestHandler().getRequestModuleName()) />
			
			<cfset getEventQueue().put(nextEvent) />
			
			<cfcatch  type="any">
				<cfif log.isErrorEnabled()>
					<cfset log.error("Cannot announce event '#nextEventName#' in module '#nextModuleName#' because it cannot be found.", cfcatch) />
				</cfif>
				
				<cfset missingEvent = getAppManager().getEventManager().createEvent(nextModuleName, nextEventName, arguments.eventArgs, getRequestHandler().getRequestEventName(), getRequestHandler().getRequestModuleName(), false) />
				<cfset exception = getRequestHandler().wrapException(cfcatch) />
				<cfset handleException(exception, true, missingEvent) />
			</cfcatch>
		</cftry>
	</cffunction> 

clearEventMappings

public void clearEventMappings( )

Clears the current event mappings.

Parameters:

Code:

	<cffunction name="clearEventMappings" access="public" returntype="void" output="false"
		hint="Clears the current event mappings.">
		<cfset StructClear(variables.mappings) />
	</cffunction> 

clearEventQueue

public void clearEventQueue( )

Clears the event queue.

Parameters:

Code:

	<cffunction name="clearEventQueue" access="public" returntype="void" output="false"
		hint="Clears the event queue.">
			
		<cfset var log = getLog() />
		
		<cfif log.isInfoEnabled()>
			<cfset log.info("Event queue has been cleared.") />
		</cfif>
		
		<cfset getEventQueue().clear() />
	</cffunction> 

displayView

public void displayView( Event event, string viewName, [string contentKey=""], [string contentArg=""], [boolean append="false"] )

Displays a view.

Parameters:
Event event
string viewName
[string contentKey=""]
[string contentArg=""]
[boolean append="false"]

Code:

	<cffunction name="displayView" access="public" returntype="void" output="true"
		hint="Displays a view.">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="viewName" type="string" required="true" />
		<cfargument name="contentKey" type="string" required="false" default="" />
		<cfargument name="contentArg" type="string" required="false" default="" />
		<cfargument name="append" type="boolean" required="false" default="false" />
		
		
		<cfset getAppManager().getPluginManager().preView(this) />
		
		<cfset getViewContext().displayView(arguments.event, arguments.viewName, arguments.contentKey, arguments.contentArg, arguments.append) />
		
		
		<cfset getAppManager().getPluginManager().postView(this) />
	</cffunction> 

executeSubroutine

public boolean executeSubroutine( string subroutineName, Event event )

Executes a subroutine.

Parameters:
string subroutineName
Event event

Code:

	<cffunction name="executeSubroutine" access="public" returntype="boolean" output="true"
		hint="Executes a subroutine.">
		<cfargument name="subroutineName" type="string" required="true" />
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		
		<cfset var subroutineHandler = "" />
		<cfset var exception = "" />
		<cfset var continue = true />
		<cfset var log = getLog() />
	
		<cftry>
			<cfif log.isDebugEnabled()>
				<cfset log.debug("Subroutine '#arguments.subroutineName#' beginning execution.") />
			</cfif>
			
					
			<cfset subroutineHandler = getAppManager().getSubroutineManager().getSubroutineHandler(arguments.subroutineName) />
			
			<cfset continue = subroutineHandler.handleSubroutine(arguments.event, this) />

			<cfif log.isDebugEnabled()>
				<cfset log.debug("Subroutine '#arguments.subroutineName#' execution has ended.") />
			</cfif>
			
			<cfcatch type="any">
				<cfif log.isErrorEnabled()>
					<cfset log.error("Subroutine '#arguments.subroutineName#' has caused an exception.", cfcatch) />
				</cfif>
				<cfrethrow />
			</cfcatch>
		</cftry>
		
		<cfif log.isInfoEnabled() AND NOT continue>
			<cfset log.info("Subroutine '#arguments.subroutineName#' has changed the flow of this event.") />
		</cfif>
		
		<cfreturn continue />
	</cffunction> 

getAppManager

public AppManager getAppManager( )

Sets the appManager that pertains to context of currently executing event.

Parameters:

Code:

	<cffunction name="getAppManager" access="public" returntype="MachII.framework.AppManager" output="false"
		hint="Sets the appManager that pertains to context of currently executing event.">
		<cfreturn variables.appManager />
	</cffunction> 

getCurrentEvent

public Event getCurrentEvent( )

Gets the current event object.

Parameters:

Code:

	<cffunction name="getCurrentEvent" access="public" returntype="MachII.framework.Event" output="false"
		hint="Gets the current event object.">
		<cfreturn variables.currentEvent />
	</cffunction> 

getEventCount

public numeric getEventCount( )

Returns the number of events that have been processed for this context.

Parameters:

Code:

	<cffunction name="getEventCount" access="public" returntype="numeric" output="false"
		hint="Returns the number of events that have been processed for this context.">
		<cfreturn getRequestHandler().getEventCount() />
	</cffunction> 

getEventMapping

public struct getEventMapping( string eventName )

Gets an event mapping by the event name.

Parameters:
string eventName

Code:

	<cffunction name="getEventMapping" access="public" returntype="struct" output="false"
		hint="Gets an event mapping by the event name.">
		<cfargument name="eventName" type="string" required="true" />
		
		<cfset var mapping = StructNew() />
		
		
		<cfif StructKeyExists(variables.mappings, arguments.eventName)>
			<cfset mapping = variables.mappings[arguments.eventName] />
		<cfelse>
			<cfset mapping.eventName = arguments.eventName />
			<cfset mapping.moduleName = getAppManager().getModuleName() />
		</cfif>
		
		<cfreturn mapping />
	</cffunction> 

getEventQueue

private SizedQueue getEventQueue( )

Parameters:

Code:

	<cffunction name="getEventQueue" access="private" returntype="MachII.util.SizedQueue" output="false">
		<cfreturn variables.eventQueue />
	</cffunction> 

getExceptionEventName

public string getExceptionEventName( )

Parameters:

Code:

	<cffunction name="getExceptionEventName" access="public" returntype="string" output="false">
		<cfreturn variables.exceptionEventName />
	</cffunction> 

getLog

private Log getLog( )

Gets the log.

Parameters:

Code:

	<cffunction name="getLog" access="private" returntype="MachII.logging.Log" output="false"
		hint="Gets the log.">
		<cfreturn variables.log />
	</cffunction> 

getNextEvent

public Event getNextEvent( )

Peeks at the next event in the queue.

Parameters:

Code:

	<cffunction name="getNextEvent" access="public" returntype="MachII.framework.Event" output="false"
		hint="Peeks at the next event in the queue.">
		<cfreturn getEventQueue().peek() />
	</cffunction> 

getPreviousEvent

public Event getPreviousEvent( )

Returns the previous handled event.

Parameters:

Code:

	<cffunction name="getPreviousEvent" access="public" returntype="MachII.framework.Event" output="false"
		hint="Returns the previous handled event.">
		<cfreturn variables.previousEvent />
	</cffunction> 

getRequestHandler

public any getRequestHandler( )

Parameters:

Code:

	<cffunction name="getRequestHandler" access="public" type="MachII.framework.RequestHandler" output="false">
		<cfreturn variables.requestHandler />
	</cffunction> 

getViewContext

private any getViewContext( )

Parameters:

Code:

	<cffunction name="getViewContext" access="private" type="MachII.framework.ViewContext" output="false">
		<cfreturn variables.viewContext />
	</cffunction> 

handleException

public void handleException( Exception exception, [boolean clearEventQueue="true"], [any missingEvent=""] )

Handles an exception.

Parameters:
Exception exception
[boolean clearEventQueue="true"]
[any missingEvent=""]

Code:

	<cffunction name="handleException" access="public" returntype="void" output="true"
		hint="Handles an exception.">
		<cfargument name="exception" type="MachII.util.Exception" required="true" />
		<cfargument name="clearEventQueue" type="boolean" required="false" default="true" />
		<cfargument name="missingEvent" type="any" required="false" default="" />
		
		<cfset var nextEvent = "" />
		<cfset var eventArgs = StructNew() />
		<cfset var appManager = getAppManager() />
		<cfset var result = StructNew() />
		<cfset var log = getLog() />
		
		<cfset result.eventName = getExceptionEventName() />
		
		<cftry>
						
			<cfset eventArgs.exception = arguments.exception />
			<cfif hasCurrentEvent()>
				<cfset eventArgs.exceptionEvent = getCurrentEvent() />
			</cfif>
			<cfif IsObject(arguments.missingEvent)>
				<cfset eventArgs.missingEvent = arguments.missingEvent />
			</cfif>
			
			
			<cfif arguments.clearEventQueue>
				<cfset variables.clearEventQueue() />
			</cfif>
			
			
			<cfif isEventMappingDefined(result.eventName)>
				<cfset result = getEventMapping(exceptionEventName) />
				<cfif Len(result.moduleName)>
					<cfset appManager = appManager.getModuleManager().getModule(result.moduleName).getModuleAppManager() />
				<cfelse>
					<cfset appManager = appManager.getModuleManager().getAppManager() />
				</cfif>
			
			<cfelseif appManager.getPropertyManager().isPropertyDefined("exceptionEvent")>
				<cfset result.moduleName = appManager.getModuleName() />
			<cfelse>
				<cfset result.moduleName = "" />
			</cfif>
			
			<cfif log.isInfoEnabled()>
				<cfset log.info("Handling exception.") />
			</cfif>
			
			
			<cfset nextEvent = appManager.getEventManager().createEvent(result.moduleName, result.eventName, eventArgs, getRequestHandler().getRequestEventName(), getRequestHandler().getRequestModuleName()) />
			<cfset getEventQueue().put(nextEvent) />
			
			
			<cfset appManager.getPluginManager().handleException(this, arguments.exception) />
			
			<cfcatch type="any">
				<cfrethrow />
			</cfcatch>
		</cftry>
	</cffunction> 

hasCurrentEvent

public boolean hasCurrentEvent( )

Checks if the current event has an event object.

Parameters:

Code:

	<cffunction name="hasCurrentEvent" access="public" returntype="boolean" output="false"
		hint="Checks if the current event has an event object.">
		<cfreturn IsObject(variables.currentEvent) />
	</cffunction> 

hasMoreEvents

public boolean hasMoreEvents( )

Checks if there are more events in the queue.

Parameters:

Code:

	<cffunction name="hasMoreEvents" access="public" returntype="boolean" output="false"
		hint="Checks if there are more events in the queue.">
		<cfreturn NOT getEventQueue().isEmpty() />
	</cffunction> 

hasNextEvent

public boolean hasNextEvent( )

Peeks at the next event in the queue.

Parameters:

Code:

	<cffunction name="hasNextEvent" access="public" returntype="boolean" output="false"
		hint="Peeks at the next event in the queue.">
		<cfreturn hasMoreEvents() />
	</cffunction> 

hasPreviousEvent

public boolean hasPreviousEvent( )

Returns whether or not getPreviousEvent() can be called to return an event.

Parameters:

Code:

	<cffunction name="hasPreviousEvent" access="public" returntype="boolean" output="false"
		hint="Returns whether or not getPreviousEvent() can be called to return an event.">
		<cfreturn IsObject(variables.previousEvent) />
	</cffunction> 

init

public EventContext init( RequestHandler requestHandler, SizedQueue eventQueue )

Initalizes the event-context.

Parameters:
RequestHandler requestHandler
SizedQueue eventQueue

Code:

	<cffunction name="init" access="public" returntype="EventContext" output="false"
		hint="Initalizes the event-context.">
		<cfargument name="requestHandler" type="MachII.framework.RequestHandler" required="true" />
		<cfargument name="eventQueue" type="MachII.util.SizedQueue" required="true" />
		
		<cfset setRequestHandler(arguments.requestHandler) />
		<cfset setEventQueue(arguments.eventQueue) />
		<cfset setViewContext(CreateObject("component", "MachII.framework.ViewContext")) />
		
		<cfreturn this />
	</cffunction> 

isEventMappingDefined

public boolean isEventMappingDefined( string eventName )

Checks if an event mapping is defined.

Parameters:
string eventName

Code:

	<cffunction name="isEventMappingDefined" type="public" returntype="boolean" output="false"
		hint="Checks if an event mapping is defined.">
		<cfargument name="eventName" type="string" required="true" />
		
		<cfset var result = false />
		
		<cfif StructKeyExists(variables.mappings, arguments.eventName)>
			<cfset result = true />
		</cfif>
		
		<cfreturn result />
	</cffunction> 

removeHTMLHeadElementCallback

public void removeHTMLHeadElementCallback( any callback )

Removes callback to notify when addHTMLHeadElement is run.

Parameters:
any callback

Code:

	<cffunction name="removeHTMLHeadElementCallback" access="public" returntype="void" output="false"
		hint="Removes callback to notify when addHTMLHeadElement is run.">
		<cfargument name="callback" type="any" required="true" />

		<cfset var utils = getAppManager().getUtils() />
		<cfset var i = 0 />
		
		<cfloop from="1" to="#ArrayLen(variables.HTMLHeadElementCallbacks)#" index="i">
			<cfif utils.assertSame(variables.HTMLHeadElementCallbacks[i], arguments.callback)>
				<cfset ArrayDeleteAt(variables.HTMLHeadElementCallbacks, i) />
				<cfbreak />
			</cfif>
		</cfloop>
	</cffunction> 

removeHTTPHeaderCallback

public void removeHTTPHeaderCallback( any callback )

Removes callback to notify when addHTTPHeaderCallback is run.

Parameters:
any callback

Code:

	<cffunction name="removeHTTPHeaderCallback" access="public" returntype="void" output="false"
		hint="Removes callback to notify when addHTTPHeaderCallback is run.">
		<cfargument name="callback" type="any" required="true" />

		<cfset var utils = getAppManager().getUtils() />
		<cfset var i = 0 />
		
		<cfloop from="1" to="#ArrayLen(variables.HTTPHeaderCallbacks)#" index="i">
			<cfif utils.assertSame(variables.HTTPHeaderCallbacks[i], arguments.callback)>
				<cfset ArrayDeleteAt(variables.HTTPHeaderCallbacks, i) />
				<cfbreak />
			</cfif>
		</cfloop>
	</cffunction> 

setAppManager

private void setAppManager( AppManager appManager )

Sets the appManager that pertains to context of currently executing event.

Parameters:
AppManager appManager

Code:

	<cffunction name="setAppManager" access="private" returntype="void" output="false"
		hint="Sets the appManager that pertains to context of currently executing event.">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfset variables.appManager = arguments.appManager />
	</cffunction> 

setCurrentEvent

private void setCurrentEvent( Event currentEvent )

Parameters:
Event currentEvent

Code:

	<cffunction name="setCurrentEvent" access="private" returntype="void" output="false">
		<cfargument name="currentEvent" type="MachII.framework.Event" required="true" />
		<cfset variables.currentEvent = arguments.currentEvent />
	</cffunction> 

setEventMapping

public void setEventMapping( string eventName, string mappingName, [string mappingModuleName="#getAppManager().getModuleName()#"] )

Sets an event mapping.

Parameters:
string eventName
string mappingName
[string mappingModuleName="#getAppManager().getModuleName()#"]

Code:

	<cffunction name="setEventMapping" access="public" returntype="void" output="false"
		hint="Sets an event mapping.">
		<cfargument name="eventName" type="string" required="true" />
		<cfargument name="mappingName" type="string" required="true" />
		<cfargument name="mappingModuleName" type="string" required="false"
			default="#getAppManager().getModuleName()#" />

		<cfset var mapping = StructNew() />
		<cfset var log = getLog() />

		<cfif Len(arguments.mappingModuleName)
			AND NOT getAppManager().getModuleManager().isModuleDefined(arguments.mappingModuleName)>
			
			<cfif log.isErrorEnabled()>
				<cfset log.error("Cannot create an event-mapping on event '#arguments.eventMapping#' because the mapping '#arguments.mappingName#' in module '#arguments.mappingModuleName#' cannot be found.") />
			</cfif>
			
			<cfthrow type="MachII.framework.eventMappingModuleNotDefined"
				message="The module '#arguments.mappingModuleName#' cannot be found for this event-mapping." />	
		</cfif>
		
		
		<cfset mapping.eventName = arguments.mappingName />
		<cfset mapping.moduleName = arguments.mappingModuleName />
		
		<cfset variables.mappings[arguments.eventName] = mapping />
		
		<cfif log.isDebugEnabled()>
			<cfset log.debug("Created event-mapping named '#arguments.eventName#' to event '#arguments.mappingName#' in module '#arguments.mappingModuleName#'.") />
		</cfif>
	</cffunction> 

setEventQueue

private void setEventQueue( SizedQueue eventQueue )

Parameters:
SizedQueue eventQueue

Code:

	<cffunction name="setEventQueue" access="private" returntype="void" output="false">
		<cfargument name="eventQueue" type="MachII.util.SizedQueue" required="true" />
		<cfset variables.eventQueue = arguments.eventQueue />
	</cffunction> 

setExceptionEventName

public void setExceptionEventName( string exceptionEventName )

Parameters:
string exceptionEventName

Code:

	<cffunction name="setExceptionEventName" access="public" returntype="void" output="false">
		<cfargument name="exceptionEventName" type="string" required="true" />
		<cfset variables.exceptionEventName = arguments.exceptionEventName />
	</cffunction> 

setLog

private void setLog( LogFactory logFactory )

Uses the log factory to create a log.

Parameters:
LogFactory logFactory

Code:

	<cffunction name="setLog" access="private" returntype="void" output="false"
		hint="Uses the log factory to create a log.">
		<cfargument name="logFactory" type="MachII.logging.LogFactory" required="true" />
		<cfset variables.log = arguments.logFactory.getLog(getMetadata(this).name) />
	</cffunction> 

setPreviousEvent

private void setPreviousEvent( Event previousEvent )

Parameters:
Event previousEvent

Code:

	<cffunction name="setPreviousEvent" access="private" returntype="void" output="false">
		<cfargument name="previousEvent" type="MachII.framework.Event" required="true" />
		<cfset variables.previousEvent = arguments.previousEvent />
	</cffunction> 

setRequestHandler

private void setRequestHandler( RequestHandler requestHandler )

Parameters:
RequestHandler requestHandler

Code:

	<cffunction name="setRequestHandler" access="private" returntype="void" output="false">
		<cfargument name="requestHandler" type="MachII.framework.RequestHandler" required="true" />
		<cfset variables.requestHandler = arguments.requestHandler />
	</cffunction> 

setup

public void setup( AppManager appManager, [any currentEvent=""] )

Sets up the event-context.

Parameters:
AppManager appManager
[any currentEvent=""]

Code:

	<cffunction name="setup" access="public" returntype="void" output="false"
		hint="Sets up the event-context.">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true" />
		<cfargument name="currentEvent" type="any" required="false" default="" />
		
		<cfset setAppManager(arguments.appManager) />
		<cfif hasCurrentEvent()>
			<cfset setPreviousEvent(getCurrentEvent()) />
		</cfif>
		<cfif IsObject(arguments.currentEvent)>
			<cfset setCurrentEvent(arguments.currentEvent) />
		</cfif>
		
		
		<cfset setExceptionEventName(getAppManager().getPropertyManager().getProperty("exceptionEvent")) />
		
		
		<cfset getViewContext().init(getAppManager()) />
		
		
		<cfset setLog(getAppManager().getLogFactory()) />
		
		
		<cfset clearEventMappings() />
	</cffunction> 

setViewContext

private void setViewContext( ViewContext viewContext )

Parameters:
ViewContext viewContext

Code:

	<cffunction name="setViewContext" access="private" returntype="void" output="false">
		<cfargument name="viewContext" type="MachII.framework.ViewContext" required="true" />
		<cfset variables.viewContext = arguments.viewContext />
	</cffunction>