jakarta-bsf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Winga...@schneider.com
Subject NetRexx 2.x / BSF2.3 issue getting "current" BSFManager instance...
Date Wed, 08 Jan 2003 22:01:11 GMT
... from within the Rexx script.  The problem seems to be that
when I call into (BSFManager.exec() or BSFManager.eval(); they
seem to act the same in this respect) the script, the only way I
can figure to get a valid reference to a BSFManager is to instantiate
one within the script, which, of course, doesn't know beans about the
Java classes  I've painstakingly tried to expose to the script.

I have tried both declaring and registering a Java class from
within my app:
     // ... deletia

     bsfMan.declareBean("invoice", invoice, Invoice.class);
     // bsfMan.registerBean("invoice", invoice);
     // ... deletia

(The 2nd is theoretically redundant so I've commented it out, though
I seem to get identical results using either or both.)

I  have a Rexx script:
     import com.schneider.slps.rexxrules.Invoice
     import org.apache.bsf.BSFManager

     class rules
     method main(args=String[]) public static
           /* deletia...*/

     method CheckForDups public static
                      /* Important stuff omitted, see below */
           myInvoice = Invoice bsf.lookupBean("invoice")     /* !!!Not
working!!! */

           if (myInvoice == null) then
              return 'None'
                     /* Actual important stuff below deleted.... */


So, in order to get NetRexxC to resolve the bsf ref in the line commented
/* !!!Not Working!!! */ I have tried:

     bsf = BSFManager   /* According to the .java.keep file this creates an
                                                            instance of a
ref to a BSFManager and sets it to null */
                bsf = BSFManager() /* Instantiates a new one */

I can theoretically avoid this whole issue if I've called declareBean(),
and interestingly,
the symbol "invoice" does seem recognizable to the NetRexx compiler if I
remove all
declarations from the Rexx script, but as a TYPE, not an instance of class
"Invoice".
So, unless I can figure out some way for the Rexx script to just know that
"invoice" means
the one I registered w/ the BSFManager, I need to do a lookupBean().
Therefore, what I
seem to need is some third choice that lets me say "the BSFManager I'm
running in", and
I don't know what that looks like.   The really ugly workaround I'm using
depends on a static
instance var:

                      myInvoice = Invoice.currentInvoice;

but I'm sure that  this is not what the authors intended.  Being new to
both BSF & Rexx I'm
probably missing something really simple, so any pointers to good resources
for either
would be much appreciated, as would any insight into this problem.

 What I'm trying to do, BTW, is to develop a "poor man's rules engine"
callable from within
J2EE code.  The idea is that as much of the business logic as possible
could be separated
out into a higher-level, user-presentable language structure.  Rexx looked
like a good choice,
but given that NetRexx must first be translated into Java anyway, BSF might
not be a good fit for this.
(I could simply have users write Rexx, and use ANT to compile this into
Java classes which we
simply load along w/ the rest of our J2EE infrastructure).  Ultimately it'd
be nice to use a Java
implementation of the Rete algorithm (there seem to be several), or
implement our own
Observer / Observable pattern to make it act more like a real rules engine,
but the first iteration
would simply fire NetRexx "rules" at predetermined points in the regular
Java processing.
Any comments or insights would be welcome.

Keith
--------------------------------------------
W. Keith Wingate
Schneider Logistics
708-647-4346
WingateK@Schneider.com



Mime
View raw message