Nov 27

The BPEL SE, featured in the GlassFish ESB, the OpenESB and the Java CAPS 6, has the ability to execute JavaScript (ECMAScript) code inline. Why would one do that, you may ask. The answer is: because BPEL, great as it is with XML all over the place and all, can not do everything, and invoking Web Services and POJOs from BPEL for small and simple code adds too much overhead.

Take a date conversion, for example. It takes about 4 lines of Java code to perform date conversion. Doing this in BPEL is too horrible to contemplate. Doing this in JavaScript is not too bad, given availability of ready-made JavaScript scripts that do the job.  The issue is that one cannot invoke Java from BPEL without resorting to a web service or a POJO. Invoking JavaScript, on the other hand, does not require either. Furthermore, JavaScript, in the Netscape days, acquired the ability to embed Java using technology known as LiveConnect.

In this Note we will explore the BPEL SE capability to execute JavaScript code inline. In passing we will also explored the ability of JavaScript to execute Java statements, and through these means to extend BPEL 2.0 with arbitrarily sophisticated functionality, without having to resort to invoking web services or POJOs.

We will introduce 2 Rules which must be followed, and 1 Rule which should be followed, for successful BPEL and  JavaScript integration. We will develop two complete examples of embedded JavaScript code that provides reasonably useful functionality not natively available through BPEL. While the two examples will be fairly trivial it will be clear that more sophisticated functionality can be added following the method introduced in this Note.

Writeup, BPEL_JavaScript_Java_GetProperty_v1.0.2.pdf, can be found at https://blogs.czapski.id.au/wp-content/uploads/2010/03/BPEL_JavaScript_Java_GetProperty_v1.0.2.pdf

Projects, developed in the writeup, in the archive BPEL_JavaScript_Java_GetProperty_v1.0.2_code_bis.zip, are to be found at https://blogs.czapski.id.au/wp-content/uploads/2010/03/BPEL_JavaScript_Java_GetProperty_v1.0.2_code_bis.zip

2 Responses to “GlassFish ESB v2.1 – Using JavaScript Codelets to Extend BPEL 2.0 Functionality”

  1. Michael Czapski says:

    mrtally pointed out that the code archive did not in fact contain code. I now replaced the code archive with teh archive that does contain code.

    Thanks mrtally

    Michael

  2. […] GlassFish ESB v2.1 – Using JavaScript Codelets to Extend BPEL 2.0 Functionality GlassFish ESB v2.x Field Notes – Preparing Basic JeOS Appliance for GlassFish ESB LB and HA Testing Nov 28 […]

Leave a Reply to Michael Czapski

preload preload preload