Skip to main content link. Accesskey S
  • Help
  • IBM Logo
  • IBM Web Experience Factory wiki
  • All Wikis
  • All Forums
  • ANNOUNCEMENT: Wiki changed to read-only. READ MORE...
  • Home
  • Product Documentation
  • Community Articles
  • Learning Center
  • IBM Redbooks
  • API Documentation
Search
Community Articles > Web Experience Factory > Samples and Techniques for Web Experience Factory > Service Enhancer Builder: Using builders to automate cross-cutting concerns
  • Share Show Menu▼
  • Subscribe Show Menu▼

About the Original Author

Click to view profileIBM contributorJonathan Booth
Contribution Summary:
  • Articles authored: 28
  • Articles edited: 38
  • Comments Posted: 13

Recent articles by this author

JumpStart slides from Connect 2014

The attached deck is from a JumpStart session at IBM Connect 2014. It takes you through the process of creating a multichannel, responsive application. It uses the MultiChannel Feature Pack 2 for WEF 8.0, and it is based on this article and attached archive: ...

What's New Slides from Connect 2014 Conference

The attached slides are from the session "What’s New in Digital Experience Development with IBM Web Experience Factory" from the Connect 2014 Conference. They describe the latest mobilemultichannel features from the latest MultiChannel Feature Pack for Web Experience Factory 8.0. There is also ...

Script Application Builder for Using JQuery and Other Scripting Libraries

Background and overview Web Experience Factory (WEF) customers are increasingly wanting to use jQuery and other script libraries for implementing portions of their applications. To aid in this effort we've been creating a number of articles and samples that show various ways of doing this ...

Building a Multi-Channel Application with Web Experience Factory

Building a MultiChannel Application with Web Experience Factory This article and sample shows how to use the latest Web Experience Factory (WEF) Feature Pack to build an application that runs on any desktop or mobile device. The application is a “Parks View” application for viewing and updating ...

Receiving a URL parameter from an external application

The attached sample illustrates how to pass a URL parameter from some external application into a WEF portlet. This sample uses a POC ("piece of content") resolver. A POC resolver is a mechanism for implementing the behavior for resolving a URL request received by WebSphere Portal. The following ...
Community articleService Enhancer Builder: Using builders to automate cross-cutting concerns
Added by IBM contributorJonathan Booth | Edited by IBM contributorJonathan Booth on April 18, 2012 | Version 6
  • Edit
  • More Actions Show Menu▼
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars
expanded Abstract
collapsed Abstract
No abstract provided.
Tags: Custom builder
The Web Experience Factory framework enables the creation of very powerful builders that do all sorts of code generation and modification. Many builders are primarily “creation” builders that generate new application elements. For example, the View & Form builder generates multiple pages and supporting code for viewing and updating data from a service. Other builders are primarily “modification” builders that enhance or modify elements that were created by other builders. For example, the Data Layout builder can modify the layout of a page that was created by another builder such as View & Form or Data Page.

Some of the most powerful modification builders are ones that work across a whole application to implement cross-cutting concerns. One example is the Data Field Settings builder, which can modify all the data fields on all pages to control all the rich behavior and appearance of the fields. Builders like this provide a kind of aspect-oriented programming (AOP) functionality.

The attached sample is a custom builder that illustrates how a builder can provice AOP features to automate the implementation of cross-cutting concerns such as logging. The builder "enhances" service operations which are created by other builders such as Service Consumer, Service Operation, SQL Data Services, or many others. This builder modifies all of the execution methods for the service operations and adds calls to LJO methods that can do things like logging. You can use this builder to enhance all the Data Services in a model, or you can select a single Data Service. In this example, the builder does the following:
• Adds an LJO to the WebApp (called serviceEnhancerLjo by default). The LJO in this sample has preServiceCall and postServiceCall methods.
• For each service operation, it generates a new method that will be used instead of the existing service execution method. It does this by calling the Method builder, using the "Rename Existing" option in the Method builder.
• The new method makes three calls: one to "preServiceCall", one to the renamed service execution method, and one to "postServiceCall".

The LJO in the sample code simply writes information to SystemOut, including the service operation inputs and results. For real use it would need to be modified, for example to call logging APIs. It could provide automation and enforcement of your desired practices for logging service call execution.

