20.8. Salience State Example: Inserting a Dynamic Fact

// By setting dynamic to TRUE, JBoss Rules will use JavaBean
// PropertyChangeListeners so you don't have to call modify or update().
final boolean dynamic = true;

session.insert( fact, dynamic );
  • For the engine to see and react to changes of fact properties, the application must tell the engine that changes occurred. This can be done explicitly in the rules by using the modify statement, or implicitly by letting the engine know that the facts implement PropertyChangeSupport as defined by the JavaBeans specification.
  • The above example demonstrates how to use PropertyChangeSupport to avoid the need for explicit modify statements in the rules.
  • Ensure that your facts implement PropertyChangeSupport, the same way the class org.drools.example.State does.