100 likes | 212 Views
"Plug it in, Plug it in" Glade Tidings of Plugins in Fusebox 4. John Quarto-vonTivadar Future Now, Inc johnq@futurenowinc.com. What is a Plugin?. developers often need to extend the functionality of Fusebox the real question: is this for a particular Fusebox app or all Fusebox apps?
E N D
"Plug it in, Plug it in"Glade Tidings of Plugins in Fusebox 4 John Quarto-vonTivadar Future Now, Inc johnq@futurenowinc.com
What is a Plugin? • developers often need to extend the functionality of Fusebox • the real question: is this for a particular Fusebox app or all Fusebox apps? • for particular Fusebox, solution is a fuseaction and its associated fuses • for all Fusebox apps, solution is core mod • Plugins: middle ground. Non app specific functionality yet not common to all Fuseboxes
Thought Experiment #1 • suppose users are required to log in to a app • option: modify the core file • what if next app doesn't need authentication? • "log in" is a business rule of the project, • business rules have nothing to do with core files • Therefore we need a fuseaction (and possibly a circuit?)
Thought Experiment #2 • suppose related login fuseactions are grouped together in a circuit "Security" • how does FB know what to do with a circuit? • how circuits (and their FAs) are accessed are not specific to a particular app – all FB apps need to be able to access circuits • a general requirement requires an abstract solution
Thought Experiment #3 • suppose when an exception occurs an email should be sent to the administrator • Two parts: • part 1: send an email . • A business rule! • should be a fuseaction • not all apps send emails • part 2: handle an exception • all apps need some way to handle exceptions • what we need is ….. a Plugin!
Therefore… • Plugins occupy the solution space between a functional requirement for your app versus available functionality for every app
Plugin Points • preProcess • preFuseaction • postFuseaction • fuseactionException • postProcess • processError
Now you try: • suppose you wanted to load a file "Constants" each request – where would it go? • You decide against normally logging procedures and instead want to write your own – where would this go? • what about users who request a non-existant fuseaction? how would that be handled? • You decide to check the permissions accorded a user before executing some functionality – where would this go?
Example Plugin section of Fusebox.xml <plugins> <phase name="preProcess"> <plugin name="GlobalSettings" template="Globals.cfm" /> </phase> <plugins>
Sharing Plugins • If plugins are properly written, they can work with all FB4 apps no matter what other plugins may also be in use • visit www.fusebox.org for a growing library of publicly available plugins