This type of cross-cutting builder could also be used to add other functionality, such as adding error handlers or other functions that you want to automate. One general high-level goal when using Web Experience Factory is to automate and enforce common best practices, so that you have: (1) simpler model code to develop and maintain; and (2) consistent implementations of the best practices you want to follow.

This builder can be used with any Data Services, in provider or consumer models. If you use the “Modify All Services” option, it will modify all Data Services in the model. In a consumer model, it will modify the Data Service generated by Service Consumer builders; in a provider model, it will modify the public Data Service as well as any other Data Services such as the ones generated by the SQL Call builder.

Here's the builder user interface:


Here's the output from the LJO when selecting a details link on the sample OrdersServiceConsumer model. In the “PreServiceCall” output you can see the input to the operation, and in “PostServiceCall” you can see the results of the operation.

[4/13/12 14:57:10:943 EDT] 00000087 SystemOut     O PreServiceCall model: samples/gettingstarted/OrdersServiceProvider operation: orders/getOneOrder
[4/13/12 14:57:10:943 EDT] 00000087 SystemOut     O inputs: <RowToSelectOne xmlns="http://bowstreet.com/services/XMLProvider"><ORDER_ID>000715</ORDER_ID>
</RowToSelectOne>

[4/13/12 14:57:10:943 EDT] 00000087 SystemOut     O PostServiceCall model: samples/gettingstarted/OrdersServiceProvider operation: orders/getOneOrder
[4/13/12 14:57:10:943 EDT] 00000087 SystemOut     O results: <Row xmlns=""><ORDER_ID>000715</ORDER_ID>
<DATE_ORDERED>2000-02-12</DATE_ORDERED>
<STATUS>Out of Stock</STATUS>
<SHIPPED>false</SHIPPED>
<DATE_SHIPPED>-</DATE_SHIPPED>
<QUANTITY>4</QUANTITY>
<AMOUNT>457.72</AMOUNT>
<BILLING>1</BILLING>
<STATE>MA</STATE>
</Row>

Some notes about how the builder is implemented:


• The builder does all of its work in “POST_CONSTRUCTION” phase of the regeneration process. This lets the builder work correctly even if it's above other builders in the builder call list.
• The builder loops over all the operations in the specified Data Service(s), and for each one, it finds the implementation method name, then generates a new method body that calls the old method. It invokes the Method builder with the “Rename Existing” option enabled, so that the old method will be renamed. If you look in the Application Tree you will see two methods for each execution method, one with a “_renamed” suffix added.

For links to more information on creating custom builders, see the section on custom builders on the “Learning Web Experience Factory” page on our wiki.

The sample package doesn't include a test model, but you can add the builder to any model that includes any Data Services (look in the Application Tree view to see the Data Services in a model). You can use it in provider or consumer models.

Hopefully this example gives a picture of how you can use builders in Web Experience Factory for an AOP approach, to automate the implementation of cross-cutting concerns in an application.

  • Edit
  • More Actions Show Menu▼


expanded Attachments (1)
collapsed Attachments (1)
Edit the article to add or modify attachments.
File TypeSizeFile NameCreated OnDelete file
application/x-zip 6 KB service_enhancer_builder.zip 1/28/12, 9:23 AM
expanded Versions (6)
collapsed Versions (6)
Version Comparison     
VersionDateChanged by              Summary of changes
This version (6)Apr 18, 2012, 9:21:41 AMJonathan Booth  IBM contributor
5Apr 13, 2012, 5:02:49 PMJonathan Booth  IBM contributor
4Apr 13, 2012, 4:50:12 PMJonathan Booth  IBM contributor
3Apr 13, 2012, 4:42:28 PMJonathan Booth  IBM contributor
2Apr 13, 2012, 4:39:14 PMJonathan Booth  IBM contributor
1Apr 13, 2012, 4:13:20 PMJonathan Booth  IBM contributor
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedHelpAbout
  • IBM Collaboration Solutions wikis
  • IBM developerWorks
  • IBM Software support
  • Twitter LinkIBMSocialBizUX on Twitter
  • BlogsIBMSocialBizUX on Facebook
  • ForumsLotus product forums
  • BlogsIBM Social Business UX blog
  • Community LinkThe Social Lounge
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Accessibility
  • IBM Terms of use
  • Wiki terms of use