IBM WebSphere Developer Technical Journal: Get started with model-driven development using the Design Pattern Toolkit

Discover the practicality and benefits of model-driven development, and the ease of creating pattern templates with the Design Pattern Toolkit, a tool that can help you speed up development through the use of transformations that capture your best (or current) practices for application development. Learn the fundamentals of using the toolkit, as well as how you can use it to generate complex systems and even to support an asset-based business.

Share:

Roland Barcia, Certified IT Specialist, EMC

Roland Barcia is a Certified IT Specialist for IBM Software Services for WebSphere in the New York/New Jersey Metro area. He is a co-author of IBM WebSphere: Deployment and Advanced Configuration. For more information on Roland, visit his Web site.


developerWorks Master author level
        2

Chris Gerken (cgerken@us.ibm.com), Senior Software Engineer, EMC

Chris Gerken is a member of the Asset Reuse Enablement Team within the IBM Software Services for WebSphere group. He created and wrote the Design Pattern Toolkit.



26 July 2006

Also available in

From the IBM WebSphere Developer Technical Journal.

Introduction

When most people think of model-driven development, the first thing that comes to mind is coding in some type of UML model and generating artifacts from that model. However, that is not necessarily the case. Models exist in all shapes and sizes. A model is any artifact that drives generation or behavior.

Model-driven development has many goals:

  • Reduce the amount of time you spend developing mundane artifacts.
  • Maintain the minimal amount of information.
  • Maintain the model in a neutral fashion, enabling the possibility of generating multiple types of implementations and artifacts from the same model. For example, one should be able to generate a Web UI and Native GUI UI from the same model using different templates.

This article introduces model-driven development with the Design Pattern Toolkit, an Eclipse-enabled template engine for generating applications based on customizable, model-driven architecture transformations (and one of the driving technologies behind JET2, see Resources). We will introduce the basics of the code generation facility in the Design Pattern Toolkit (DPTK), and at the same time incorporate good design around code generation that leads to model-driven development (MDD). These design principles make DPTK more than a toy code generator; it is a fully featured model-driven development tool that can generate complex systems. This article will focus on the fundamentals of building pattern templates.

Visit IBM alphaWorks to learn more about or to download the Design Pattern Toolkit.


Pattern templates

Pattern authors in DPTK build pattern templates out of tags. These tags have special behaviors that access the model, execute logic, and perform various other tasks. The rich set of tags offers much functionality and, in fact, represents the basic building blocks needed to build arbitrarily complex MDD transformations. The main goal of a pattern template is to generate artifacts; however, as we will see in the next section, pattern templates can be used to do more.

For the purpose of understanding, let's look at the simple pattern template below:

Figure 1. Simple pattern template
Figure 1. Simple pattern template

This is a very simple view of DPTK:

  1. The pattern is applied against a simple XML model.
  2. The DPTK engine invokes a pattern template. The pattern template uses the DPTK tag language to replace dynamic portions.
  3. The final artifact is generated.

Generating a Java™ class out of a simple XML declaration is not exciting, but the intention is to give you a starting point to think about the flow. We will expand on this as we continue.


Model View Controller for code generation

Model View Controller (MVC) is a popular design pattern for building many different types of applications. For example, in Java EE, frameworks like JavaServer™ Faces and Struts specialize just in providing MVC design. MVC enables separation of concerns in an application where Model represents data and business logic, View represents how you view the data, and the Controller handles user input, model invocation, and view selection.

MVC is actually an excellent design pattern for building MDD solutions with the Design Pattern Toolkit. Consider Figure 2:

Figure 2. MVC as a design pattern
Figure 2. MVC as a design pattern

The DPTK tag library contains various tags that can be used to perform many tasks. As such, we can build well designed templates with specific roles. For example, the controller pattern template will generate the overall container of many artifacts and invoke various other templates, which in turn generate specific artifacts.

