Fusebox XML files

Probably the most noticeable change to Fusebox 4 from previous versions was the introduction of XML files. Fusebox 4 uses XML files for two purposes: to provide configuration and initialization information for the overall application (the fusebox.xml file) and to provide that same information for individual circuits (the circuit.xml file). Fusebox 5 uses the same XML files with some minor changes.

XML was selected as the markup language to create these files for several reasons. First, it facilitates Fusebox's parsing phase, where the configuration files are read and fuseaction code files are generated. Second, it helps application architects create language-neutral Fusebox applications.

Since XML can be used by any programming language, the same Fusebox XML configuration files can be used in many environments. Any language that has a Fusebox parsing system built for it could use the XML files. Currently there are parsers for ColdFusion and PHP, but other languages such as ASP.NET and Java can be supported.

Fusebox.xml defined

Fusebox.xml is comprised of 4 key sections which define your fusebox application. This single file is essentially the legend to your entire fusebox application.

The <circuits> section

Circuits are the logical collections of actions, or fuseactions. Each circuit is defined with a <circuit> tag, which defines the circuits alias, path to its location, parent, and its relativity to the application root.

<circuits>
<circuit alias="c" path="controller/"/> <!-- default -->
<circuit alias="m" path="/sharedcircuits/model/" relative="false"/> <!-- absolute / mapped path -->
<circuit alias="v" path="views/" relative="true"/> <!-- explicit relative path -->
</circuits>

Each circuit in a Fusebox Application carries its own configuration file, named circuit.xml, which defines the fuseactions that exist within the circuit. The circuit.xml file may also contain circuit specific settings which can override the fusebox.xml parameter settings.

The <classes> section

Classes are aliases for objects (CFC's) to be used in the application. Any Object that can be used with the <cfobject> tag can be aliased here. This allows the alias name to be referenced using the <invoke> and <instantiate> built-in verbs.

The <parameters> section

The parameters section contains several settings controlling how your fusebox application will behave.

The parameters section of the fusebox.xml file is described more in detail in the Parameters Element page.

The <globalfuseactions> section

This section specifies which run, or fire in combination with the explicitly called fuseaction for each page request.

<globalfuseactions>
<appinit>
<!-- Run on Application initialization -->
</appinit>

<preprocess>
<!-- Run before every requested fuseaction -->
</preprocess>

<postprocess>
<!-- Run after every requested fuseaction -->
</postprocess>
</globalfuseactions>

The <pluginssection>

Plugins are similar to Global Fuseactions with one important exception: Plugins are comprised of code that is not contained within a fuseaction or circuit in the framework application.

There are six defined plugin points as follows:

<plugins>
<phase name="preProcess">
<!-- Runs before all fusebox processes-->
</phase>

<phase name="preFuseaction">
<!-- Runs before each fuseaction -->
</phase>

<phase name="postFuseaction">
<!-- Runs after each fuseaction -->
</phase>

<phase name="fuseactionException">
<!-- Runs on exception within the logic of a fuse -->
</phase>

<phase name="postProcess">
<!-- Runs after all fusebox processes -->
</phase>

<phase name="processError">
<!-- Runs on exception within the Fusebox framework itself -->
</phase>
</plugins>

For more information about Fusebox Plugins, see Fusebox Plugins.