Defining the business model from JavaBeans classes

If the back-end application is made up of classes that fully comply with the JavaBeans™ pattern, you can integrate these classes easily using the JViews TGO wrapper for existing JavaBeans classes (see Reminder about JavaBeans design patterns). This wrapper, defined by IlpBeansClass, makes it possible to access the class as if it were a dynamic class. Business object instances also have a corresponding wrapper— IlpBeansObject—that allows the user to view them as dynamic objects.
The following figure shows the various JavaBeans wrappers that JViews TGO supplies.
tgo_business_model_beans.png
JavaBeans wrappers

Reminder about JavaBeans design patterns

JavaBeans have the following main design patterns:

Properties

Properties can be defined with a pair of get and set methods. Their names are derived from the method names. The following class contains the "severity" property:
public class Alarm {
  public int getSeverity() {...}
  public void setSeverity(int severity) {...}
}
If the getSeverity method is specified without the setSeverity method, the property is readable only.

Bound properties

Each time the value of a bound property changes, other objects are notified accordingly. A PropertyChange event is fired specifying the property name, the old value, and the new value. The IlpBeansObject class takes advantage of this process, so that each time a bound property changes, its new value is reflected in all the graphic components displaying it.

Mandatory default constructor or serialized instance

A constructor with no parameters should be available on the Bean or a serialized instance should be provided. For more information, see the instantiate method of the class java.beans.Beans .
The following example shows a Java™ class that conforms to the JavaBeans design pattern.

How to write a Java class that conforms to the JavaBeans design pattern

public static class MO {
  String name;
  int state = 0;
  PropertyChangeSupport support = new PropertyChangeSupport(this);
  public MO() {
  }
  public MO(String name) {
   this.name = name;
  }
  public String getName() {
   return name;
  }
  public void setName(String name) {
   String oldName = this.name;
   this.name = name;
   support.firePropertyChange("name",oldName,name);
  }
  public int getState() {
   return state;
  }
  public void setState(int state) {
   int oldState = this.state;
   this.state = state;
   support.firePropertyChange("state",oldState,state);
  }
  public void addPropertyChangeListener(PropertyChangeListener listener) {
   support.addPropertyChangeListener(listener);
  }
  public void removePropertyChangeListener(PropertyChangeListener
listener) {
  support.removePropertyChangeListener(listener);
  }
}
To retrieve the corresponding IlpClass, execute the following (assuming that you have a class manager):
IlpClass moAsIlpClass = classManager.get(MO.getClass().getName());
For details, see Business class manager API.
For an example of how to use this class in a data source, see Adding business objects from JavaBeans.