Documentation home page

MachII.framework.commands
Component ExecuteCommand

framework.Command
  |
  +--framework.commands.ExecuteCommand

An Command for executing a subroutine.

Method Summary
public ExecuteCommand init(string subroutineName)
          Used by the framework for initialization.
public boolean execute(Event event, EventContext eventContext)
          Executes the command.
private string getSubroutineName()
private void setSubroutineName(string subroutineName)

Methods inherited from framework.Command
setParameter, getParameter, setParameters
 

Method Detail

execute

public boolean execute(Event event, EventContext eventContext)
Executes the command.

Parameters:
Event event
EventContext eventContext

Code:
	<cffunction name="execute" access="public" returntype="boolean" output="true"
		hint="Executes the command.">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfreturn arguments.eventContext.executeSubroutine(getSubroutineName(), arguments.event) />
	</cffunction>

getSubroutineName

private string getSubroutineName()

Code:
	<cffunction name="getSubroutineName" access="private" returntype="string" output="false">
		<cfreturn variables.subroutineName />
	</cffunction>

init

public ExecuteCommand init(string subroutineName)
Used by the framework for initialization.

Parameters:
string subroutineName

Code:
	<cffunction name="init" access="public" returntype="ExecuteCommand" output="false"
		hint="Used by the framework for initialization.">
		<cfargument name="subroutineName" type="string" required="true" />
		
		<cfset setSubroutineName(arguments.subroutineName) />
		
		<cfreturn this />
	</cffunction>

setSubroutineName

private void setSubroutineName(string subroutineName)
Parameters:
string subroutineName

Code:
	<cffunction name="setSubroutineName" access="private" returntype="void" output="false">
		<cfargument name="subroutineName" type="string" required="true" />
		<cfset variables.subroutineName = arguments.subroutineName />
	</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: Peter J. Farrell (peter@mach-ii.com)
$Id: ExecuteCommand.cfc 482 2007-09-05 02:07:07Z pfarrell $

Created version: 1.5.0
Updated version: 1.5.0

Notes:
--->
<cfcomponent 
	displayname="ExecuteCommand" 
	extends="MachII.framework.Command"
	output="false"
	hint="An Command for executing a subroutine.">
	
	<!---
	PROPERTIES
	--->
	<cfset variables.subroutineName = "" />
	
	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" returntype="ExecuteCommand" output="false"
		hint="Used by the framework for initialization.">
		<cfargument name="subroutineName" type="string" required="true" />
		
		<cfset setSubroutineName(arguments.subroutineName) />
		
		<cfreturn this />
	</cffunction>
	
	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="execute" access="public" returntype="boolean" output="true"
		hint="Executes the command.">
		<cfargument name="event" type="MachII.framework.Event" required="true" />
		<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
		<cfreturn arguments.eventContext.executeSubroutine(getSubroutineName(), arguments.event) />
	</cffunction>
	
	<!---
	ACCESSORS
	--->
	<cffunction name="setSubroutineName" access="private" returntype="void" output="false">
		<cfargument name="subroutineName" type="string" required="true" />
		<cfset variables.subroutineName = arguments.subroutineName />
	</cffunction>
	<cffunction name="getSubroutineName" access="private" returntype="string" output="false">
		<cfreturn variables.subroutineName />
	</cffunction>

</cfcomponent>