This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Scripting business logic using kawa/scheme


I would like to evaluate kawa/scheme for a re-design and simplification of
our current application to see if it is a good idea to use it, and if others
have applied it to similar problems.

Our firm is in the finance/investment management business. We currently have
a compliance system for portfolio managers that is written in Java and that
checks business rules on trades for compliance. The system comprises of
backend Java services (exposed through CORBA) that allow trading
applications to connect and invoke them.

The system allows users to create pre-defined rules against portfolios and
store them in the database. Rules are defined using a custom  grammar that
is mainly based on boolean logic operations. An example rule expression is
the following: 

    (Security.IsEquity() AND Issuer.MarketCap() < 5000000)

The above expression means that it is a compliance failure if the trade
contains an equity security of an issuer with market cap less than 5
million.

The expressions are parsed by a parser (using javacc) converted to ASTs
(using jjtree) which is then used to generate Java source code that can
execute the rule. The Java source code is then compiled to bytecode and
stored in the database. The bytecode is loaded on the fly by the application
to evaluate the rules.

For the above example, the generated Java source code would use the Security
and Issuer Java business objects from the 'current context' and use
reflection to invoke the methods isEquity() and marketCap() and check the
above condition. 

We have run into a situation where the users (who create new rules) need a
more powerful and expressive language to express the rules. They would like
us to extend the grammar to include conditional logic (IF-THEN-ELSE, COND)
and even possibly FOR/WHILE loops. They want to access more
attributes/methods of the business objects and be able to write more complex
rules and expressions.

I am wondering if it is a good idea to keep making our grammar more powerful
(which involves a great deal of time and effort to deal with parsing,
tree-generation, compilation, etc) or use an existing scripting language
that can integrate with Java and possibly (which is the case with kawa)
compile the scripts directly to Java bytecode.

The only issue is that non-technical users should be comfortable writing at
least basic scripts (consisiting of boolean operations). 

Is kawa/scheme suited to solve this type of a problem. Essentially - to move
out business logic/rules from the application to scripts - so that it is
easy to create, modify, and maintain (even by non-technical users).

What would be the advantages of kawa/scheme over other scripting languages
that also integrate with Java like JPython (based on Python) and Jacl (based
on Tcl).

-Shoeb Bhinderwala

PS: Here is an informative article on Java scripting languages:
http://www.javaworld.com/javaworld/jw-04-2002/jw-0405-scripts.html.





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]