A Java-based pattern framework is provided to facilitate pattern design and implementation. The framework supports a set of mechanisms for default pattern behavior and a set of extensions for specific pattern implementation.
This basic code is known as the implementation model and includes a pattern library, the pattern body, and pattern parameters. The framework also provides commonly used functions for the author to use by extending the interfaces and abstract classes defined in a pattern service. The basic default code is added when the pattern author creates the pattern plug-in project. The pattern library, essential to pattern design, is created during this process.
The author completes the implementation model by adding one or more patterns and their template parameters to the library. This is accomplished by using GUI-based tools. The implementation model is regenerated each time the pattern author modifies the library model. Patterns are represented by Java™ classes and nested within these classes is a class for each parameter. Each parameter has empty expansion methods to address the addition or removal of an argument.
Dependencies are used to control the expansion sequence when one parameter requires the values of another to expand. A dependency class is nested in the appropriate parameter class and includes three update methods. Code added to the update methods addresses conditions that may occur in pattern application: adding, removing, or maintaining an argument.
The expansion and update methods are known as hot spots. The pattern author supplies the appropriate code in the hot spots that will invoke the required behaviors when the pattern is applied. Hot spots are clearly annotated in the default Java code with TODO comments. The default code is marked with Javadoc @generated tags. The @generated tags must be removed if the default code is modified or the modifications are overwritten when the implementation model is regenerated.
Pattern framework
The pattern framework provides support for the base classes that are extended by the standard pattern implementation model that includes the pattern library, the contained patterns, and the pattern parameters. The framework promotes consistency in pattern design.Pattern definitions
Pattern definitions include all of the specific components needed to determine the behavior of a pattern.Pattern instantiations
Pattern instantiation is the initial step of the apply pattern process and results in the creation of an instance of the pattern definition in the pattern's target model. The pattern instance element is identified by the keyword Pattern Instance.Pattern project contents
The pattern plug-in is created in the Eclipse Plug-in Development Environment by using a pattern template that adds the pattern required artifacts to the project.Pattern expansion
To implement the intended pattern behaviors when the pattern is applied, pattern expansion code is provided by the pattern author for each parameter and is invoked when that parameter is bound. Thus, expansion occurs on an incremental basis.
Parent topic: Authoring patterns
Related tasks
Defining expansion methods
Defining update methods
Adding dependencies to parameters