Brought to you by EarthWeb
ITKnowledge Logo Login Graphic Click here to enter the Java Zone
Click here to enter the Java Zone
ITKnowledge
Search this book:
 
Search the site:
 
EXPERT SEARCH ----- nav

EarthWeb Direct

EarthWeb Direct

EarthWeb sites: other sites

Previous Table of Contents Next


CarSupplierServer.java

The CarSupplierServer class is the RMI server class. It creates three instances of CarFactory and binds them to the RMI registry. A simple string names the bindings to allow clients to perform lookups in the registry. Listing 10-28 shows the source code for CarSupplierServezr.java.

Listing 10-28: CarSupplierServer.java.

//
// CarSupplierServer.java
//
// (C) 1996 Wim De Munck mailto: wimdm@dm-mediaware.be
//
import java.rmi.Naming;
class CarSupplierServer {
  public static void main ( String args[] ) {
  // Install a SecurityManager for this server
      System.setSecurityManager( new java.rmi.RMISecurityManager() );
      // create and register all CarFactories
      System.out.println ( "Creating Car Factories" );
      CarFactoryImpl audi, bmw, vw ;
      try {
           audi = new CarFactoryImpl("Audi");
           bmw = new CarFactoryImpl("BMW");
           vw = new CarFactoryImpl("Volkswagen");
      } catch ( Exception ex ) {
           ex.printStackTrace();
           return;
      }
      System.out.println ( "Registring Car Factories" );
      try {
           Naming.bind("CarFactory.audi", audi);
           Naming.bind("CarFactory.bmw", bmw);
           Naming.bind("CarFactory.vw", vw);
      } catch ( java.net.MalformedURLException ex ) {
           ex.printStackTrace();
      } catch ( java.rmi.AlreadyBoundException ex ) {
           ex.printStackTrace();
      } catch ( java.rmi.RemoteException ex) {
           ex.printStackTrace();
      }
  }
}

RMI, as defined and implemented by JavaSoft, Inc., is HTTP-proxy aware. The networking layer of RMI provides server- and client-side transparent support for HTTP tunneling that allows applets to communicate with remote methods and remote objects through WWW proxy servers. A final note for those who want to run RMI on a stand-alone machine: A TCP/IP stack must be running on the machine to let RMI clients and servers communicate.

Summary

This chapter provided examples of JDBC in the form of Java applets or stand-alone applications. Each example covered a specific topic discussed in earlier chapters. The source code of all the examples is on the accompanying CD-ROM.

Examples discussed in this chapter include:

  A simple ISQL client
  Handling BLOBS from the command line
  A Java Automatic Teller Machine
  Fly with JDBC Airlines
  A graphical database surfer
  An advanced example using Remote Method Invocation


Previous Table of Contents Next
HomeAbout UsSearchSubscribeAdvertising InfoContact UsFAQs
Use of this site is subject to certain Terms & Conditions.
Copyright (c) 1996-1999 EarthWeb Inc. All rights reserved. Reproduction in whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.