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));
but the same segment won't work when included as a method in the bean
itself.
Can anyone tell me why?
Peter
******************************************************
package policy; // Generated package name
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import jess.Rete;
import jess.FactIDValue;
import jess.Value;
import jess.Funcall;
import jess.JessException;
import jess.RU;
public class IMSBasicBean {
/**
* <code>sequenceNumber</code> this is this bean's position in a
* one-up sequence of IMSPolicyBeans.
*/
private int sequenceNumber;
/**
* Get the value of sequenceNumber.
* @return value of sequenceNumber.
*/
public int getSequenceNumber() {
return sequenceNumber;
}
/**
* Set the value of sequenceNumber.
* @param v Value to assign to sequenceNumber.
*/
protected void setSequenceNumber(int v) {
int oldSequenceNumber = sequenceNumber;
this.sequenceNumber = v;
firePropertyChange("sequenceNumber", oldSequenceNumber,
sequenceNumber);
}
/*****************************************************************
* Property Change Support
*****************************************************************/
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
// The last three methods are standard methods for monitoring bean
// property changes.
public void
addPropertyChangeListener(PropertyChangeListener l){
pcs.addPropertyChangeListener(l);
}
public void
removePropertyChangeListener(PropertyChangeListener l){
pcs.removePropertyChangeListener(l);
}
public void
firePropertyChange(String propName, Object oldVal, Object newVal){
pcs.firePropertyChange(propName, oldVal, newVal);
}
public void
firePropertyChange(String propName, int oldVal, int newVal){
pcs.firePropertyChange(propName, oldVal, newVal);
}
// This method won't install the bean. Any guess as to why?
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;
}
}
Peter Olsen writes:
> I'd like to know the limits of the functionality that can be included
> in a "Jess bean" (one that can be installed using "definstance").
>
> My understanding is that, according the the basic Java definition, a
> bean is _any_ object that has one or more properties that are
> accessed using some combination of setter/getter functions. Under
> this definition, a bean _may_ contain much more functionality, but
> that functionality is not accessible under the Java bean conventions.
> (I believe that may of the Swing and AWT classes embody this
> approach.)
>
> I have not been able to adopt this approach successfully in Jess. In
> particular, I haven't been able to build "self installing" beans,
> beans having their own method of the form "install(jess.Rete engine)"
> which allows them to install themselves in the rete engine given as an
> argument.
>
> I have also been unsuccessful in attempts to build beans that could
> write themselves out as formatted strings or as XML, although there
> may have been other factors at issue in these two cases.
>
> My goal is to design a system based on objects that can both interact
> with Jess and do significant processing on their own internal data in
> other environments. Is this goal attainable or must I refactor my
> design to have all the external processing done in other classes?
>
> Peter
>
> --
> Peter Olsen, PE 703-516-7304
> Principal Member of Technical Staff FAX 703-528-5918
> The Charles Stark Draper Laboratory SWBD 703-243-2600
> 1555 Wilson Boulevard, Suite 501 [EMAIL PROTECTED]
> Arlington VA 22209
>
> Scientists investigate that which already is; engineers create that which
> has never been. --Albert Einstein
>
>
> ---------------------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
>
--
Peter Olsen, PE 703-516-7304
Principal Member of Technical Staff FAX 703-528-5918
The Charles Stark Draper Laboratory SWBD 703-243-2600
1555 Wilson Boulevard, Suite 501 [EMAIL PROTECTED]
Arlington VA 22209
Scientists investigate that which already is; engineers create that which
has never been. --Albert Einstein
---------------------------------------------------------------------
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]
---------------------------------------------------------------------