Bound Gooey Beans
In the Gooey Beans Info prequel, we explicitly declare properties. Now we allow a bean info instance to be bound to a specific bean, in order to support bound properties ie. firing PropertyChangeEvent's.
A part of "Gooey Beans, a trilogy in 42 parts"
In our bean, we instantiate a bound bean info class with PropertyChangeSupport as follows.
where we use property "literals" from our bean info to firePropertyChanged().
We can add PropertyChangeListener's as follows.
Code Snippet
public class BakedBean {
public final BakedBeanInfo info = new BakedBeanInfo(this);
private BigInteger barcode;
private String label;
private Integer bakingTemparature;
private BigDecimal medianLength;
...
public BakedBean() {
}
...
public void setBarcode(BigInteger barcode) {
this.barcode = barcode;
info.barcode.firePropertyChanged(barcode);
}
}
public class BakedBeanDemo implements PropertyChangeListener, Runnable {
BakedBean bean = new BakedBean();
...
public BakedBeanDemo() {
...
bean.info.getPropertyChangeSupport().addPropertyChangeListener(this);
}
...
}





