I think Peter Olsen wrote:
> This is a followup to my previous question about "HeavyWeight Beans."
> This bean can be installed by using this code segment in a class
> extending the Jess.Rete engine,
> 
>       Funcall fc = new Funcall("definstance", engine);               
>       fc.add(new Value(getClass().getName(), RU.STRING));
>       fc.add(new Value(this));
>       fc.add(new Value("static", RU.STRING));

First an aside: although  this may work, it's not strictly correct;
the type of the two arguments ought to be RU.ATOM (symbols) not
RU.STRING (quoted strings.)


> 
> but the same segment won't work when included as a method in the bean
> itself.  
> 
> Can anyone tell me why?
> 
> Peter
> 

[ Most of the code deleted]

This snippet ought to work perfectly well no matter what class the
method belongs to. You don't say what "doesn't work" means, and in
fact, if something does go wrong Jess would try to tell you but you've
turned a deaf ear. The empty catch block that eats an exception
without reporting it to the caller or to the user is probably the
single worst programming habit one can have. If you were one of my
students I would strongly castigate you. As you are not, the best I
can do is to tell you to stick a System.out.println(je) into that
catch block and see if Jess is already telling you what is going
wrong. 

If there is no exception, but the definstance simply doesn't show up,
you might make sure that you're looking for it in the same Rete object
that you're passing as an argument to "install" . Lastly, since one of
your messages mentions multiple definstances, note that a single Bean
can only be definstanced once - you can't add the same Bean to a given
Rete object twice simultaneously.


> 
>   public void install(Rete engine){
>     Value result = null;
>     try{
>       Funcall fc = new Funcall("definstance", engine);               
>       fc.add(new Value(getClass().getName(), RU.STRING));
>       fc.add(new Value(this));
>       fc.add(new Value("static", RU.STRING));
>       result = fc.execute(engine.getGlobalContext());
>     }catch(JessException je){
>       result = null;
>     }
>     //return result;
>   }
> 
> }


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
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]
---------------------------------------------------------------------

Reply via email to