Getting Started with Tuscany – for version 1.5

My javascript is really rusty.I spent an embarrassingly long time this weekend trying to get the sample in the Getting Started with Tuscany guide working but it’s there now. I followed the instructions to the letter and when I ran the store application my catalog was empty. Didn’t take long to figure out that my catalog service was never getting called but it took me a lot longer to figure out why. Turns out that the current version of the guide is not quite correct for running with v1.5.One of the things that you will find if you dig as deep as I did is that Tuscany creates a javascript file that reflects the services and bindings that it finds in the composite file. That javascript file, which is called store.js for this particular example (to correspond to store.composite), will include javascript functions for the bindings your composite uses (in this case, JSONrpc and Atom) and instantiates those clients for each of the services it finds in the .composite file. In version 1.3.2 of Tuscany those last lines in the store.js look like:var referenceMap = new Object();referenceMap.catalog = new JSONRpcClient("/Catalog").Service;referenceMap.shoppingCart = new AtomClient("/ShoppingCart/Cart");referenceMap.shoppingTotal = new JSONRpcClient("/Total").Service;function Reference(name) {    return referenceMap[name];}And as given in the guide the javascript in the store.html file includes://@Referencevar catalog = new Reference("catalog"); //@Referencevar shoppingCart = new Reference("shoppingCart"); //@Referencevar shoppingTotal = new Reference("shoppingTotal");Well, with version 1.5 of Tuscany the last few lines of the store.js are different:tuscany.sca.referenceMap = new Object();tuscany.sca.referenceMap.catalog = new JSONRpcClient("/Catalog").Service;tuscany.sca.referenceMap.shoppingCart = new AtomClient("/ShoppingCart/Cart");tuscany.sca.referenceMap.shoppingTotal = new JSONRpcClient("/Total").Service;tuscany.sca.Reference = function (name) {   return tuscany.sca.referenceMap[name];}A variable name change. A simple update to the store.html file to replace the variable Reference with tuscany.sca.Reference and all was well.//@Referencevar catalog = new tuscany.sca.Reference("catalog"); //@Referencevar shoppingCart = new tuscany.sca.Reference("shoppingCart"); //@Referencevar shoppingTotal = new tuscany.sca.Reference("shoppingTotal");If only I had remembered that this was javascript and not java and I would have spent more time in the sun this weekend. Ah well, the silver lining is that I dug deep enough that I understand a lot more about Tuscany now.

July 12, 2009 Administrator Bug No Comments

Share Your Thoughts