Yes, please feel free to use the content here for the wiki.
So basically, to set a global plugin like web app firewall that needs to run
first, when runParent is set to "none" in module, I would create a place
holder plugin in the module config. Then, in the base config, during module
declaration, "replace/inject" the place holder with a base plugin.

runOnChild would have been easier, but from your answer I understand it
won't work as plugins run in the order they are defined.

I'm new to Mach-II and trying to get my head around the whole project setup
and structure. I'm working on creating a sample app with basic setup of a
back-end (admin) and front-end. I will e-mail you that in few days for
review and if appropriate you can use that for wiki as well.

I have another question about a different issue, but I will send a new
message so it's easier to track.


On Mon, Sep 14, 2009 at 1:22 PM, Peter J. Farrell <[email protected]> wrote:

>  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/
-~----------~----~----~----~------~----~------~--~---

Reply via email to