Services Tab Database Connection Public Contracts

Modificaion History
Winston Prakash: Feb 8, 2007

Note: This is just sample or a starter document to start the discussion based on Services Tab Architecture. Does not correctly reflect the implementation details. Need to be re-written by the Service Type implementor. - Winston



When the user drag and drops a Table, View or Stored Procedure from the database connection on to one of the consumer (Ex. VWP designer or JSP editor), it must know the contents of DnD transferable. Similarly, after receving the DnD, the consumer must have some API to talk to the producer (database connections manager), to get information about the connection. So, Database Connections Node (or its manager), must publish two public contracts (API's) for consuming the

  • A Contract between the consumer and the Nodes in the Services tab from which DnD gets initiated.
  • A Contract between the consumer and the database connections manager to get information about the connections.

Drag and Drop Contract

The contract that explains the contents of the DnD Transferable (Data Flavors & transfer data etc). The Service Producer Module must publish the contract explaining the contents of the Transferable, Data Flavors etc. This information is used by the consumer. Here is an example of DnD Contract published by database service module. The TableInfo class is sent as Transfer data

public final class DatabaseMetaDataTransfer 
  // For view drag and drop
  public static DataFlavor TABLE_FLAVOR;
  public static final class TableInfo{
     private final DatabaseConnection dbconn;
  // For view drag and drop
  public static DataFlavor VIEW_FLAVOR;
  public static final class ViewInfo{
     private final DatabaseConnection dbconn;

The Database Service Consumer can now obtain the TableInfo from the DataFlavor as follows.

    DataFlavor supportedFlavor = DatabaseMetaDataTransfer.TABLE_FLAVOR;
    if (transferable.isDataFlavorSupported(supportedFlavor)){
        transferData = transferable.getTransferData(supportedFlavor);
            DatabaseMetaDataTransfer.TableInfo tableInfo =  
                (DatabaseMetaDataTransfer.TableInfo) transferData;
            // Obtain the database connection from the 
            DatabaseConnection dbConnection = 
            // Now use DatabaseConnection as needed

The DatabaseConnection is one of the Service Meta-data Contract APIs published by the Database Connections Manager, for the consumer to interact with as explained below.

Service Meta data Contract

The Database Connections manager keeps information about the connections displayed in the module. So in order for consumer to get these information it must publish set of API. For example, after the consumer gets the TableInfo from the DnD transferable, it needs to get the connection information. So the Database Service module would publish the following public API, whose implementation could be reached via the DnD contract as explained above

public interface DatabaseConnection {
     public String getDriverClass(); 
     public String getDatabaseURL(); 
     public String getPassword(); 
     public String getUser();

The Service Consumer would create a DataSource object from the DatabaseConnection and add it to the project or inject the relevant source to the JSP. Once, the Table or View information is obtained from the transferable it is up to the consumer to consume the service.

For example, VWP designer might create a Data Source from the database connection and add the datasource info to a dataprovider and binds it to a component in the page.

On the other hand, the Matisse GUI designer might create a JPA entity using the database connection information obtained via above contract and binds it to the components using beans binding.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo