root / framework / trunk / extensions / lexicon / reactor / plugin.cfm

Revision 275, 1.6 kB (checked in by scorfield, 2 years ago)

Nathan Strutz wrote this lexicon.

  • Property svn:executable set to *
Line 
1<cfscript>
2        // @ Author Nathan Strutz
3        // Creates a plugin of a given type from Reactor
4        // usage:
5        // 1. add the lexicon declaration to your circuit file:
6        //    <circuit xmlns:reactor="reactor/">
7        // 2. use the verb in a fuseaction:
8        //    <reactor:plugin alias="User" returnvariable="variables.userPlugin" />
9        //
10        if (fb_.verbInfo.executionMode is "start") {
11
12                // alias is required
13                if (not structKeyExists(fb_.verbInfo.attributes,"alias")) {
14                        fb_throw("fusebox.badGrammar.requiredAttributeMissing",
15                                                "Required attribute is missing",
16                                                "The attribute 'alias' is required, for a 'plugin' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
17                }
18                // plugin is required
19                if (not structKeyExists(fb_.verbInfo.attributes,"plugin")) {
20                        fb_throw("fusebox.badGrammar.requiredAttributeMissing",
21                                                "Required attribute is missing",
22                                                "The attribute 'plugin' is required, for a 'plugin' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
23                }
24                // returnvariable is required
25                if (not structKeyExists(fb_.verbInfo.attributes,"returnvariable")) {
26                        fb_throw("fusebox.badGrammar.requiredAttributeMissing",
27                                                "Required attribute is missing",
28                                                "The attribute 'returnvariable' is required, for a 'plugin' verb in fuseaction #fb_.verbInfo.circuit#.#fb_.verbInfo.fuseaction#.");
29                }
30
31                fb_appendLine('<cfset #fb_.verbInfo.attributes.returnvariable# = myFusebox.getApplication().getApplicationData().reactor.createPlugin("#fb_.verbInfo.attributes.alias#", "#fb_.verbInfo.attributes#") />');
32
33                //
34        } else {
35                //
36                // end mode - do nothing
37        }
38</cfscript>
Note: See TracBrowser for help on using the browser.