[izpack-users] Feature Request - Scripting Languages for custom actions

Matthew Inger mattinger at gmail.com
Fri Jan 4 20:14:16 CET 2008


Mark,

The following code snipped for bsf reveals to me that it would be easy to do
what is needed, given that the
scripting languages support anonymous functions.

BSFManager manager = new BSFManager();
manager.declareBean("file", file File.class);
manager.declareBean("pack", pack, PackFile.class);
BSFEngine engine = manager.loadScriptingEngine("groovy");
engine.iexec(srcFileName, 1, 1, scriptContent);
engine.iexec(srcFileName, 1, 1, "beforeFile(file, pack);");

And the scriptContent would be a groovy closure, something like:

beforeFile = {
   print file;
   print "\n";
   print pack;
   print "\n";
};


To see if a given function exists, we would have to lookup the function
reference:

// This throws an exception if the function is not defined
// For groovy, it return the function closure.
Object functionRef = engine.eval("", 1, 1, "beforeFile");


If this is reliable enough, I'm ok with that sort of implementation.

Any input would be very helpful here.


On Dec 28, 2007 9:08 PM, Mark Fortner <phidias51 at yahoo.com> wrote:

> I sent this to the list earlier, but it somehow didn't make it
> through.  You'll find more information on BSF at
> http://jakarta.apache.org/bsf
>
> On Dec 22, 2007 8:38 AM, Mark Fortner <phidias51 at gmail.com> wrote:
> > The tags that you propose seem groovy-centric. I was wondering if you
> > had any thoughts about how multiple languages would be supported?
> > Would a general-purpose <script> tag work better -- along the lines of
> > the Ant script tag.
> >
> > <script language="text/javascript" src="installer.js" />
> >
> > <script language="text/groovy">
> > <![CDATA[
> >         void beforePacks(
> com.izforge.izpack.installer.AutomatedInstallData
> > idata,
> >                                   java.lang.Integer npacks,
> >
> > com.izforge.izpack.util.AbstractUIProgressHandler handler)
> >         {
> >            // do your groovy scripting here
> >         }
> >     ]]>
> > </script>
> >
> > The flexibility to be able to either embed or refer to a script (as
> > Julien suggested)  would be useful.
> >
> > Also, being able to support scripting through either BSF or Java 6's
> > built-in support would be useful.  This would insure that the
> > scripting functionality is available in both 1.4 and 1.5.  BSF
> > supports JSR-223 scripting engines.
> >
> > Regards,
> >
> > Mark
> >
> >
> > On Dec 21, 2007 12:10 PM, Matthew Inger <mattinger at gmail.com> wrote:
> >  [snip]
> >
> _______________________________________________
> izpack-users mailing list
> izpack-users at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/izpack-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/izpack-users/attachments/20080104/7a6a587f/attachment.html 


More information about the izpack-users mailing list