Scripting Jackpot

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.

As a proof of concept, I've only implemented Query; supporting Transformers should not be that difficult (famous last words). Here is what you need to do to try this module:

  • 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

  • Get some of the sample query scripts from here. All the scripts, except one, are reimplementation of the query examples from the Jackpot website.

  • Once you have installed the module, open up the 'Query and Refactor' and select 'Query scripting runner'.

  • A filechooser dialog box will open up. Select any one of the JavaScript examples.

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?

Comments:

Post a Comment:
Comments are closed for this entry.
About

Random thought at random intervals

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today