This section lists a few of the uses for the JBeans package as well as some applications that the
JBeans package has been used in.
An O/R Mapping Tool
One project that the JBeans package has been used in or could be used in in the future would be
an Object-to-Relational mapping tool. These tools are used to map relational databases to Java
objects. Normally Java beans are used because they provide such a standard interface for accessing
properties. One such example is the DataMap package by XiriTech (XiriTech.com). This package was
built on top of the JBeans package.
The way that this type of tool would use JBeans would be that SQL queries would be executed against
a relational database and the results would be stored into Java beans. Ideally, the only thing that
the O/R mapping tool would need to know would be the Java bean's class and the properties that would
map to the columns return from the SQL query. This makes JBeans an ideal candidate for a Java bean
framework. The reason is that JBeans only uses the Java bean's class and the name of the property in
order to access those properties.
For example, the DataMap package is setup using XML files and that is where the mapping takes place.
The mapping looks something like:
<column table="..." property="firstName">first_name</column>
This would map the column named first_name to the firstName property
of a Java bean. The DataMap package can then look in the result set of a query and determine the
value of the first_name column and use the Jbeans package to set the property to
the value.
An MVC framework
Another area that could make use of the JBeans project would be a MVC framework. An example of a
MVC framework is the Struts project from Jakarta-Apache. This framework uses Java beans as its model
component. In order to facilitate the transfer of information from the view component (in Struts,
the view is JSP pages) to the model, the framework needs to have access to the Java bean properties.
This is where JBeans would come in. The view would tell the framework the name of the property and
the framework would know the class of the Java bean (normally from an XML configuration file). Then
the framework would use the JBeans package to access the Java bean properties.
Just like the O/R mapping tool, the Merlin framework from XiriTech (XiriTech.com) uses the JBeans
package for access to Java bean properties. This framework functions similarly to the Apache Structs
framework but it adds the ability of auto-conversion of properties. The discussion of Frameworks is
out of the scope of this document, but it is a good example of something that could make use of
JBeans.
An XML-to-JavaBean conversion system
Another good example of a use for JBeans would be a package that converted XML into Java beans. This
conversion would take the values from the XML and store them into an existing Java bean's properties.
The system could use the attributes of an XML element as Java bean property values. Here's a simple
XML element that could be converted:
<Address city="Boulder" state="CO"></Address>
This XML would cause the setCity() and setState() property methods to be called with the values,
Boulder and CO respectively, on some Java bean. The JBeans package could handle all of that
functionality. The name of the attribute is the name of the property and the bean class could be the
name of the element (ie Address). The converter could then retrieve the value of the attribute (ie
Boulder) and using BeanProperty, set the property value for some Java bean instance.
These are just a few examples of how JBeans could be used. Of course JBeans is flexible enough that
it could be used in nearly any application that used Java beans.
|