framework.Command | +--framework.commands.AnnounceCommand
| Method Summary | |
public AnnounceCommand |
init(string eventName, [boolean copyEventArgs="true"], [string moduleName=""])
Used by the framework for initialization. |
public boolean |
execute(Event event, EventContext eventContext)
Executes the command. |
private string |
getEventName()
|
private string |
getModuleName()
|
private boolean |
isCopyEventArgs()
|
private void |
setCopyEventArgs([boolean copyEventArgs="true"])
|
private void |
setEventName(string eventName)
|
private void |
setModuleName(string moduleName)
|
| Methods inherited from framework.Command |
setParameter,
getParameter,
setParameters
|
| Method Detail |
public boolean execute(Event event, EventContext eventContext)
Event eventEventContext eventContext<cffunction name="execute" access="public" returntype="boolean" output="false" hint="Executes the command."> <cfargument name="event" type="MachII.framework.Event" required="true" /> <cfargument name="eventContext" type="MachII.framework.EventContext" required="true" /> <cfset var eventArgs = StructNew() /> <cfif isCopyEventArgs()> <cfset eventArgs = arguments.event.getArgs() /> </cfif> <cfset arguments.eventContext.announceEvent(getEventName(), eventArgs, getModuleName()) /> <cfreturn true /> </cffunction>
private string getEventName()
<cffunction name="getEventName" access="private" returntype="string" output="false"> <cfreturn variables.eventName /> </cffunction>
private string getModuleName()
<cffunction name="getModuleName" access="private" returntype="string" output="false"> <cfreturn variables.moduleName /> </cffunction>
public AnnounceCommand init(string eventName, [boolean copyEventArgs="true"], [string moduleName=""])
string eventName[boolean copyEventArgs="true"][string moduleName=""]<cffunction name="init" access="public" returntype="AnnounceCommand" output="false" hint="Used by the framework for initialization."> <cfargument name="eventName" type="string" required="true" /> <cfargument name="copyEventArgs" type="boolean" required="false" default="true" /> <cfargument name="moduleName" type="string" required="false" default="" /> <cfset setEventName(arguments.eventName) /> <cfset setCopyEventArgs(arguments.copyEventArgs) /> <cfset setModuleName(arguments.moduleName) /> <cfreturn this /> </cffunction>
private boolean isCopyEventArgs()
<cffunction name="isCopyEventArgs" access="private" returntype="boolean" output="false"> <cfreturn variables.copyEventArgs /> </cffunction>
private void setCopyEventArgs([boolean copyEventArgs="true"])
[boolean copyEventArgs="true"]<cffunction name="setCopyEventArgs" access="private" returntype="void" output="false"> <cfargument name="copyEventArgs" type="boolean" required="false" default="true" /> <cfset variables.copyEventArgs = arguments.copyEventArgs /> </cffunction>
private void setEventName(string eventName)
string eventName<cffunction name="setEventName" access="private" returntype="void" output="false"> <cfargument name="eventName" type="string" required="true" /> <cfset variables.eventName = arguments.eventName /> </cffunction>
private void setModuleName(string moduleName)
string moduleName<cffunction name="setModuleName" access="private" returntype="void" output="false"> <cfargument name="moduleName" type="string" required="true" /> <cfset variables.moduleName = arguments.moduleName /> </cffunction>
<!---
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: Ben Edwards (ben@ben-edwards.com)
$Id: AnnounceCommand.cfc 482 2007-09-05 02:07:07Z pfarrell $
Created version: 1.0.0
Updated version: 1.5.0
Notes:
--->
<cfcomponent
displayname="AnnounceCommand"
extends="MachII.framework.Command"
output="false"
hint="An Command for announcing an event.">
<!---
PROPERTIES
--->
<cfset variables.eventName = "" />
<cfset variables.copyEventArgs = true />
<cfset variables.moduleName = "" />
<!---
INITIALIZATION / CONFIGURATION
--->
<cffunction name="init" access="public" returntype="AnnounceCommand" output="false"
hint="Used by the framework for initialization.">
<cfargument name="eventName" type="string" required="true" />
<cfargument name="copyEventArgs" type="boolean" required="false" default="true" />
<cfargument name="moduleName" type="string" required="false" default="" />
<cfset setEventName(arguments.eventName) />
<cfset setCopyEventArgs(arguments.copyEventArgs) />
<cfset setModuleName(arguments.moduleName) />
<cfreturn this />
</cffunction>
<!---
PUBLIC FUNCTIONS
--->
<cffunction name="execute" access="public" returntype="boolean" output="false"
hint="Executes the command.">
<cfargument name="event" type="MachII.framework.Event" required="true" />
<cfargument name="eventContext" type="MachII.framework.EventContext" required="true" />
<cfset var eventArgs = StructNew() />
<cfif isCopyEventArgs()>
<cfset eventArgs = arguments.event.getArgs() />
</cfif>
<cfset arguments.eventContext.announceEvent(getEventName(), eventArgs, getModuleName()) />
<cfreturn true />
</cffunction>
<!---
ACCESSORS
--->
<cffunction name="setEventName" access="private" returntype="void" output="false">
<cfargument name="eventName" type="string" required="true" />
<cfset variables.eventName = arguments.eventName />
</cffunction>
<cffunction name="getEventName" access="private" returntype="string" output="false">
<cfreturn variables.eventName />
</cffunction>
<cffunction name="setCopyEventArgs" access="private" returntype="void" output="false">
<cfargument name="copyEventArgs" type="boolean" required="false" default="true" />
<cfset variables.copyEventArgs = arguments.copyEventArgs />
</cffunction>
<cffunction name="isCopyEventArgs" access="private" returntype="boolean" output="false">
<cfreturn variables.copyEventArgs />
</cffunction>
<cffunction name="setModuleName" access="private" returntype="void" output="false">
<cfargument name="moduleName" type="string" required="true" />
<cfset variables.moduleName = arguments.moduleName />
</cffunction>
<cffunction name="getModuleName" access="private" returntype="string" output="false">
<cfreturn variables.moduleName />
</cffunction>
</cfcomponent>