Open ESB Tip : Simplified Business View Generation

Read the original article at The Crooked Stick

In the never search for simplicity and perfection I have written a new Servlet that is designed to simply retrieve the business view of the BPEL based on the BPEL Instance Id which can be easily obtained from the Business Process. This I hope will greatly simplify the task of generating the Business View and make it easier to integrate with web applications, such as the Sun Pre-Sale Cars Online Demo, to provide user feedback.

This blog entry, which will probably take longer to write than the Servlet, will document how to call the new Servlet, the html / xhtml requirements and what we information need from the business process.

<script type="text/javascript"> $(document).ready(function(){ $("#traildiv").load("../resource/bpel-monitor/MonitorTrail.html"); $("#resourcediv").load("../resource/bpel-monitor/MonitorResources.html"); $("#traildiv").load("resource/bpel-monitor/MonitorTrail.html"); $("#resourcediv").load("resource/bpel-monitor/MonitorResources.html"); }); </script>


I am assuming that the reader has read the previous blog entries associated with this topic and therefore understands how to add the specific Business Style Icons and how to design and build their Business Processes to take advantages of this functionality. With this version I have made not attempt to generate Internet Explorer / Opera compatible code but the reader can do this by looking at the previous entries.

I will split the description on usage into the the following section:

  • BPEL Modifications
  • Client Side Code.
  • Server Side Code.

BPEL Modifications


To allow this new Servlet to be integrated into any web application requires a number of simple modification to the layout / grouping of the Business Process. These are defined in my previous blog entry "Giving the Monitor a Business Skin". In addition to this we need to obtain the running processes Instance Id and this easily to by using the "Get BP ID" function available from the BPEL Menu in the mapping tools bar (see below).

BPEL Id

Once we have the Instance Id this needs to be returned to the User Interface before the process has completed. This can be done either by having the reply early in the process (I'm assuming Asynchronous processing) or we need to place this information in a location where the front end can read / correlate this information database / jms.

Client Side Code


I have provided a simple jsp page (index.jsp) to demonstrate the call to the Servlet (below) and as you can see it simply takes an Instance Id and then displays the SVG for the Business Process. I have documented the index.jsp because it shows some key features required to display the svg, inline, correctly.
Example

index.jsp

The demo page created has a few key pieces of information you will require within your page to display the inline svg correctly. Line 30 is the most important line because it changes the standard "text/html" Type for the page to "application/xhtml+html" this allows the svg to be placed inline and display correctly, in Firefox / SeaMonkey / Chrome, correctly. If this is not done then the code will not be displayed correctly with only the titles being displayed.

Once the content type has been set we need to set the content of the html to xhtml as shown by line 33.

To force the Browser not to cache the pages I have added lines 36-39 by setting the various no cache and timeout options.

ajax.js

This simple JavaScript simply calls the Servlet using the JQuery $.ajax functionality and then place the result of the Servlet call into the div defined in the index.jsp page. It can be seen from the JavaScript code that I simply call the Servlet and pass the contents of the instanceId input field on index.jsp. Obviously this instanceId can be obtained programatically and passed onto the call.

BPEL Instance Id is defined in MONITORBPELINSTANCE database table.

Server Side Code


The Server side code has been simplified to a single Servlet and Singleton Factory. The Single exists only to provide a simple cache so that I do not have to access the database for each invocation of the Servlet. This is not an intelligent cache by any means just simple storage implementation.

AjaxGenerateBusinessSvgServlet

The AjaxGenerateBusinessSvgServlet will take the Instance Id passed and obtain the BPEL Id (line 133) and then obtain the BPEL as a String (line 135). This BPEL is then Unmarshalled into a JAXB Structure (Line 137) before we build the required SVG Layout and Generator (Lines 138 - 167).

The Activities and their status is obtained from the BPEL Management API (Line 131) and these are converted to background colours in lines 147 - 161. Whilst the business Icons are obtained at line 146.

In addition to the required instanceId parameter the Servlet also accepts a scaling and iconSet parameters. The scaling parameter is a double that defines how the generated svg will be scaled. The default value is 1.0 and hence generates with no scaling. The iconSet defaults to alternative (the only available) but can be changed if you add your own icons sub-directory.

BusinessSvgFactory

Simple cache of the database information so that I can quickly access / retrieve the BPEL as a String and Business Icons.



Comments:

Post a Comment:
Comments are closed for this entry.
About

As a member of the Oracle A-Team we specialise in enabling and supporting the Oracle Fusion Middleware communities.

Search

Archives
« April 2014
MonTueWedThuFriSatSun
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    
       
Today