hehehehe... good question.

Well, in 2.1 it used Janino. Which is a simple in memory compiler. So the
first time you go to execute a rule that has embedded code, it would compile
and cache it on the fly. Kind of lazy compilation.

In 2.5, its a bit different. It actually takes the "java" (actually it can
be other semantic languages as well, such as groovy, there is even a .net
version now) and generates a little piece of code (all in memory), includes
your functions (if any), then it sends this code to "JCI" which is a generic
java compiler interface (which supports more then just java).

JCI then invokes the appropriate runtime compiler (by default in 2.5 is is
eclipse jdt, which is definately not javac !), and ends up building a binary
"ddj" (which is really a jar) of all the rules, which is then loaded into
the ruleset. This all happens behind the scenes, but you can get the "jar"
out (both source and binary) to have a look. So in effect the rules run off
the compiled version (meaning fast startup times as no lazy compilation).

To make it dynamic, package names used by the rulesets are unique, so when a
new version is loaded, its actually a different "package" name behind the
scenes. Also, a custom classloader is used, not the system classloader (so
it shouldn't be effected by the runtime environment).

It is important to note that this all happens in memory, unless you want to
persist the binary/source forms of the rules for deployment purposes. So no
conflict with J2EE restrictions about files, system settings etc.

For groovy all of the above applies. For Jython, there is no compiling, its
totally script based dynamic.

Phew - does that answer your question ?



On 1/20/06, Ephemeris Lappis <[EMAIL PROTECTED]> wrote:
>
> Hello.
>
> I'm not absolutely sure I have understood well how it works.
>
> Does Drools translate DRL files in java source files, and then compile
> them
> using a javac compiler ? Or is there another kind of dynamic interpreter
> that just shares the java language syntax, in case of this semantic is
> used
> ?
>
> What are the technical impacts, for instance in use cases inside J2EE
> plaforms (EJB specifications come with many programming restrictions), or
> when a simple JRE is available (embedded systems for example) ?
>
> Thanks.
>
> --
> Ephemeris Lappis
>
>
> -----Message d'origine-----
> De: Mark Proctor [mailto:[EMAIL PROTECTED]
> Envoyé: vendredi 20 janvier 2006 04:20
> À: user@drools.codehaus.org
> Objet: Re: [drools-user] [Drools][5.2.1] JDKs support in rules expression
>
> Drools 2.1 uses Janino, which is jdk1.4.
> Drools 2.5 can use either Eclipse JDT (default) or janino. Eclipse JDT
> works fine with JDK1.5
>
>
> Mar
> Ephemeris Lappis wrote:
> > Hello.
> >
> >
> >
> > I've already successfully checked that Drools supports JDK 1.5 at
> runtime
> > for the java code that calls it.
> >
> > But it seems the code snippets in rules expression are rejected if some
> JDK
> > 1.5 features, like the new for loops, are used.
> >
> >
> >
> > Could somebody confirm that ?
> >
> > Or is there a way to make Drools compile JDK 1.5 rules ?
> >
> >
> >
> > Thanks.
> >
> >
> >
> > --
> >
> > Ephemeris Lappis
> >
> >
> >
> >
> >
>
>

Reply via email to