By going through the series of exercises that follow, you will be able to learn by example and see how to generate artifacts using the MVC design pattern. You can access the DPTK and download the sample materials for this article at the end.


Building pattern templates

With model-driven development, it is always best to have a target in mind. That is: manually build out the first case. This way you know what you want to generate. To begin, then, we will show you a sample exemplar (In later articles, we will discuss tools that can actually be used to analyze your exemplar in order to generate the pattern itself.) In this example, we provide instructions for using the Design Pattern Toolkit within IBM Rational® Software Architect. However, this exercise can just as easily be performed using plain Eclipse with the DPTK plug-in installed (see Resources).

  1. Startup Rational Software Architect and open a new, empty workspace:

    1. Switch to the Design Pattern Toolkit perspective, by selecting Window => Open Perspective => Other (Figure 3).

      Figure 3. Open perspective
      Figure 3. Open perspective
    2. Select Design Pattern Toolkit from the dialog (Figure 4).

      Figure 4. Select perspective
      Figure 4. Select perspective
  2. Import our sample Java exemplar; this is an example of the JavaBean we are going to generate:

    1. Right click in the Navigator view and select Import (Figure 5).

      Figure 5. Import sample
      Figure 5. Import sample
    2. Select Project Interchange from the Import wizard. (If you are using plain Eclipse, unzip the project and import it into your workspace as an existing project.)

      Figure 6. Import sample
      Figure 6. Import sample
    3. Navigate to the download materials and select MyExemplar.zip (Figure 7).

      Figure 7. Select project
      Figure 7. Select project
    4. Select the MyExemplar project and press Finish.

  3. Examine the artifacts:

    1. Expand the project (Figure 8) and open the file sample.appdef.

      Figure 8. Open the sample
      Figure 8. Open the sample

      The file will contain a bunch of XML tags. For those familiar with IBatis (see (Resources), you will notice the XML model (Listing 1) reflects a parameterMap structure of an iBatis mapping file. This defines the Java class, along with the properties and data types for each property, and will serve as our model for generation.

      (Remember, the objective is to become familiar with writing pattern templates. Best practices for maintaining a model are not represented here. In practice, the input and internal models will not match. In fact, we will modify the internal model later.)

      Listing 1
      <app>
      	<parameterMap class="com.ibm.dptk.ibatis.dataobject.Customer"
      		id="newCustomerMap" >
      		<parameter property="customerId" javaType="java.lang.Integer"/>
      		<parameter property="name" javaType="java.lang.String"/>
      		<parameter property="address1" javaType="java.lang.String" />
      		<parameter property="address2" javaType="java.lang.String" />
      		<parameter property="city" javaType="java.lang.String" />
      		<parameter property="state" javaType="java.lang.String" />
      		<parameter property="zip" javaType="java.lang.String" />
      	</parameterMap>
      </app>
    2. If you open the Java class, you will find a simple JavaBean with simple properties and setters and getters. We grouped the JavaBean property with its corresponding getter and setter for convenience in this exercise. The JavaBean is shown below.

      Listing 2
      public class Customer implements Serializable {
      
      	private java.lang.String address1;
      
      	/**
      	 * Gets the address1
      	 * 
      	 * @return Returns a java.lang.String
      	 */
      	public java.lang.String getAddress1() {
      		return address1;
      	}
      
      	/**
      	 * Sets the address1
      	 * 
      	 * @param java.lang.String
      	 *            The address1 to set
      	 */
      	public void setAddress1(java.lang.String address1) {
      		this.address1 = address1;
      	}
      
      ...

The above was a very simple approach to examining our target example. In many cases, the model and generated artifacts are not that obvious. We will illustrate more advanced analysis techniques for preparing your exemplar and discovering models in an upcoming article.


Creating and running patterns

To give you a good feel for creating and testing patterns, we will now create a pattern project and apply the pattern to a model.

  1. Create a pattern project.

    1. Right click in the Navigator view and select New => New pattern project. (Figure 9)

      Figure 9. Create new pattern
      Figure 9. Create new pattern
    2. Name the pattern IBatisJavaBeanGenerator, then press Next (Figure 10).

      Figure 10. Create new pattern
      Figure 10. Create new pattern
    3. Verify or enter values for the following fields:

      • Pattern Name: Enter the Pattern Name.
      • Pattern ID: A unique pattern ID value.
      • Appdef Type: The type of file extension that your model is stored in. When running a pattern against a model with this extension, this pattern will show up on a list of applicable patterns for this model.
      • Applies To: Indicates if the model is represented in a single file, meaning whether a single file will drive your code generation.
      Figure 11. Create new pattern
      Figure 11. Create new pattern
  2. The DPTK is architected to use Model View Controller. As such, the Design Pattern Toolkit Project wizard creates a default project structure with Model View Controller in mind. (Figure 12)

    Figure 12. MVC project structure
    Figure 12. MVC project structure
    1. Under the controller folders will be the templates driving the generation. When you apply a pattern to a model, the control.pat file gets invoked first.

    2. Under the view folder, pattern authors will store the templates that represent the data views.

    3. The project also created a dummy sample.appdef file (Figure 13). Select the file in the Navigator view to open it.

      Figure 13. Dummy sample.appdef file
      Figure 13. Dummy sample.appdef file
    4. Figure 14 shows that the sample.appdef file is just file with a simple <app> tag.

      Figure 14. Dummy sample.appdef file
      Figure 14. Dummy sample.appdef file
    5. The DPTK also provides a simple example of a view template, the dump.pat file (Figure 15).

      Figure 15. View template example
      Figure 15. View template example
    6. If you open the dump.pat file, you will find another simple file, shown in Listing 3. This one takes the in-memory model and dumps it to a file.

      Listing 3
      <exists node="/*/.." attr=".encoding">
      <?xml version="1.0" encoding="<attr node="/*/.." name=".encoding"/>"?>
      </exists>
      <exists node="/*/.." attr=".name">
      <!DOCTYPE <attr node="/*/.." name=".name"/> PUBLIC "<attr node="/*/.." 
      name=".publicId"/>" "<attr node="/*/.." name=".systemId"/>">
      </exists>
      <dump node="/*" format="true" entities="true"/>
    7. Open the control.pat file. (Figure 16)

      Figure 16. Open control.pat file
      Figure 16. Open control.pat file
    8. The contents of the control.pat file is shown in Listing 4. If you look at bold section of code, you will see that we use the <start> template tag to invoke dump.pat. The start tag will invoke the pattern template and dump the result into the specified resource, in our case, dump.xml.

      Listing 4
      *** High-Level Controller
      
         *** Apply naming conventions
         
         <include template="ibatis.java.bean.generator/controller/naming.pat"/>
      
      
         *** Derive names and other data 
         
         <include template="ibatis.java.bean.generator/controller/derived.pat"/>
         
         
         
         
         *** Dump the modified appdef file for testing and debug purposes
         
         <start template="ibatis.java.bean.generator/view/dump.pat" 
      	resource="dump.xml" replace="true"/>
  3. We are now ready to see how to invoke patterns.

    1. Right click on the included sample.appdef file and select Apply Pattern. (Figure 17)

      Figure 17. Apply pattern
      Figure 17. Apply pattern
    2. Select the Ibatis Java Bean Generator and press OK. (Figure 18)

      Figure 18. Generate pattern
      Figure 18. Generate pattern
    3. When the pattern is generated, you should see the text box in Figure 19.

      Figure 19. Pattern applied successfully
      Figure 19. Pattern applied successfully
    4. You should also have a file called dump.xml (Figure 20).

      Figure 20. Dump.xml file
      Figure 20. Dump.xml file
    5. If you examine the contents of dump.xml (Figure 21), you will see it is a simple XML file that copies the model. (Not too exciting, but great for debugging.)
      Figure 21. Dump.xml file
      Figure 21. Dump.xml file
    6. For fun, copy the sample.appdef from the exemplar project into the pattern project and override the default project.

    7. Re-apply the pattern to the sample.appdef (Figure 22).

      Figure 22. Re-apply pattern
      Figure 22. Re-apply pattern
    8. The dump.xml file should now have our exemplar model. (Figure 23)

      Figure 23. Dump.xml file
      Figure 23. Dump.xml file

Creating pattern templates with DPTK tags

We are now ready to create our first template. Our goal is to generate a JavaBean from the sample.appdef file.

  1. To generate Java source files, the generation has to happen inside a Java project. The Design Pattern Toolkit can generate various Eclipse project types, but for our purposes, we will manually create a Java project:

    1. In the Design Pattern Toolkit select File => New=> Project (Figure 24).

      Figure 24. Create Java project
      Figure 24. Create Java project
    2. Select Java Project (Figure 25).

      Figure 25. Create Java project
      Figure 25. Create Java project
    3. Name the project MyJavaBeanProject and press Finish (Figure 26).

      Figure 26. Create Java project
      Figure 26. Create Java project
    4. When asked to switch to the Java perspective, reply No (Figure 27).

      Figure 27. Reject perspective switch
      Figure 27. Reject perspective switch
    5. Copy the sample.appdef file from the exemplar into the Java project (Figure 28).

      Figure 28. Copy sample.appdef file
      Figure 28. Copy sample.appdef file
  2. Now we will create a pattern template. Right-click the view folder, select New => File (Figure 29), and name the new file JavaBean.pat (Figure 30).

    Figure 29. Create a pattern template
    Figure 29. Create a pattern template
    Figure 30. Create a pattern template
    Figure 30. Create a pattern template
  3. Copy the JavaBean code into the template using the Customer JavaBean as a starting point. Copy the Customer.java code from the exemplar project and paste it into the template. The pat file should look like the file shown in Figure 31.

    Figure 31. Create a pattern template
    Figure 31. Create a pattern template
  4. To make our JavaBean template part of our pattern, we must add it to the control.pat.

    1. Open the control.pat file (Figure 32).

      Figure 32. Open control.pat file
      Figure 32. Open control.pat file
    2. Add another start tag, as shown in the bold text in Listing 5 (or copy it from C:\DPTKArticles\Part1\CodeSnippet1.txt from the download file). The template attribute points to the JavaBean.pat file. The resource attribute defines the name of the file. (The resource folder will be relative to the src directory specified in the Eclipse project, as opposed to the root of the project, since the filetype is java.)

      Listing 5
      <start template="ibatis.java.bean.generator/view/dump.pat" resource="dump.xml"
      project="MyJavaBeanProject" replace="true"/>
         <start template="ibatis.java.bean.generator/view/JavaBean.pat" 
      resource="com/ibm/dptk/ibatis/dataobject/Customer.java" replace="true"/>
    3. Apply the pattern by right clicking sample.appdef inside the MyJavaBeanProject (Figure 33).

      Figure 33. Apply pattern
      Figure 33. Apply pattern
    4. Select the Ibatis Java Bean Generator from the pattern list (Figure 34) and the Customer class should be generated (Figure 35).

      Figure 34. Apply pattern
      Figure 34. Apply pattern
      Figure 35. Customer class generated
      Figure 35. Customer class generated

Building with the Design Pattern Toolkit

We will now use some Design Pattern Toolkit tags to build the JavaBean pattern template.

  1. The Design Pattern Toolkit has several tags that enable us to access the model and use the data in our pattern. The first tag is accessing attribute data from the model:

    1. You will remember from the model that we had information to get the class name (Figure 36). Now, open the JavaBean.pat file (Figure 37).

      Figure 36. Open JavaBean.pat file
      Figure 36. Open JavaBean.pat file
      Figure 37. Open JavaBean.pat file
      Figure 37. Open JavaBean.pat file
    2. The first tag is the <attr> tag that lets us access an attribute on a particular tag. The <attr> tag also has a few attributes that enables you to format the text in a certain way. Substitute the package name and class name, shown in Figure 38, with the text shown in Listing 6. You may also copy the text from C:\DPTKArticles\Part1\CodeSnippet2.txt. (Alternatively, a completed template is provided in the download file, if you wish instead to load it.)

      Figure 38. Replace package name and class name
      Figure 38. Replace package name and class name
      Listing 6
      package <attr node="/app/parameterMap" 
      	name="class" format="QP" />;
      
      import java.io.Serializable;
      
      public class <attr node="/app/parameterMap " 
      	name="class" format="QC"> 
      implements Serializable {
  2. Tags let you dump the attribute data of the model. However, you may occasionally need to modify the in-memory model. Open the control.pat file (Figure 39) and examine the start template tag we added earlier (Listing 7).

    Figure 39. Open control.pat file
    Figure 39. Open control.pat file
    Listing 7
    <start template="ibatis.java.bean.generator/view/JavaBean.pat" 
    resource="com/ibm/dptk/ibatis/dataobject/Customer.java"  
    replace="true"/>
  3. The issue is we cannot use the attr tag inside another DPTK tag. DPTK provides a dynamic expression language that can be used to access the data. One issue is the format of the class needs to be in a directory structure. Dynamic expressions could get ugly. Another way to approach the problem is by modifying the in-memory model. This will let you format the same data in different ways and then access it directly. The <setAttr> tag enables you to set attributes on an existing tag.

    1. Add the tags in bold text in Listing 8 (or copy it from C:\DPTKArticles\Part1\CodeSnippet3.txt). Here, we format the class name in several ways.

      Listing 8
      <setAttr node="/app/parameterMap" name="classname" >
      <attr node="/app/parameterMap" name="class"></setAttr>
      <setAttr node="/app/parameterMap" name="name" ><attr 
      node="/app/parameterMap" name="class" format="QC"></setAttr>
      <setAttr node="/app/parameterMap" name="dir"><attr 
      node="/app/parameterMap" name="class" format="PD"></setAttr>
      <setAttr node="/app/parameterMap" name="package">
      <attr node="/app/parameterMap" name="class" format="QP" />
      </setAttr>
         
         
         
      *** Dump the modified appdef file for testing
      *** and debug purposes
         
         
         <start template="ibatis.java.bean.generator/view/dump.pat" 
      resource="dump.xml" project="MyJavaBeanProject" replace="true"/>
         <start template="ibatis.java.bean.generator/view/JavaBean.pat" 
      resource="com/ibm/dptk/ibatis/dataobject/Customer.java" replace="true"/>
    2. Apply the pattern and then look at the dump.xml file, which shows what the in-memory model looks like (Figure 40). We never modify the original input model.

      Figure 40. In-memory model
      Figure 40. In-memory model
  4. Now we can modify the templates to access our new model elements:

    1. Modify the value of the resource attribute as shown in bold below.

      Listing 9
      <start template="ibatis.java.bean.generator/view/
      JavaBean.pat" resource="%/app/parameterMap(dir)%
      .java" replace="true"/>
    2. Go back to JavaBean.pat and modify the attr tags shown below to refer to our new data in the model.

      Listing 10
      package <attr node="/app/parameterMap" 
      name="package" />;
      
      import java.io.Serializable;
      
      public class <attr node="/app/parameterMap" 
      name="name"> implements 
      Serializable {
  5. Next, we need to generate the JavaBean properties. Since the number of Java properties is variable, we need to traverse the model. The Design Pattern Toolkit has an iterate tag. (Alternatively, copy the completed class snippet for this part from C:\DPTKArticles\Part1\CodeSnippet4.txt.)

    1. Open the JavaBean.pat file.

    2. We only need one Java property as a model. Delete all except the first one. Keep the address property along with its getter and setter.

    3. Add the iterate tag in Listing 11 around the Java property, getters, and setters. Figure 41 illustrates this example.

      Listing 11
      <iterate nodes="/app/parameterMap/parameter" name="currentParameter" >
      Figure 41. Iterate tag
      Figure 41. Iterate tag
    4. Substitute the type and property with the tags below. Refer to Figure 42 to see where to make the substitution.

      Listing 12
      private <attr node="currentParameter" name="javaType"/>
      <attr node="currentParameter" name="name"/>;
      Figure 42. Substitute type and property
      Figure 42. Substitute type and property
    5. Finally, update the setter and getter tags as shown in bold text in Listing 13, and apply the pattern (Figure 43).

      Listing 13
      package <attr node="/app/parameterMap" name="package" />;
      
      import java.io.Serializable;
      
      public class <attr node="/app/parameterMap" name="name"> implements 
      Serializable {
      
      	<iterate nodes="/app/parameterMap/parameter" 
      name="currentParameter" >
      	
      	private <attr node="currentParameter" name="javaType"/> 
      <attr node="currentParameter" name="name"/>;
      
      	/**
      	 * Gets the <attr node="currentParameter" name="name"/>
      	 * @return Returns a <attr node="currentParameter" 
      name="javaType"/>
      	 */
      	public <attr node="currentParameter" name="javaType"/> 
      get<attr node="currentParameter" name="name" format="U1"/&gt />
      () {
          		return <attr node="currentParameter" name="name"/>;
      	}
      	/**
      	 * Sets the <attr node="currentParameter" name="name"/>
      	 * @param <attr node="currentParameter" name="javaType"/> 
      The <attr node="currentParameter" name="name"/> to set
      	 */
      public void set<attr node="currentParameter" name="name" 
      format="U1"/&gt /> (<attr node="currentParameter" 
      name="javaType"/> <attr node="currentParameter" name="name"/>) {
          		this.<attr node="currentParameter" name="name"/> = 
      <attr node="currentParameter" name="name"/>;
      	}
      
      	</iterate>
      }
      Figure 43. Apply the pattern
      Figure 43. Apply the pattern

Generating a second JavaBean

To see how generic our pattern is, we need to test it by generating something else. Our pattern right now generates a single file from a single model. However, we can make minor modifications. (Alternatively, you can load the solution project interchange from C:\DPTKArticles\Part1/Part1Solution.zip and run the final result.)

  1. Let's add another JavaBean to our model. Open the sample.appdef file from the MyJavaBeanProject (Figure 44), and add an additional parameterMap tag, as shown in the bold text in Listing 14.

    Figure 44. Open sample.appdef file
    Figure 44. Open sample.appdef file
    Listing 14
    <app>
    	<parameterMap class="com.ibm.dptk.ibatis.dataobject.Customer"
    		id="newCustomerMap" >
    		<parameter property="customerId" 
    javaType="java.lang.Integer"/>
    		<parameter property="name" 
    javaType="java.lang.String"/>
    		<parameter property="address1" 
    javaType="java.lang.String" />
    		<parameter property="address2" 
    javaType="java.lang.String" />
    		<parameter property="city" 
    javaType="java.lang.String" />
    		<parameter property="state"  
    javaType="java.lang.String" />
    		<parameter property="zip" 
    javaType="java.lang.String" />
    	</parameterMap>
    	<parameterMap class="com.ibm.dptk.ibatis.dataobject.Order"
    		id="newCustomerMap" >
    		<parameter property="customerId" 
    javaType="java.lang.Integer"/>
    		<parameter property="orderId" 
    javaType="java.lang.String" />
    	</parameterMap>
    </app>
  2. Next, to update the pattern so that it generates more than one file, we need to update the control.pat file:

    1. Open the control.pat file and make the changes shown in bold text below. We can use the iterate tag to mass generate files, as well as to mass update the model.

      Listing 15
      *** High-Level Controller
      
         *** Apply naming conventions
         
         <include template="ibatis.java.bean.generator/controller/naming.pat"/>
      
      
         *** Derive names and other data 
         
         <include template="ibatis.java.bean.generator/controller/derived.pat"/>
         
         <iterate nodes="/app/parameterMap" name="currentBean" >
          <setAttr node="currentBean" name="classname" ><attr 
      node="currentBean" name="class"></setAttr>
      	<setAttr node="currentBean" name="name" ><attr 
      node="currentBean" name="class" format="QC"></setAttr>
      	<setAttr node="currentBean" name="dir"><attr 
      node="currentBean" name="class" format="PD"></setAttr>
      	<setAttr node="currentBean" name="package"><attr 
      node="currentBean" name="class" format="QP" /></setAttr>
         </iterate>
         
         
         
         *** Dump the modified appdef file for testing and debug purposes
         
         
         <start template="ibatis.java.bean.generator/view/dump.pat" 
      resource="dump.xml" project="MyJavaBeanProject" replace="true"/>
         
         <iterate nodes="/app/parameterMap" name="currentBean" >
        	<start template="ibatis.java.bean.generator/view/JavaBean.pat" 
      resource="%currentBean(dir)%.java" replace="true"/>
         </iterate>
      
      
      package <attr node="currentBean" name="package" />;
      
      import java.io.Serializable;
      
      public class <attr node="currentBean" name="name"> 
      implements Serializable {
      
      	<iterate nodes="currentBean/parameter" 
      name="currentParameter" >
      	
      	private <attr node="currentParameter" name="javaType"/> 
      <attr node="currentParameter" name="property"/>;
      
      	/**
      	 * Gets the <attr node="currentParameter" name="property"/>
      	 * @return Returns a <attr node="currentParameter" 
      	 * name="javaType"/>
      	 */
      	public <attr node="currentParameter" name="javaType"/> 
      get<attr node="currentParameter" name="property" format="U1"/&
      gt />() {
          		return <attr node="currentParameter" name="property"/>;
      	}
      	/**
      	 * Sets the <attr node="currentParameter" name="property"/>
      	 * @param <attr node="currentParameter" name="javaType"/> 
      The <attr node="currentParameter" name="property"/> to set
      	 */
      public void set<attr node="currentParameter" name="property" 
      format="U1"/&gt /> (<attr node="currentParameter" 
      name="javaType"/> <attr node="currentParameter" name="property"/>) 
      {
          		this.<attr node="currentParameter" name="property"/> = 
      <attr node="currentParameter" name="property"/>;
      	}
      	
      	</iterate>
      }
    2. Apply the pattern (Figure 45). You should then see the Order class, as shown in Figure 46.

      Figure 45. Apply the pattern
      Figure 45. Apply the pattern
      Figure 46. Order class
      Figure 46. Order class

Conclusion

With this article, we showed you a very simple example of how you can use the DPTK. However, the DPTK can also be used to solve very complex problems with minimal effort. We focused here on building pattern templates; DPTK also provides analysis tools for discovering a model from an existing implementation. This enables us to reverse engineer code into neutral models, functionality that can serve as the basis for building asset-based businesses. Future articles will illustrate more complex problems and how the more advanced features of the Design Pattern Toolkit can be used to address them.


Acknowledgements

The authors would like to thank Geoffrey Hambrick for his suggestions and review.


Download

DescriptionNameSize
Code samplesDPTKArticleMaterials.zip  ( HTTP | FTP )11 KB

Resources

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into WebSphere on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=WebSphere, SOA and web services, Architecture
ArticleID=150096
ArticleTitle=IBM WebSphere Developer Technical Journal: Get started with model-driven development using the Design Pattern Toolkit
publish-date=07262006