| Business Objects and Data Sources > The Business Model > Defining the Business Model from JavaBeans Classes |
Defining the Business Model from JavaBeans Classes |
INDEX
PREVIOUS
NEXT
|
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.
Reminder About JavaBeans Design PatternsJavaBeans have the following main design patterns: Properties
Properties can be defined with a pair of public class Alarm {
public int getSeverity() {...}
public void setSeverity(int severity) {...}
}
If the Bound properties
Each time the value of a bound property changes, other objects are notified accordingly. A 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 |
Following is an example of 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.
| Copyright © 1987-2007 ILOG S.A. All rights reserved. Documentation homepage. All rights reserved. Legal terms. | PREVIOUS NEXT |