Monday, April 23, 2012

When to Use Custom XPath Functions in the SOA Suite

If you want to know how to create custom XPath functions, then have a look for example at Anthony Reynold's Blog entry on the topic. I have little to add to that excellent posting except for how to add parameters, which is done using the <param> tag as in the following example:



And the following simple piece of Java code to get the parameter from the list:

  public static Object compressGuid(IXPathContext iXPathContext, 
                                    List arguments) {
    String guid = (String)(arguments.get(0));
    ...
  }



If you want to know when or why to use custom XPath functions, then read on.

Before I come to some sort of a conclusions, first let's discuss some of the specifics of the mechanism of adding custom XPath functions.


One Function, One Class

First observation is that a custom XPath function is exposed by a class that implements the IXPathFunction interface. This interface enforces implementation of a call() method which executes the XPath function. As there can be only one call() method in the class, it can realize only one function. So if you want to implement more functions you will need to create as many classes as there are functions. To support reuse you can let each of those classes extend an (abstract) super class that will contain the common behavior and (static) reusable attributes.


No Runtime Versioning

A second observation is that the class to implement an XPath function ends up in a jar file that is deployed in the SOA infra structure. A class is not a service, so there can be only one implementation of that class at the same time. If you need to deploy a new version of the XPath function while keeping the previous one, you either need to put it in a different package or give it another name. On top of that you will also have to give the <function> another name (in the example resulting in a compressGuid, and compressGuid2). How ugly do you want it to get? An obvious other aspect is that the XPath function by definition is reusable for everybody that is deploying on the SOA engine on which the jar file is deployed.


No Right-Mouse-Click Deployment

By now you will realize that you cannot simply deploy a new version of the jar file on the server by just right-mouse-clicking it and then choose "deploy", and that this is for a reason. You will have to copy the jar file to a specific folder, run an ant script, and restart the server.


Conclusion

