Command

Package: MachII.framework
Base Command component.

<!--- 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: Command.cfc 1098 2008-10-19 02:57:06Z kurtwiersma $ Created version: 1.0.0 Updated version: 1.6.0 Notes: --->

Method Summary
public Command init()

Used by the framework for initialization.

public boolean execute(Event event, EventContext eventContext)

Overridden by the command that extends this component.

public ExpressionEvaluator getExpressionEvaluator()
public Log getLog()

Gets the log.

public any getParameter(string name)
public PropertyManager getPropertyManager()
public void setExpressionEvaluator(ExpressionEvaluator expressionEvaluator)
public void setLog(LogFactory logFactory)

Uses the log factory to create a log.

public void setParameter(string name, any value)
public void setParameters(struct parameters)

Sets a struct of parameters to this command.

public void setPropertyManager(PropertyManager propertyManager)
Method Detail
execute

public boolean execute( Event event, EventContext eventContext )

Overridden by the command that extends this component.

Parameters:
Event event
EventContext eventContext

Code:

	<cffunction name="execute" access="public" returntype="boolean" output="true"
		hint="Overridden by the command that extends this component.">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		
		<cfset var log = getLog() />
		
		<cfif log.isInfoEnabled()>
			<cfset log.info("Executing a default command named '#getParameter("commandName")#'. This is not a concrete command. Check your configuration file.") />
		</cfif>
		
		<cfreturn true />
	</cffunction> 

getExpressionEvaluator

public ExpressionEvaluator getExpressionEvaluator( )

Parameters:

Code:

	<cffunction name="getExpressionEvaluator" access="public" returntype="MachII.util.ExpressionEvaluator" output="false">
		<cfreturn variables.expressionEvaluator />
	</cffunction> 

getLog

public Log getLog( )

Gets the log.

Parameters:

Code:

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

getParameter

public any getParameter( string name )

Parameters:
string name

Code:

	<cffunction name="getParameter" access="public" returntype="any" output="false">
		<cfargument name="name" type="string" required="true" />
		<cfreturn variables.parameters[arguments.name] />
	</cffunction> 

getPropertyManager

public PropertyManager getPropertyManager( )

Parameters:

Code:

	<cffunction name="getPropertyManager" access="public" returntype="MachII.framework.PropertyManager" output="false">
		<cfreturn variables.propertyManager />
	</cffunction> 

init

public Command init( )

Used by the framework for initialization.

Parameters:

Code:

	<cffunction name="init" access="public" returntype="Command" output="false"
		hint="Used by the framework for initialization.">
		<cfreturn this />
	</cffunction> 

setExpressionEvaluator

public void setExpressionEvaluator( ExpressionEvaluator expressionEvaluator )

Parameters:
ExpressionEvaluator expressionEvaluator

Code:

	<cffunction name="setExpressionEvaluator" access="public" returntype="void" output="false">
		<cfargument name="expressionEvaluator" type="MachII.util.ExpressionEvaluator" required="true" />
		<cfset variables.expressionEvaluator = arguments.expressionEvaluator />
	</cffunction> 

setLog

public void setLog( LogFactory logFactory )

Uses the log factory to create a log.

Parameters:
LogFactory logFactory

Code:

	<cffunction name="setLog" access="public" 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> 

setParameter

public void setParameter( string name, any value )

Parameters:
string name
any value

Code:

	<cffunction name="setParameter" access="public" returntype="void" output="false">
		<cfargument name="name" type="string" required="true" />
		<cfargument name="value" type="any" required="true" />
		<cfset variables.parameters[arguments.name] = arguments.value />
	</cffunction> 

setParameters

public void setParameters( struct parameters )

Sets a struct of parameters to this command.

Parameters:
struct parameters

Code:

	<cffunction name="setParameters" access="public" returntype="void" output="false"
		hint="Sets a struct of parameters to this command.">
		<cfargument name="parameters" type="struct" required="true" />

		<cfset var key = "" />

		<cfloop collection="#arguments.parameters#" item="key">
			<cfset setParameter(key, parameters[key]) />
		</cfloop>
	</cffunction> 

setPropertyManager

public void setPropertyManager( PropertyManager propertyManager )

Parameters:
PropertyManager propertyManager

Code:

	<cffunction name="setPropertyManager" access="public" returntype="void" output="false">
		<cfargument name="propertyManager" type="MachII.framework.PropertyManager" required="true" />
		<cfset variables.propertyManager = arguments.propertyManager />
	</cffunction>