Description: Example of a distributed DataExpress application using RMI and DataSetData
This example demonstrates the use of the DataExpress DataSetData class to build a distributed
database application.
In addition to using DataSetData objects to pass database data between an RMI server and client,
this sample also illustrates the use of a custom DataSet Provider and Resolver.
How to run this sample
What is going on
DataServerApp registers itself as an RMI server. It responds to two RMI client requests: provideEmployeeData() and resolveEmployeeChanges() defined in the RMI remote interface EmployeeApi.java.
ClientApp is simply a frame with a dbSwing JdbTable and JdbNavToolBar for displaying database data in a DataExpress TableDataSet. The DataSet uses a DataExpress "custom Provider", ClientProvider.java, to fill its table data by invoking DataServerApp's provideEmployeeData() remote method via RMI. DataServerApp subsequently queries data from a table on a JDBC database server into a QueryDataSet. It then extracts the data from the DataSet into a DataSetData object and sends it back to ClientProvider via RMI. ClientProvider then loads the data in the DataSetData object into ClientApp's DataSet, and the data appears in the table.
When it is time to resolve changes made in the table back to the database, the ClientApp DataSet's "custom Resolver", ClientResolver.java, extracts (only) the changes that need to be sent to the database server into a DataSetData object. ClientResolver then invokes DataServerApp's resolveEmployeeChanges() remote method via RMI, passing it the DataSetData object containing the necessary updates as the parameter.
DataServerApp then uses DataExpress to resolves the changes back to the database server. If an error occurs (due to a business rule or data constraint violation, for example) DataServerApp packages rows which could not be saved back to the database into a DataSetData object and returns it back to ClientResolver. ClientResolver then extracts the unresolvable rows in the DataSetData object into the ClientApp's table, allowing the problematic rows to be corrected and resolved back to the server again.
Note that DataServerApp is the "middle-tier" of the application. It can enforce its own business rules and constraints between the database server and the client. And of course, it could provide any number of additional remotely accessible methods for implementing business logic or application-specific tasks.
Metadata passed by DataSetData
The metadata passed in a DataSetData object is very limited.
Only the following Column properties are passed:
Deploying the application on 3-tiers
NOTE: Beginning with JDK 1.2, it is necessary to grant an RMI server special security rights in order for it to listen for and accept client RMI requests over a network. Typically, these rights are specified in a java security policy file defined by a special property, "java.security.policy", passed via a command-line argument to the VM of the server. This is similar to the "java.rmi.server.codebase" property which must also be passed to the server's VM. A sample RMI security policy file which will allow an RMI client to connect to the server is included with this project in the file 'SampleRMI.policy'. When starting DataServerApp on the middle-tier, make sure both the "java.security.policy" and "java.rmi.server.codebase" properties are set to the proper locations on the middle-tier machine.
For more information