Java Applets as Data ProvidersJava Applets as Data Providers*
*



Contents  *



Index  *Topic Contents
*Previous Topic: OLE-DB Simple Provider: A Data Binding API for IE4/MSHTML
*Next Topic: OLE-DB Simple Provider for Java: A Data Binding API for IE4/MSHTML

Java Applets as Data Providers

To date, IE4/MSHTML has supported ActiveX™ Controls as data providers when present on an HTML page and when the control supports either the OLE-DB Simple Provider interface or is an instance of the Advanced Data Connector (ADC), which provides OLE-DB interfaces. Note that ADC is the only OLE-DB interface supported in release 1.0 of IE4/MSHTML. As Java becomes more prevalent on the Internet, it will be desirable for IE4/MSHTML to support writing data sources in Java using JavaBeans.

The remainder of this article specifies the conventions to be used when constructing data-providing applets in Java. The internal IE4/MSHTML data binding agent implements support to detect and utilize such applets similar to the current support for ActiveX Controls.

arrowy.gifOverview

arrowy.gifRecognizing Java Applets as Data Providers

arrowy.gifNotifications for Data Set Changes

Overview

Although IE4/MSHTML 1.0 will only support third-party providers that implement the OLE-DB Simple Provider interface, this specification is constructed to allow support for additional provider types when IE4/MSHTML adds support for those providers. All references to the OSP interfaces in this specification can be summarily changed to any of the additional provider interfaces supported by IE4/MSHTML.

Recognizing Java Applets as Data Providers

The applet writer needs a way to allow the IE4/MSHTML binding agent to detect the Java applet as a data provider. The most straightforward way to accomplish this is for the applet to implement a well-known method that the IE4/MSHTML binding agent will call to recognize the applet. The method will have the following signature:

public Object msDataSourceObject( String qualifier );

The qualifier parameter will be used when a data-providing applet supports access to more than one set of data. When the parameter is NULL or a null string (""), the applet should return the data interface on its default data set. What constitutes the default data set is left to the applet.

IE4/MSHTML 1.0 will only support applets that provide a single data set; therefore, it will use only the msDataSourceObject("") form of the call when invoking the interface.

Notifications for Data Set Changes

There are instances where a consumer already has an interface to a data set supplied by an applet, and the shape of the data set changes. For example, the number of columns changes, the name of the columns changes, the type of a column(s) changes, or the entire data set is reordered (result of a sort operation). In such an instance, there needs to be a way for the consumer to get notified of the change so it can retrieve a new interface on the (changed) data—using a call to msDataSourceObject. Consumers will do this by registering with the provider for a notification.

The applet must support a method whereby the consumer can register for receiving such notifications. The method has the following signature:

public void addDataSourceListener( DataSourceListener listener )
    throws java.util.TooManyListenersException;

IDataSourceListener is defined as follows:

public abstract interface DataSourceListener
{
   void dataMemberChanged( String qualifier );
   void dataMemberAdded( String qualifier );
   void dataMemberRemoved( String qualifier );
}

When a data change occurs, the applet will call the dataMemberChanged method on the DataSourceListener interface to notify the data consumer that the shape has changed. The qualifier will indicate which data interface has changed (for IE4/MSHTML 1.0, this will be ignored since data sources can only expose a single data set).

Finally, a data consumer must notify a provider that it is no longer interested in data-shape-change notifications by calling the following method:

public void removeDataSourceListener(
    DataSourceListener listener);

The DataSourceListener should be identical to the one passed to addDataSourceListener.


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.