home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 2.8 KB | 80 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
- * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
- * THE PRODUCT.
- *
- * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
- * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
- * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
- * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
- * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
- * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
- * CODE FILE.
- */
-
- //Title: JBuilder Tutorial
- //Version: 2.0
- //Copyright: Copyright (c) 1998
- //Author: Jens Ole Lauridsen
- //Company: Borland Int'l
- //Description: Tutorial of Distributed Computing using RMI and DataSetData.
-
- package borland.samples.tutorial.dataset.datasetdata;
-
- import borland.jbcl.dataset.*;
- import java.rmi.*;
- import java.util.*;
-
- // The ClientProvider class is an implementation of a Provider.
- //
- class ClientProvider extends Provider {
- ResourceBundle res = Res.getBundle("borland.samples.tutorial.dataset.datasetdata.Res");
-
- // provideData
- // Implementation of method in borland.jbcl.dataset.Provider
- // We lookup the "DataServerApp" service on the host specified by the
- // HostName property. Then make the remote method call: provideEmployeeData
- // and load our dataSet with the contents.
- //
- public void provideData(StorageDataSet dataSet, boolean toOpen) throws DataSetException {
- try {
- String serverName = "//" + hostName + "/DataServerApp";
- EmployeeApi server = (EmployeeApi)Naming.lookup(serverName);
- DataSetData data = server.provideEmployeeData();
- dataSet.empty();
- data.loadDataSet(dataSet);
- }
- catch (NotBoundException ex) {
- throw new DataSetException(res.getString("RS_NoServer"));
- }
- catch (DataSetException ex) {
- throw ex;
- }
- catch (Exception ex) {
- String error = ex.getMessage();
- if (error == null)
- error = res.getString("RS_NoConnect")+hostName;
- throw new DataSetException(error);
- }
- }
-
- // The HostName property is used to locate the "DataServerApp" service
- // through RMI. By default we just look at our local machine.
- //
- public String getHostName() {
- return hostName;
- }
-
- public void setHostName(String hostName) {
- this.hostName = hostName;
- }
-
- private String hostName = "localhost";
- }
-