Answers inline below. Would you mind if I used your question and sample use case for entry on the wiki?
Sumit Verma said the following on 09/12/2009 11:12 PM: > Hi Peter, > > Is there a way to set runParent attribute to individual plugin? No, plugins are a cross-cutting concern and it would be imprudent (and really messy) to allow some plugins to run in certain circumstances and not in others. However, there is a solution to the use case you describe. > Here is a simple use case: > > • A web application firewall set up as a base plugin should by default > process each request, even inside modules. > > • A session handling plugin should only run on the base application > (front end). > > • An access check / security plugin should run only inside module > (let's say when admin is set up as a module). > > So, in this case if we set runParent to none inside the admin module, > it will disable session handling (good), but it will also disable web > app firewall (bad). > > I know we can always run the web app firewall in Application.cfc and > it will run on each request, but I'm sure there will be other cases > where we would like to use the plugin. > > I think it might be good to have an attribute called > runOnChild="before|after|none|always" that can be set on individual > plugin. First, there is a known defect right now that stopping the solution I will outline below from working: http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/ticket/194 This will be fixed in Mach-II 1.8 soon (it affects 1.5, 1.6.0 and 1.6.1). Basically, you will set the runParent="none" and pull in the plugin you want using the overrideAction and/or mapping attribute. These attributes are documented in the XML Configuration File reference entry on the wiki. Snip in module: <plugins runParent="none"> <plugin name="security" type="MachII.plugins.SimplePlugin /> ... other plugins... </plugins> In parent using override XML when defining the module: <module name="foo" file="./path/to/mach-ii_foo.xml"> <mach-ii> <plugins> <plugin name="security" overrideAction="addFromParent"/> </plugins> </mach-ii> </module> This adds the "security" plugin from the parent into the module with the name of "security". Remember that plugins are run in the order they are defined, since I want my "security" plugin to be run first -- I added a placeholder in the module to replace. Otherwise you could do away with that "SimplePlugin" placeholder and the override XML will append the plugin -- therefore the security plugin would be the last plugin to run in the module. Of course, you still have to have the "security" plugin defined in the base application so you can use the overrideAction to add it to the module. If you want to use a plugin with different name in the parent, that is fine but you need to use the mapping attribute: Snip in module: <plugins runParent="none"> <plugin name="security" type="MachII.plugins.SimplePlugin /> ... other plugins... </plugins> In parent using override XML: <module name="foo" file="./path/to/mach-ii_foo.xml"> <mach-ii> <plugins> <plugin name="security" overrideAction="addFromParent" mapping="crazyFooBarName" /> </plugins> </mach-ii> </module> This pulls in a plugin named "crazyFooBarName" from the parent into the module and replaces "security" plugin placeholder. Of course, you still have to a plugin named "crazyFooBarName" in the base application (parent). Again, there is a known ticket right now that stops this from working right now and this will be fixed soon. Best, .Peter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to Mach-II for CFML list. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/mach-ii-for-coldfusion?hl=en SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/ Wiki / Documentation / Tickets: http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/ -~----------~----~----~----~------~----~------~--~---
