Subject Re: [Firebird-Architect] Re: embedding Lua as procedural language
Author Adriano dos Santos Fernandes
Roman Rokytskyy wrote:
>> What about javax.script package?
>>
>
> I think Rhino is directly supported, if not - there is definitely some
> plugin package already.
>
The Sun implementation is based on it, without the
javascript-to-bytecode:
http://java.sun.com/javase/6/docs/technotes/guides/scripting/programmer_guide/index.html

>
>> With some small (that I already plan) additions to FB Java Engine, it
>> will be possible to implement an engine in Java that interfaces with
>> javax.script engines.
>>
>
> Cool, let's talk about it after holidays...
>
The basic idea is to have classes:
InternalContext
- String getObjectName()

FirebirdTriggerContext extends InternalContext
- String getTableName()

This is what I currently already have for triggers. It need additions.
More methods are necessary to read all parameters (and fields OLD.*,
NEW.*) from an "array". With that array, things could be passed back and
forth between the Java code to script engines.

Also, external procedures currently can't have body source. They can
only have an "external name". It would be ok to have:

set term !!;

create function add (n1 integer, n2 integer) return integer external
engine Javascript
as
begin
/* Javascript code */
return n1 + n2;
end!!

That's more or less how it works in PgSQL AFAIR.


Adriano