| 1 | <!--- |
|---|
| 2 | Copyright 2006-2007 TeraTech, Inc. http://teratech.com/ |
|---|
| 3 | |
|---|
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
|---|
| 5 | you may not use this file except in compliance with the License. |
|---|
| 6 | You may obtain a copy of the License at |
|---|
| 7 | |
|---|
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
|---|
| 9 | |
|---|
| 10 | Unless required by applicable law or agreed to in writing, software |
|---|
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
|---|
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|---|
| 13 | See the License for the specific language governing permissions and |
|---|
| 14 | limitations under the License. |
|---|
| 15 | ---> |
|---|
| 16 | <cfcomponent output="false"> |
|---|
| 17 | |
|---|
| 18 | <cffunction name="__executeDynamicDo" returntype="string" access="public" output="true" |
|---|
| 19 | hint="I execute a dynamically generated do fuseaction."> |
|---|
| 20 | <cfargument name="parsedFileInfo" type="struct" required="true" |
|---|
| 21 | hint="I am the information about the parsed file." /> |
|---|
| 22 | <cfargument name="myFusebox" type="myFusebox" required="true" |
|---|
| 23 | hint="I am the myFusebox data structure." /> |
|---|
| 24 | <cfargument name="returnOutput" type="boolean" required="true" |
|---|
| 25 | hint="I indicate whether to display output (false) or return the output (true)." /> |
|---|
| 26 | |
|---|
| 27 | <cfset var output = "" /> |
|---|
| 28 | |
|---|
| 29 | <cfif structKeyExists(request.__fusebox.fuseactionsDone,arguments.parsedFileInfo.parsedFile)> |
|---|
| 30 | <cfthrow type="fusebox.badGrammar.recursiveDo" |
|---|
| 31 | message="Recursive do is illegal" |
|---|
| 32 | detail="An attempt was made to execute a dynamic fuseaction '#arguments.parsedFileInfo.parsedFile#' that is already being executed, in fuseaction #arguments.myFusebox.getCurrentCircuit().getAlias()#.#arguments.myFusebox.getCurrentFuseaction().getName()#." /> |
|---|
| 33 | </cfif> |
|---|
| 34 | <cfset request.__fusebox.fuseactionsDone[arguments.parsedFileInfo.parsedFile] = true /> |
|---|
| 35 | |
|---|
| 36 | <cfset structAppend(variables,myFusebox.variables(),true) /> |
|---|
| 37 | |
|---|
| 38 | <!--- |
|---|
| 39 | readonly lock protects against including the parsed file while |
|---|
| 40 | another threading is writing it... |
|---|
| 41 | ---> |
|---|
| 42 | <cflock name="#arguments.parsedFileInfo.lockName#" type="readonly" timeout="30"> |
|---|
| 43 | <cfif arguments.returnOutput> |
|---|
| 44 | <cfsavecontent variable="output"><cfinclude template="#arguments.parsedFileInfo.parsedFile#" /></cfsavecontent> |
|---|
| 45 | <cfelse> |
|---|
| 46 | <cfinclude template="#arguments.parsedFileInfo.parsedFile#" /> |
|---|
| 47 | </cfif> |
|---|
| 48 | </cflock> |
|---|
| 49 | |
|---|
| 50 | <cfset structAppend(myFusebox.variables(),variables,true) /> |
|---|
| 51 | |
|---|
| 52 | <cfset structDelete(request.__fusebox.fuseactionsDone,arguments.parsedFileInfo.parsedFile) /> |
|---|
| 53 | |
|---|
| 54 | <cfreturn output /> |
|---|
| 55 | |
|---|
| 56 | </cffunction> |
|---|
| 57 | |
|---|
| 58 | </cfcomponent> |
|---|