Custom XPath functions is not the silver bullet to do any type of Java embedding in SOA or BPM processes. Especially as a BPM developers you just might have hoped for this as, unlike in BPEL, there is no Java Embedding activity in BPM (also for a good reason you might argue, but that's another blog entry).

You should only create XPath function for specific types of cases, while applying some best practices:

  1. Only use it for XPath functions that clearly fits between all other already available XPath functions. An example is an XPath function I just created (based on the brilliant algorithm of my dear colleague Tonio Voerman), which compresses the 32 character Oracle GUID into 30 characters (because the column in which we have to store it, is only 30 characters long). After all the (existing) oraext:generate-guid() is also an XPath function.
  2. Be sure that the XPath function indeed is an obvious candidate for reuse (our compress-guid() function will be used by every BPM process). Otherwise, other solutions like including a Sprint Context in your composite, probably are better.
  3. Do your utter best to get the proper requirements for the interface, and functionality, to prevent you find yourself in a situation (and trouble) where you have to deploy a new version of the function next to an existing one.
  4. Test the XPath function thoroughly, preferable using some unit-testing framework like JUnit

Unbelievable, this is actually the first time in my life that I manage to post two entries on the same day. Normally I don't even find the time to do two in a week, or even a month for that matter!

12 comments:

poojaa2015 said...

My cousin recommended this blog and she was totally right keep up the fantastic work!


Custom Software Development

Ali Kazmi said...

thanks for the auspicious writeup. It in truth was once a amusement.Glance advanced to more introduced agreeable from you! However, how can we keep in touch?
Meet a standout custom software development Company

Allan said...

Custom software development specialists explore exactly of the company are on they need from their IT system in order to operate to their optimum.

Denature Sip said...

nice article, thankyou,
cara alami mengobati kanker payudara
cara alami untuk mengobati kanker payudara
cara alami utk mengobati kanker payudara
cara yang alami mengobati kanker payudara
cara alami buat mengobati kanker payudara

gantungan kunci said...

good planning*****************

ganci murah said...

thanks in advance*****************

souvenir said...

thanks for this article ***********************************

Anonymous said...

good
Obat Ambeien Tanpa Operasi
Pengobatan Ambeien Tanpa Operasi di Apotik
Obat Ambeien di Apotik
Obat Ambeyen Tanpa Operasi di Apotik
Obat Ambeien Tanpa Operasi
Obat Ambeien Resep Dokter
Obat Ambeyen Resep Dokter
Pengobatan Ambeien Tanpa Operasi Resep Dokter
Obat Ambeien Herbal
Obat Ambeien Tanpa Operasi
Obat Ambeyen Herbal
Pengobatan Ambeien Herbal Tanpa Operasi
Cara Mengobati Ambeyen
Cara Mengobati Wasir
Cara Alami Mengobati Ambeien
Cara Tradsional Mengobati Ambeien
Mengobati Penyakit Ambeien
Cara Mengobati Ambeien
Cara Mengobati Penyakit Wasir
Cara Mengobati Penyakit Ambeien Wasir
Cara Mengobati Wasir
Cara Mengobati Ambeien dan Wasir
Mengobati Ambeien Wasir
Cara Mengobati Ambeien atau Wasir
Cara Ampuh Mengobati Ambeien Wasir
Cara Mengobati Ambeien
Cara Ampuh Mengobati Wasir
Cara Ampuh Mengobati Ambeien Wasir
Aman Mengobati Ambeien
Cara Aman Mengobati Ambeyen
Cara Aman Mengobati Ambeien Wasir
Cara Alami Mengobati Ambeien
Cara Mengobati Ambeien Wasir Parah
Cara Mengobati Ambeyen Parah
Mengobati Ambeien Parah
Cara Mengobati Ambeien dan Wasir Parah

Art Jokja said...

spesialis gantungan kunci
gantungan kunci
pesan gantungan kunci
jual gantungan kunci
harga gantungan kunci
produksi gantungan kunci
order gantungan kunci
souvenir gantungan kunci
bikin gantungan kunci
buat gantungan kunci
gantungan kunci murah
spesialis gantungan kunci
gantungan kunci
pesan gantungan kunci
jual gantungan kunci
harga gantungan kunci
produksi gantungan kunci
order gantungan kunci
souvenir gantungan kunci
bikin gantungan kunci
buat gantungan kunci
buat gantungan kunci_24
pesan gantungan kunci akrilik partai
order gantungan kunci akrilik partai
spesialis gantungan kunci akrilik obyek wisata

Art Jokja said...

pesan gantungan kunci akrilik
jual gantungan kunci akrilik
order gantungan kunci akrilik
harga gantungan kunci akrilik
kulakan gantungan kunci akrilik
produksi gantungan kunci akrilik
bikin gantungan kunci akrilik
bikin gantungan kunci akrilik
spesialis gantungan kunci akrilik
buat gantungan kunci akrilik

Art Jokja said...

jual gantungan kunci akrilik perusahaan
order gantungan kunci akrilik motor
harga gantungan kunci akrilik obyek
kulakan gantungan kunci akrilik unit
produksi gantungan kunci akrilik
bikin gantungan kunci akrilik unik
spesialis gantungan kunci akrilik jogja
buat gantungan kunci akrilik manten
cara pesan gantungan kunci
harga gantungan kunci
pesangantungankunciakrilikmurah
hargagantungankunciakrilikmanten
kulakangantungankunciakrilikmurah
bikingantungankunciakrilikperusahaan
buatgantungankunciakrilikhotel
pesan gantungan kunci akrilik sablon
jual gantungan kunci akrilik souvenir
harga gantungan kunci akrilik hotel
produksi gantungan kunci akrilik sablon
bikin gantungan kunci akrilik souvenir
pesan gantungan kunci akrilik resin
order gantungan kunci akrilik ultah
produksi gantungan kunci akrilik resin
bikin gantungan kunci akrilik ultah
buat gantungan kunci akrilik anime
pesan gantungan kunci akrilik grafir

Art Jokja said...

order gantungan kunci akrilik pilkada
harga gantungan kunci akrilik dealer
produksi gantungan kunci akrilik grafir
spesialis gantungan kunci akrilik pilkada
jual gantungan kunci akrilik print
order gantungan kunci akrilik promosi produk
kulakan gantungan kunci akrilik anime
spesialis gantungan kunci akrilik promosi produk
buat gantungan kunci akrilik dealer
bikin gantungan kunci akrilik
jual gantungan kunci akrilik unik
kulakan gantungan kunci akrilik full colour
produksi gantungan kunci akrilik print
spesialis gantungan kunci akrilik partai
gantungan kunci
pesan gantungan kunci
jual gantungan kunci
order gantungan kunci
harga gantungan kunci
produksi gantungan kunci
kulakan gantungan kunci
bikin gantungan kunci
buat gantungan kunci