Defining update methods

A pattern can contain multiple parameters where the argument for one parameter, the supplier parameter, is used to calculate the values for dependent (client) parameters. When the user specifies a valid argument for a supplier parameter, the update methods are called to recompute the dependent client parameters.

You add a dependency relationship by using the New Pattern wizard when adding a new pattern or by using the Properties view from the Pattern Authoring view. When added, the code for update hot spots methods is added to the pattern implementation model. The three types of update methods are generated only for the client parameter. Update methods are invoked for the following activities: addition of a supplier argument, removal of a supplier argument, and no change to the supplier argument when the pattern is reapplied.

Using update methods, you can suppress total or partial expansion of the client parameter until the required values are specified in the supplier parameters. The following code shows the update methods:


The expansion update method code for adding an argument.


The expansion update method code for removing an argument.


The expansion update method code for maintaining an argument value during reapply.

To assist you with your code design, refer to the resources available in the pattern online help for pattern framework and other API references. To open the references, click Reference > Modeler's reference > Feature reference > Extensibility reference, expand either API reference or Extention Points Reference and then click one of the Patterns topics.

To add code to the update methods:

  1. In the Pattern Authoring view, double-click the client parameter to locate the parameter's code in the Java™ editor.
  2. Scroll down past the dependency class and its constructor to locate the update methods.
  3. Replace the TODO comments in the update methods with the code that performs the required behaviors to address addition, removal, and maintenance of an argument in the pattern instance.
  4. Remove the @generated tag from any method that you modify to prohibit the pattern authoring tool from regenerating and removing your code.
Note: To better understand pattern behavior, you can practice applying patterns by using the sample patterns. You can load the sample patterns by clicking Help > Samples Gallery, expand Technology samples, expand Patterns, and click Patterns to apply. In the Patterns to apply pane, click Import the sample. To better understand how to create patterns, you can import the example patterns by clicking File > New > Other, in the New window, expand Examples, expand UML Modeler Plug-ins, and click Pattern Library Examples.
Related concepts
Pattern code and support files
Pattern expansion
Related tasks
Defining expansion methods
Regenerating source code
Regenerating pattern definitions
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.