BaseComponent

Package: MachII.framework
Method Summary
public void init(AppManager appManager, [struct parameters="#StructNew()#"])

Used by the framework to initialize the component.

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

Announces a new event to the framework.

public void configure()

Override to provide custom configuration logic. Called after init().

package AppManager getAppManager()

Gets the components AppManager instance.

public any getParameter(string name, [string defaultValue=""])

Gets a configuration parameter value, or a default value if not defined.

public struct getParameters()

Gets the full set of configuration parameters for the component.

public any getProperty(string propertyName)

Gets the specified property - this is just a shortcut for getAppManager().getPropertyManager().getProperty()

public boolean hasParameter(string name)

Checks to see whether or not a configuration parameter is defined.

public boolean isParameterDefined(string name)

Checks to see whether or not a configuration parameter is defined.

private void setAppManager(AppManager appManager)

Sets the components AppManager instance.

public void setParameter(string name, any value)

Sets a configuration parameter.

public void setParameters(struct parameters)

Sets the full set of configuration parameters for the component.

public any setProperty(string propertyName, any propertyValue)

Sets the specified property - this is just a shortcut for getAppManager().getPropertyManager().setProperty()

Method Detail
announceEvent

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

Announces a new event to the framework.

Parameters:
string eventName
[struct eventArgs="#StructNew()#"]

Code:

	<cffunction name="announceEvent" access="public" returntype="void" output="false"
		hint="Announces a new event to the framework.">
		<cfargument name="eventName" type="string" required="true"
			hint="The name of the event to announce." />
		<cfargument name="eventArgs" type="struct" required="false" default="#StructNew()#"
			hint="A struct of arguments to set as the event's args." />
		
		<cfif structKeyExists(request,"eventContext")>
			<cfset request.eventContext.announceEvent(arguments.eventName, arguments.eventArgs) />
		<cfelse>
			<cfthrow message="The EventContext necessary to announce events is not set in 'request.eventContext.'" />
		</cfif>
	</cffunction> 

configure

public void configure( )

Override to provide custom configuration logic. Called after init().

Parameters:

Code:

	<cffunction name="configure" access="public" returntype="void" output="false"
		hint="Override to provide custom configuration logic. Called after init().">
		
	</cffunction> 

getAppManager

package AppManager getAppManager( )

Gets the components AppManager instance.

Parameters:

Code:

	<cffunction name="getAppManager" access="package" returntype="MachII.framework.AppManager" output="false"
		hint="Gets the components AppManager instance.">
		<cfreturn variables.appManager />
	</cffunction> 

getParameter

public any getParameter( string name, [string defaultValue=""] )

Gets a configuration parameter value, or a default value if not defined.

Parameters:
string name
[string defaultValue=""]

Code:

	<cffunction name="getParameter" access="public" returntype="any" output="false"
		hint="Gets a configuration parameter value, or a default value if not defined.">
		<cfargument name="name" type="string" required="true"
			hint="The parameter name." />
		<cfargument name="defaultValue" type="string" required="false" default=""
			hint="The default value to return if the parameter is not defined. Defaults to a blank string." />
		<cfif isParameterDefined(arguments.name)>
			<cfreturn variables.parameters[arguments.name] />
		<cfelse>
			<cfreturn arguments.defaultValue />
		</cfif>
	</cffunction> 

getParameters

public struct getParameters( )

Gets the full set of configuration parameters for the component.

Parameters:

Code:

	<cffunction name="getParameters" access="public" returntype="struct" output="false"
		hint="Gets the full set of configuration parameters for the component.">
		<cfreturn variables.parameters />
	</cffunction> 

getProperty

public any getProperty( string propertyName )

Gets the specified property - this is just a shortcut for getAppManager().getPropertyManager().getProperty()

Parameters:
string propertyName

Code:

	<cffunction name="getProperty" access="public" returntype="any" output="false"
		hint="Gets the specified property - this is just a shortcut for getAppManager().getPropertyManager().getProperty()">
		<cfargument name="propertyName" type="string" required="yes"
			hint="The name of the property to return"/>
		<cfif not structKeyExists(variables,"propMgr")>
			<cfset variables.propMgr = getAppManager().getPropertyManager()/>
		</cfif>
		<cfreturn variables.propMgr.getProperty(arguments.propertyName) />
	</cffunction> 

