Differences between revisions 3 and 4
Revision 3 as of 2005-03-22 05:48:35
Size: 2060
Editor: anonymous
Comment: missing edit-log entry for this revision
Revision 4 as of 2009-09-20 23:12:44
Size: 2060
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

StrutsCatalog: Segment applications

Larger applications can often benefit from being organized into logical "segments" and using a separate set of configuration files for each segment. As of Struts 1.1. final, all Struts configuration files can be expressed as a comma-delimited list. Segments provide most of the benefits of using multiple modules without making it harder to share resources within the application.

The same general strategy is used for modules and segments. Each segment is given it's own "prefix", which acts like a namespace. The segment prefix is then made part of the  ActionMappings  paths and Application Resource entries. Separate configuration files can be used for each segment (without using modules).

struts-config-segment1.xml   <action path="/segment1/MyAction" ...  

struts-config-segment2.xml   <action path="/segment2/MyAction" ...  

tiles-def-segment1.xml   <definition name=".segment1.MyDef"  

tiles-def-segment2.xml   <definition name=".segment2.MyDef"  

(Likewise for validator configurations.)

application.properties {{{ segment1.property = ...

  • segment2.property = ... }}}

Modules are useful when several teams are working independently, but if the application are being managed by a single, cooperate team, defining your own segments can be simplier and more effective.

For smaller applications, segments are also useful for creating a "command structure" format for your ActionMappings. It's been said that query strings are the universal command line. This is especially true of ActionMappings, which usually lead to some type of dynamic operation. Since ActionMappings can be named in any convenient manner, you can segment them after the command structure (which may also be embedded in the menu system). A set of mappings for a file management system might read "file/Save", "file/Open", and "file/Exit", regardless of how the source tree or JSP tree is organized.

-- TedHusted


Comments:

StrutsCatalogSegmentApplications (last edited 2009-09-20 23:12:44 by localhost)