By chuk on Jul 19, 2006
I have written an ScriptModule for Jackpot. As I have mentioned in my earlier blog, one of my motivation for experimenting with a scripting interface for NetBeans is to be able to script Jackpot. What is Jackpot? Very briefly, Jackpot is a source transformation engine. The Jackpot engine allows a developer to query and transform Java source. See Tom Ball's JavaOne presentation.
As you probably know, to use Jackpot today, you either describe your query/transformation the Jackpot rules language or develop a NetBeans modules which allows you access to the full Jackpot and Javac APIs. The rule language is easy to learn and use if you can express your queries/transformations as axioms. For more powerful Jackpot features, you have to resort to the Jackpot APIs which are only available in NetBean modules. So if you want to develop a sufficiently complex Jackpot query, you have to buy into NetBean's module (nothing against developing NetBeans modules). There is nothing in between the two methods.
The idea of the Jackpot script module is:
To expose the full power of the Jackpot API but not the NetBean module gut.
Use scripting as a prototype before implementing it in Java
Quick, use once and unique to you but complex Jackpot hacks; eg. converting your application from Hungarian notation to Java naming convention
Reduce Jackpot develop/debug cycle. You modify the script instead of the Query class for example.
It is NOT the intention of this module to totally replace the Jackpot/NetBeans module method of development.
You need to install Jackpot. See here form instructions.
Install the ScriptEngine module first because the Jackpot module is dependent on it. Get it from here.
Finally install the JackpotScriptModule. Get it from here.
NetBeans must be running on Mustang. Use the –jdkhome switch. Also, you must get Mustang b79, b80, b81 or b82. This is a Jackpot requirement. I've build and tested the module on b82
Once you have installed the module, open up the 'Query and Refactor' and select 'Query scripting runner'.
Currently the script environment supports the following objects CallGraph, NodeScanner and TreeScanner. I tried adding support for Finder object (because of FindUnusedVariables.java example) but could not instantiate Finder class. Try running find_unused_variables.js to see what I mean. If you manage to find the problem, let me know.
The source is available here. If there is enough interest, I'll work on Transformers. Let me know what you think.
Try running the Jackpot module with other scripting engine and let me know your experience. You need to get JSR-223 enable scripts. You can get a some of these script engines from http://scripting.dev.java.net.
BTW, this blog is written with “Sun Blogger for OpenOffice.org and StarOffice”. Pretty cool. It would be really nice if I can view my files as well. Next version?