ServicesTabEjbContracts

Services Tab Enterprise Java Beans 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


Contents



Introduction

When the user drag and drops a EJB or EJB method on to one of EJB the consumer (Ex. VWP designer or JSP editor), it must know the contents of DnD transferable. Similarly, after receiving the DnD, the consumer must use some API to talk to the Service manager to obtained additional meta data about the Service stored locally. For example to obtained the EJB proxy client information created while adding the EJB to the root node. So the EJB Manager, which manager the nodes must publish some public contracts (API's) to be used by the consumer like

  • A Contract between the consumer and the Nodes in the Services tab from which DnD gets initiated.
  • A Contract between the consumer and the EJB Manager to get meta data information about the dropped EJB.

EJB Meta-data descriptor

The meta data descriptor describes about the EJB added to the repository. For example, the Metadata descriptor for JavaTraveller EJB would contains the following information


<?xml version="1.0" encoding="UTF-8"?>
<ServiceType name="EJB">
   <EJB name="JavaTraveller" displayName="JavaTraveller">
      <Jar name="JavaTraveller.jar" type="proxy-ja">
      <Jar name="JavaTraveller_dt.jar" type="designtime"/>
       ...
   </EJB>
</ServiceType>

EJB manager and consumer add help contract

When the EJB is added to repository via the Web Services, a proxy client of the EJB is created and stored in the Meta Data repository of the added EJBs.

Also, In order to minimize the time between the drop of DnD and the corresponding binding to appear in the designer, the VWP EJB consumer would like to generate additional jars, like designtime jars, when the EJB is add. These may not be required by other EJB Consumer module. Since the EJB Manager does not know how to create these consumer specific meta-data, the solution may be to provide an option for the Consumer modules to participate in the service adding process. This could be achieved by the EJB Manager publishing some public contract

Assume, EJB manager published a interface API called EjbManagerExtension, which can be implemented by the consumers and then register it as service via Java Extension mechanism. Then EJB Service manager can look up this extended service and call the implemented method to allow the consumer to create additional meta-data required.

Ex.


Interface EjBManagerExtension{
  public boolean ejbAddedExtension(File ejbMetadataDesc);
  public boolean ejbRemovedExtension(File ejbMetadataDesc);
}

The Consumer Module like VWP W/S service consumer would implement the extension as

public final class VwpEjbManagerExtensionImpl implements EjbManagerExtension{
    public boolean ejbAddedExtension(File ejbMetadataDesc){
         // Get the proxy jar as define in the metadata descriptor
         // Create the wrapper class and add it to the proxy jar 
         // Create the design time jar add to location ejbMetadataDesc.getParentFile()
         return true; // false if creation failed
    }
} 

Now, the additional step taken by Web Serice Manager while adding the service is

public final class  EjbServiceManager{
   public boolean addEjb(Ejb ejb){
       // Add the EJB to repository location 
       ...
       // Call the W/S add extensions
       EjbManagerExtension[] ejbExts = Lookup.lookup("EjbManagerExtension");
       for (for int i = 0; I < ejbExs.lenght; i++){
            ejbExts[I].ejbAddedExtension(ejbDesc); 
       }
       fireWebServiceAdded(ejb);
   }
...
}


Drag and Drop Contract

The contract that explains the contents of the DnD Transferable (Data Flavors & transfer data etc). The Web Service manager Module must publish the contract explaining the contents of the Transferable, Data Flavors etc. This information is used by the Service Helper (or by the Service Client as explained above). Here is an example of DnD Contract that could be published by Web Service manager module. The WsInfo class is sent as Transfer data

public final class EjbMetaDataTransfer 
  // For W/S drag and drop
  public static DataFlavor EJB_FLAVOR;
  public static final class EjbInfo{
     private final EjbDescriptor ejbDescriptor;
     ...
  }  
  // For W/S method drag and drop
  public static DataFlavor EJB_METHOD_FLAVOR;
  public static final class EjbMethodInfo{
     private final EjbMethodDescriptor ejbMethodDescriptor;
     ...
  }  
} 

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

    DataFlavor supportedFlavor = EjbMetaDataTransfer.EJB_FLAVOR;
    if (transferable.isDataFlavorSupported(supportedFlavor)){
        transferData = transferable.getTransferData(supportedFlavor);
            EjbMetaDataTransfer.EjbInfo wsInfo =  
                (EjbMetaDataTransfer.EjbInfo) transferData;
            // Obtain the EJB descriptor  
            EjbDescriptor wsDesc = 
                (EjbDescriptor)wsInfo.getEjbDescriptor();
            // Now use EjbDescriptor as needed
        }
    }

The EjbDescriptor is one of the Service Meta-data Contract APIs published by the EJB Manager, for the consumer to interact as explained below.

EJB Meta data Contract

The EJB manager keeps information about the EJBs displayed in the EJB root node. So in order for consumer to get these information it must publish set of API. For example, after the consumer gets the EjbInfo from the DnD transferable, it needs to get the additional Metadata information. So the EJB manager module would publish the following public API, whose implementation could be reached via the DnD contract as explained above

public interface EJBDescriptor {
     public WSDL getDeploymentDesc(); 
     public File getProxyJar(); 
     public File getDescriptor(); 
     public String getDisplayName();
}

The Service Consumer would either get the proxy Jar and add it to the project or get the Deployment and creates its own proxy and then inject the relevant source to the JSP Editor. Once, the EJB information is obtained from the transferable it is up to the consumer to consume the service.

For example, VWP designer might create a dataprovider using the wrapper class it added to the proxy jar and then binds it to a component in the page.

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