-
Notifications
You must be signed in to change notification settings - Fork 24
Mach II 1.9 Wildcard Include Support
By Peter J. Farrell - Lead Developer (peter@…)
This is a working document and is subject to change.
Feel free to comment at the bottom of this specification and feedback process document (M2SFP).
Our mission in Mach-II 1.9 - "Integrity" is to continue creating new features that aid you in your daily development. During the development of Mach-II 1.9 - "Integrity", we've adapted a motto by Richard Buckminster "Bucky" Fuller (1895-1983) -- "Integrity is the essence of everything successful." Team Mach-II feels that this statement embodies our mindset when developing this version of the framework.
In Mach-II 1.5, we introduced the new <include> tag that allows you to specify other Mach-II XML configuration files to include with your base config file. This allows you to break up your configuration file into logical parts which makes maintenance of your application easier. However for each XML include you create, you must define it in your base XML file. This can lead to developer errors such forgetting to define a new include. We want to introduce ANT-style directory and file wildcards in Mach-II "Integrity" (1.9) which would allow you to use a pattern that automatically selects and loads all XML includes that match your pattern.
We based the pattern matching engine off the ANT-style wildcards. These wildcards works similar to regex, however there are only three operators to know and understand. Let's examine the available wildcards.
Wildcard | Description |
---|---|
* |
Matches zero or more characters. |
? |
Matches exactly one character. |
** |
Matches zero or more directories. |
Wildcards would allow you to include all include files in a directory (or directories) that match the pattern. This is compatible with the relative path support (e.g. ./
and ../
) available as of Mach-II 1.5. An interesting byproduct of this improvement you can use includes to auto-register widgets or sections of an application by just dropping in the configuration file. This could be used to drop in user add-ons (like widgets or add-ons ) to your applications.
Pattern <include file="./mach-ii_*.xml" />
Matches:
mach-ii_account.xml
mach-ii_dashboard.xml
mach-ii_1.xml
mach-ii_a.xml
Does Not Match:
mach-ii.xml
N.B. Base xml config file is located in /myApp/config/
so the ./
is relative from this location
Pattern <include file="/myApp/addOns/**/config/mach-ii.xml" />
Matches:
/myApp/addOns/widgetA/config/mach-ii.xml
/myApp/addOns/widgetB/config/mach-ii.xml
Does Not Match:
/myApp/addOns/widgetA/config/mach-ii_other.xml
/myApp/addOns/widgetB/mach-ii.xml
Pattern <include file="./mach-ii_?.xml" />
Matches:
mach-ii_1.xml
mach-ii_a.xml
Does Not Match:
mach-ii_account.xml
mach-ii_dashboard.xml