| 135 | | <cfset pluginType = pluginNodes[i].XmlAttributes["type"] /> |
| 136 | | |
| 137 | | <!--- Set the Plugin's parameters. ---> |
| 138 | | <cfset pluginParams = StructNew() /> |
| 139 | | |
| 140 | | <!--- For each plugin, parse all the parameters ---> |
| 141 | | <cfif StructKeyExists(pluginNodes[i], "parameters")> |
| 142 | | <cfset paramNodes = pluginNodes[i].parameters.xmlChildren /> |
| 143 | | <cfloop from="1" to="#ArrayLen(paramNodes)#" index="j"> |
| 144 | | <cfset paramName = paramNodes[j].XmlAttributes["name"] /> |
| 145 | | <cftry> |
| 146 | | <cfset paramValue = utils.recurseComplexValues(paramNodes[j]) /> |
| 147 | | <cfcatch type="any"> |
| 148 | | <cfthrow type="MachII.framework.InvalidParameterXml" |
| 149 | | message="Xml parsing error for the parameter named '#paramName#' for plugin '#pluginName#' in module '#getAppManager().getModuleName()#'." /> |
| 150 | | </cfcatch> |
| 151 | | </cftry> |
| 152 | | <cfset pluginParams[paramName] = paramValue /> |
| 153 | | </cfloop> |
| | 137 | |
| | 138 | <!--- Override XML for Modules ---> |
| | 139 | <cfif hasParent AND arguments.override AND StructKeyExists(pluginNodes[i].xmlAttributes, "overrideAction")> |
| | 140 | <!--- Check for a mapping ---> |
| | 141 | <cfif StructKeyExists(pluginNodes[i].xmlAttributes, "mapping")> |
| | 142 | <cfset mapping = pluginNodes[i].xmlAttributes["mapping"] /> |
| | 143 | <cfelse> |
| | 144 | <cfset mapping = pluginName /> |
| | 145 | </cfif> |
| | 146 | |
| | 147 | <!--- Check if parent has event handler with the mapping name ---> |
| | 148 | <cfif NOT getParent().isPluginDefined(mapping)> |
| | 149 | <cfthrow type="MachII.framework.overridePluginNotDefined" |
| | 150 | message="An plugin named '#mapping#' cannot be found in the parent plugin manager for the override named '#pluginName#' in module '#getAppManager().getModuleName()#'." /> |
| | 151 | </cfif> |
| | 152 | |
| | 153 | <cfset addPlugin(pluginName, getParent().getPlugin(mapping), arguments.override) /> |
| | 154 | <!--- General XML setup ---> |
| | 155 | <cfelse> |
| | 156 | <!--- Set the Plugin's type and parameters. ---> |
| | 157 | <cfset pluginType = pluginNodes[i].XmlAttributes["type"] /> |
| | 158 | <cfset pluginParams = StructNew() /> |
| | 159 | |
| | 160 | <!--- For each plugin, parse all the parameters ---> |
| | 161 | <cfif StructKeyExists(pluginNodes[i], "parameters")> |
| | 162 | <cfset paramNodes = pluginNodes[i].parameters.xmlChildren /> |
| | 163 | <cfloop from="1" to="#ArrayLen(paramNodes)#" index="j"> |
| | 164 | <cfset paramName = paramNodes[j].XmlAttributes["name"] /> |
| | 165 | <cftry> |
| | 166 | <cfset paramValue = utils.recurseComplexValues(paramNodes[j]) /> |
| | 167 | <cfcatch type="any"> |
| | 168 | <cfthrow type="MachII.framework.InvalidParameterXml" |
| | 169 | message="Xml parsing error for the parameter named '#paramName#' for plugin '#pluginName#' in module '#getAppManager().getModuleName()#'." /> |
| | 170 | </cfcatch> |
| | 171 | </cftry> |
| | 172 | <cfset pluginParams[paramName] = paramValue /> |
| | 173 | </cfloop> |
| | 174 | </cfif> |
| | 175 | |
| | 176 | <cftry> |
| | 177 | <!--- Do not method chain the init() on the instantiation |
| | 178 | or objects that have their init() overridden will |
| | 179 | cause the variable the object is assigned to will |
| | 180 | be deleted if init() returns void ---> |
| | 181 | <cfset plugin = CreateObject("component", pluginType) /> |
| | 182 | <cfset plugin.init(getAppManager(), pluginParams) /> |
| | 183 | |
| | 184 | <cfcatch type="any"> |
| | 185 | <cfif StructKeyExists(cfcatch, "missingFileName") AND cfcatch.missingFileName EQ pluginType> |
| | 186 | <cfthrow type="MachII.framework.CannotFindPlugin" |
| | 187 | message="Cannot find a CFC with the type of '#pluginType#' for the plugin named '#pluginName#' in module named '#getAppManager().getModuleName()#'." |
| | 188 | detail="Please check that a plugin exists and that there is not a misconfiguration in the XML configuration file." /> |
| | 189 | <cfelse> |
| | 190 | <cfthrow type="MachII.framework.PluginSyntaxException" |
| | 191 | message="Mach-II could not register a plugin with type of '#pluginType#' for the plugin named '#pluginName#' in module named '#getAppManager().getModuleName()#'." |
| | 192 | detail="#getAppManager().getUtils().buildMessageFromCfCatch(cfcatch)#" /> |
| | 193 | </cfif> |
| | 194 | </cfcatch> |
| | 195 | </cftry> |
| | 196 | |
| | 197 | <cfset baseProxy = CreateObject("component", "MachII.framework.BaseProxy").init(plugin, pluginType, pluginParams) /> |
| | 198 | <cfset plugin.setProxy(baseProxy) /> |
| | 199 | |
| | 200 | <cfset addPlugin(pluginName, plugin, arguments.override) /> |
| 155 | | |
| 156 | | <cftry> |
| 157 | | <!--- Do not method chain the init() on the instantiation |
| 158 | | or objects that have their init() overridden will |
| 159 | | cause the variable the object is assigned to will |
| 160 | | be deleted if init() returns void ---> |
| 161 | | <cfset plugin = CreateObject("component", pluginType) /> |
| 162 | | <cfset plugin.init(getAppManager(), pluginParams) /> |
| 163 | | |
| 164 | | <cfcatch type="any"> |
| 165 | | <cfif StructKeyExists(cfcatch, "missingFileName") AND cfcatch.missingFileName EQ pluginType> |
| 166 | | <cfthrow type="MachII.framework.CannotFindPlugin" |
| 167 | | message="Cannot find a CFC with the type of '#pluginType#' for the plugin named '#pluginName#' in module named '#getAppManager().getModuleName()#'." |
| 168 | | detail="Please check that a plugin exists and that there is not a misconfiguration in the XML configuration file." /> |
| 169 | | <cfelse> |
| 170 | | <cfthrow type="MachII.framework.PluginSyntaxException" |
| 171 | | message="Mach-II could not register a plugin with type of '#pluginType#' for the plugin named '#pluginName#' in module named '#getAppManager().getModuleName()#'." |
| 172 | | detail="#getAppManager().getUtils().buildMessageFromCfCatch(cfcatch)#" /> |
| 173 | | </cfif> |
| 174 | | </cfcatch> |
| 175 | | </cftry> |
| 176 | | |
| 177 | | <cfset baseProxy = CreateObject("component", "MachII.framework.BaseProxy").init(plugin, pluginType, pluginParams) /> |
| 178 | | <cfset plugin.setProxy(baseProxy) /> |
| 179 | | |
| 180 | | <cfset addPlugin(pluginName, plugin, arguments.override) /> |