2012/01/13

Accessible Accessors

Now, say the title out loud quickly five times in a row and I'm sure you'll qualify for House Slytherin ...

In a previous entry I sort of hinted at the fact that in order to write core tools for NetKernel, you need Java. Since NetKernel is developed in Java I stand by that statement.

However, it is not impossible to use one of the dynamic languages and if you are addicted to one of those you can (and should) develop at least some of your tools in that language.

Which brings us to the workhorses of NetKernel, accessors. Check your local documentation for the explanation, In this entry I want to focus on the Service Accessors. Those accessors are resource transformation functions or in simpler words : they compute.

The fact you'll notice quickly about accessors is this : they require a class. Is that then the end of this entry ? No, for there is an alternative :

If you've looked at accessors implemented in Java, you'll notice that those always implement a class that extends the StandardAccessorImpl class. Now, Python does have classes and at first I tried that (and it didn't work), until I realised that I was too late. The prototype is the class, once in the script you are already inside the accessor.

To show what my simple accessor can do (not a lot), here are two screenshots from executions in the request resolution trace tool (click to enlarge).

This entry is maybe (slightly) above the level of my intended audience. My main point is that your investment in a scripting language is not wasted. You'll automatically drift to Java as your tools become more and more core, but scripting languages definitely do the job.