Apache Struts 2 Documentation > Home > Guides > Contributors Guide > Requirements > Use Cases > Zero Configuration Scanning
Added by Ted Husted, last edited by Ted Husted on Nov 14, 2006  (view change) show comment

Narrative

One of Zaphod's heads is allergic to XML. Rather than embed metadata in a configuration file, Zaphod annotates his POJO actions instead. The framework scans the designated packages for objects that implement Action or have names that end with "Action". An action mappings is automatically created and registered for each matching class, based on the annotations.

Goal

Goal  
Level   (User Goal, Summary, Subfunction)
Trigger  
Primary Actor  

Main Success Scenario (MSS)

Step Action
1 System loads FilterDispatcher through web.xml, which includes actionPackages parameter
2 FilterDispatcher initializes a Dispatcher, passing along the actionPackages parameter
3 Dispatcher initializes ClasspathConfigurationProvider to hold one or more Configuration Providers
4 Dispatcher adds to the ConfigurationManager object a ClasspathConfigurationProvider to process the actionPackages.
5 (someone) calls loadpackages on ClasspathConfigurationProvider
6 loadpackages utilizes the XWork ResolverUtil to find classes that implement Action or have names suffixed with "Action" in the listed packages. Each found class is added to a set (if not already present), and each class in the set is passed to the processActionClass helper method.
7 processActionClass ascertains the namespace, captures any ParentPackage or Results annotations, and creates an ActionConfig, setting the action name, package name, and results.

Extensions

Step Branching Action
   
7a Action suffix
.1 The action name is truncated before any Action suffix.
   
7b Embedded /
.1 If action name contains a / character, then the first character after the last / is forced to lowercase.
   
7c On the fly results
.1 Results are wrapped in a ResultMap class that processes the Action class annotations on initialization, creating any new result configuration objects as needed.

Preconditions and Guarantees

Preconditions  
Minimal Guarantees  
Success Guarantees  

Stakeholders and Interests

Stakeholder Interest
   

Variations

Step Variation