Hello,
Since the rules I am writing in Jess need to modify attributes of Java
objects and control the way the application (app server) is running, I need
to have most of the data on the Java side. If only because some of it will
be either stored in a database or displayed on the screen (HTML generation
from templates in WebObjects).
The simplest seems to be to only have facts which are actually instances of
Java objects and that dynamically notify Jess. On the Jess side, I have the
rules which modify and sometimes create those objects.
For example, an very basic state machine to handle the display:
(defrule switchRule1
(Session (readyToRun TRUE) (currentActionName "COMPLETER_CALLED")
(OBJECT ?x))
=>
(call ?x setCurrentStateName "UsingCompleter")
)
(defrule switchRule2
(Session (readyToRun TRUE) (currentActionName "SCRIPT_SELECTED") (OBJECT
?x))
=>
(call ?x setCurrentStateName "UsingScript")
)
(defrule switchRule3
(Session (readyToRun TRUE) (currentActionName "ORDER_TEMPLATE_SELECTED")
(OBJECT ?x))
=>
(call ?x setCurrentStateName "EnteringOrder")
)
(defrule componentRule1
(Session (currentStateName "UsingCompleter") (readyToRun TRUE) (OBJECT
?x))
=>
(call ?x setLeftComponentName "CompleterComponent")
(call ?x setRightComponentName "OrdersComponent")
(call ?x setBottomComponentName "CommentComponent")
)
(defrule componentRule2
(Session (currentStateName "UsingScript") (readyToRun TRUE) (OBJECT ?x))
=>
(call ?x setLeftComponentName "ScriptComponent")
(call ?x setRightComponentName "OrdersComponent")
(call ?x setBottomComponentName "CommentComponent")
)
(defrule componentRule3
(Session (currentStateName "EnteringOrder") (readyToRun TRUE) (OBJECT
?x))
=>
(call ?x setLeftComponentName "ScriptComponent")
(call ?x setRightComponentName "OrderEntryComponent")
(call ?x setBottomComponentName "CommentComponent")
)
Am I doing something "philosophically wrong" or is a it correct way to view
development with Jess?
It is more or less as if my Java classes where only used to store data and
map the data to the screen, etc... And all the algorithmic part is handled
by Jess rules.
Alex
--
Alexander Lamb
Groupe Serveurs Applicatifs
Division d'Informatique Midicale
Htpitaux Universitaires de Genhve
21 rue Micheli-du-Crest
CH-1211 Genhve 4 / Switzerland
Tel: +41-22 372.48.46 Fax: +41-22 372.61.98
[EMAIL PROTECTED] / http://www.hcuge.ch
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------