| Let
InfoBus Plug Your Beans Together Equip your JavaBeans to exchange data without knowing beans about each other |
||
| by Mark Colan and Christopher J. Karle | ||
| The InfoBus is a public specification of dynamic data-sharing technology that enables developers to equip their JavaBean components to communicate with other JavaBean components. InfoBus was jointly designed by Lotus Development Corporation and Sun Microsystems' JavaSoft division; the final release 1.1 specification, the release candidate for InfoBus 1.1, and other information about InfoBus can be found at http://www.javasoft.com/beans/infobus. InfoBus 1.1, which supports applications designed for either JDK 1.1 and 1.2, will be released soon; watch the web page for more news. |
||
| InfoBus interfaces allow
application designers to create "data flows"
between cooperating components. In contrast to an
event/response model where the semantics of an
interaction depend upon understanding an applet-specific
event and responding to that event with applet-specific
callbacks, the InfoBus interfaces have very few events
and an invariant set of method calls for all applets. The
semantics of the data flow are based on interpreting the
contents of the data that flows across the InfoBus
interfaces as opposed to responding to names of
parameters from events or names of callback parameters. Components that make up an InfoBus application can be classified in three types: Data producers: Components that respond to requests for data from consumers.Data consumers: Components interested in hearing about any new data sets that enters the environment. Data controllers: The InfoBus traffic cop. A data controller is an optional component that regulates or redirects the flow of events between data producers and consumers. A data controller is not required for the application described here.
|
||
![]() |
||
| The second applet is a data access
component (DAC). It looks for a data item (the string
representation of an employee ID from the input applet),
passes that string to a database via JDBC, and receives a
result set, which is then published on the InfoBus. The
DAC runs the query when it first receives an employee ID
and each time the ID changes. When each query is
complete, a change notification is sent regarding the
result-set data item. The DAC in this example is both a
data consumer (in that it looks for a query-string item
from the employee ID input applet on the InfoBus) and a
data producer (in that it publishes to the InfoBus a data
item containing the results of the query). The spreadsheet in this example acts as a data consumer: It looks for information published by the DAC and displays it on the screen, as shown in Figure 3. The application designer did not have to write the spreadsheet, of course: It is a commercially available Java applet designed specifically to talk to the other applications via the InfoBus. The sheet responds to change events fromt he DAC to display the results of each query. From the point of view of the InfoBus architecture, the application architecture looks a bit different. Note that the InfoBus is similar to a hardware bus; the three applets are all plugged into the same bus, as peers shown in Figure 2. In principle, all applets can see the events generated by all other applets; it is up to the application designer to control which data items will be produced or consumed by each applet. InfoBus-connected applets must all live in the same Java Virtual Machine, but that doesn't mean InfoBus can't participate in distributed applications. In our example, the DAC has a connection to a remote data source and uses JDBC to query it. |
||
![]() |
||
| Although our simple example shows
one producer for each consumer and vice versa, multiple
consumers can receive and user data published by a
producer, and a consumer can easily obtain data from
multiple producers. In fact, a request for data can
elicit multiple responses. Multiple conversations can
occur simultaneously without requiring anything special
fromt eh participating components. Overview of the InfoBus Process for
Data Exchange
Data access.InfoBus
specifies a number of standard interfaces to provide
direct data transfer between a producer and consumer. The
interfaces include Change notification. When
a consumer has received a data item from a producer, it
can request notifications of all changes to the data by
registering a Let's consider how each of these plays a role in the employee ID input applet. Implementing InfoBusMember
to Get on the Bus The following code indicates that
The
The "default InfoBus" can
be used for communication between applets on the same
browser page. A default InfoBus is one whose name is
created from the
Similarly, a data-item name should be configurable. Data-item names are used in the rendezvous; in our example the producer will offer the employee ID input as a named data item. The code below gets the data-item name and saves it for later.
Notice that
In the InfoBus model, the rendezvous is asynchronous. Data producers announce the availability of new data as it becomes ready at, say, completion of a URL read or completion of a calculation. Data consumers solicit data from producers as they require that data (at applet initialization, redraw, and so on.)
|
||
The data item is created and announced the first time the button is pushed. For the second and each successive time the button is pushed, we just set the new value.
We revoke
the data item when
Data exchange. Different data producers manage different types of data; consumers may wish to receive this data in simple or complex ways. To accommodate the needs of both producers and consumers, the InfoBus defines a determinate number of data access interfaces.
Data
controllers are potentially quite complex. They might
keep track of data producers that have offered particular
data items, and of data consumers that have requested
data items, in order to provide late binding of producer
to consumer. For our purposes, the following simple implementations will suffice:
The DAC
provides a row and column interface to the information
returned by the query. This can be done using the The
Data
Item Change Notification. The Producers
can easily implement the
Putting
It All Together The first
applet is the Remember
that the second applet, the data access component, is
both a consumer of a lookup string and the producer of a
table of data returned by a query. A parameter called Finally,
the sheet component specifies a data item name with its ![]() How
Can the Infobus Help Me? |