hasParameter

public boolean hasParameter( string name )

Checks to see whether or not a configuration parameter is defined.

Parameters:
string name

Code:

	<cffunction name="hasParameter" access="public" returntype="boolean" output="false"
		hint="Checks to see whether or not a configuration parameter is defined.">
		<cfargument name="name" type="string" required="true"
			hint="The parameter name." />
		<cfreturn StructKeyExists(variables.parameters, arguments.name) />
	</cffunction> 

init

public void init( AppManager appManager, [struct parameters="#StructNew()#"] )

Used by the framework to initialize the component.

Parameters:
AppManager appManager
[struct parameters="#StructNew()#"]

Code:

	<cffunction name="init" access="public" returntype="void" output="false"
		hint="Used by the framework to initialize the component.">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true"
			hint="The framework instances' AppManager." />
		<cfargument name="parameters" type="struct" required="false" default="#StructNew()#"
			hint="The initial set of configuration parameters." />
		
		<cfset setAppManager(arguments.appManager) />
		<cfset setParameters(arguments.parameters) />
	</cffunction> 

isParameterDefined

public boolean isParameterDefined( string name )

Checks to see whether or not a configuration parameter is defined.

Parameters:
string name

Code:

	<cffunction name="isParameterDefined" access="public" returntype="boolean" output="false"
		hint="Checks to see whether or not a configuration parameter is defined.">
		<cfargument name="name" type="string" required="true"
			hint="The parameter name." />
		<cfreturn StructKeyExists(variables.parameters, arguments.name) />
	</cffunction> 

setAppManager

private void setAppManager( AppManager appManager )

Sets the components AppManager instance.

Parameters:
AppManager appManager

Code:

	<cffunction name="setAppManager" access="private" returntype="void" output="false"
		hint="Sets the components AppManager instance.">
		<cfargument name="appManager" type="MachII.framework.AppManager" required="true"
			hint="The AppManager instance to set." />
		<cfset variables.appManager = arguments.appManager />
	</cffunction> 

setParameter

public void setParameter( string name, any value )

Sets a configuration parameter.

Parameters:
string name
any value

Code:

	<cffunction name="setParameter" access="public" returntype="void" output="false"
		hint="Sets a configuration parameter.">
		<cfargument name="name" type="string" required="true"
			hint="The parameter name." />
		<cfargument name="value" required="true"
			hint="The parameter value." />
		<cfset variables.parameters[arguments.name] = arguments.value />
	</cffunction> 

setParameters

public void setParameters( struct parameters )

Sets the full set of configuration parameters for the component.

Parameters:
struct parameters

Code:

	<cffunction name="setParameters" access="public" returntype="void" output="false"
		hint="Sets the full set of configuration parameters for the component.">
		<cfargument name="parameters" type="struct" required="true" />
		<cfset var key = '' />
		<cfloop collection="#arguments.parameters#" item="key">
			<cfset setParameter(key, parameters[key]) />
		</cfloop>
	</cffunction> 

setProperty

public any setProperty( string propertyName, any propertyValue )

Sets the specified property - this is just a shortcut for getAppManager().getPropertyManager().setProperty()

Parameters:
string propertyName
any propertyValue

Code:

	<cffunction name="setProperty" access="public" returntype="any" output="false"
		hint="Sets the specified property - this is just a shortcut for getAppManager().getPropertyManager().setProperty()">
		<cfargument name="propertyName" type="string" required="yes"
			hint="The name of the property to set"/>
		<cfargument name="propertyValue" type="any" required="yes" 
			hint="The value to store in the property" />
		<cfif not structKeyExists(variables,"propMgr")>
			<cfset variables.propMgr = getAppManager().getPropertyManager()/>
		</cfif>
		<cfreturn variables.propMgr.setProperty(arguments.propertyName, arguments.propertyValue) />
	</cffunction>