Esercizio RMI. Server import java.io.*; class Item implements Serializable { private String category, itemNumber, descr; private int value, cost, bidder,

Slides:



Advertisements
Similar presentations
Remote method invocation. Introduction First introduced in JDK 1.1. Allows distributed Java programs to work with each others by behaving as if they are.
Advertisements

Outline DivideByZeroTes t.java 1 // Fig. 15.1: DivideByZeroTest.java 2 // An exception-handling example that checks for divide-by-zero. 3 import java.awt.*;
 2003 Prentice Hall, Inc. All rights reserved. Chapter 15 – Exception Handling Outline 15.1 Introduction 15.2 Exception-Handling Overview 15.3 Exception-Handling.
 2002 Prentice Hall, Inc. All rights reserved. Chapter 14 – Exception Handling Outline 14.1 Introduction 14.2 When Exception Handling Should Be Used 14.3.
James Tam Simple File Input And Output Types of Java Files Simple File Output in Java Simple File Input in Java.
James Tam Simple File Input And Output Types of Java Files Simple File Output in Java Simple File Input in Java.
James Tam Exception handling in Java Java Exception Handling Dealing with errors using Java’s exception handling mechanism.
James Tam Simple file handling in Java Simple File Input And Output Types of Java files Simple file output in Java Simple file input in Java.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
James Tam Simple File Input And Output You will learn how to write to and read from text and serialized files in Java.
Introduction to Remote Method Invocation (RMI)
James Tam Simple File Input And Output Types of Java Files Simple File Output in Java Simple File Input in Java.
Client/Server example. Server import java.io.*; import java.net.*; import java.util.*; public class PrimeServer { private ServerSocket sSoc; public static.
Java Remote Object Invocation (RMI) Overview of RMI Java RMI allowed programmer to execute remote function class using the same semantics as local functions.
Layout Mangers CSC 171 FALL 2001 LECTURE 14. History: The Transistor William Shockley, John Bardeen, and Walter Brattain invent the transfer resistance.
James Tam Simple File Input And Output Types of Java Files Simple File Output in Java Simple File Input in Java Writing and reading objects to and from.
Variable Scope Brackets, brackets…. brackets. Variable Scope /** * HelloWorld --- program that prints something to the screen. Blanca Polo */
CSE 341, S. Tanimoto Java networking- 1 Java Networking Motivation Network Layers Using Sockets A Tiny Server Applets URLs Downloading Images, MediaTracker.
Web Proxy Server. Proxy Server Introduction Returns status and error messages. Handles http CGI requests. –For more information about CGI please refer.
Io package as Java’s basic I/O system continue’d.
Java Exception Handling Handling errors using Java’s exception handling mechanism.
Example 1 :- Handling integer values public class Program1 { public static void main(String [] args) { int value1, value2, sum; value1 = Integer.parseInt(args[0]);
CC1007NI: Further Programming Week 8-9 Dhruba Sen Module Leader (Islington College)
1 Java Programming II Java Network II (Distributed Objects in Java)
Introduction Files –Long-term storage of large amounts of data –Persistent data exists after termination of program –Files stored on secondary storage.
Chapter 4 Distributed objects and Remote Method Invocation
CS 584 Lecture 18 l Assignment » Glenda assignment extended to the Java RMI Deadline » No Java RMI Assignment l Test » Friday, Saturday, Monday.
Very Brief Introduction to Java I/O with Buffered Reader and Buffered Writer.
15 - RMI. Java RMI Architecture Example Deployment RMI is a part of J2SE (standard edition), but is used by J2EE) A J2EE server is not nessesary for using.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
1 Why layout managers Can we perform layout without them? –Yes. A container’s layout property can be set to null. Absolute positioning: specify size and.
UDP vs TCP UDP Low-level, connectionless No reliability guarantee TCP Connection-oriented Not as efficient as UDP.
LAB 1CSIS04021 Briefing on Assignment One & RMI Programming February 13, 2007.
RMI Continued IS Outline  Review of RMI  Programming example.
Networks Sockets and Streams. TCP/IP in action server ports …65535 lower port numbers ( ) are reserved port echo7 time13 ftp20 telnet23.
 Remote Method Invocation  A true distributed computing application interface for Java, written to provide easy access to objects existing on remote.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 25 – Ticket Information Application Introducing.
Li Tak Sing COMPS311F. RMI callbacks In previous example, only the client can initiate a communication with the server. The server can only response to.
CS101 Lab “File input/Output”. File input, output File : binary file, text file READ/WRITE class of “text file” - File Reading class : FileReader, BufferedReader.
Java Server Programming Web Interface for Java Programs.
1 Java Remote Method Invocation java.rmi.* java.rmi.registry.* java.rmi.server.*
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 24.1 Test-Driving the Enhanced Car Payment.
CSI 3125, Preliminaries, page 1 Java I/O. CSI 3125, Preliminaries, page 2 Java I/O Java I/O (Input and Output) is used to process the input and produce.
By Vivek Dimri. Basic Concepts on Networking IP Address – Protocol – Ports – The Client/Server Paradigm – Sockets The Java Networking Package – The InetAddress.
Exceptions. Exception  Abnormal event occurring during program execution  Examples Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
Creating a GUI Class An example of class design using inheritance and interfaces.
1 Layout Managers Layout managers –Provided for arranging GUI components –Provide basic layout capabilities –Processes layout details –Programmer can concentrate.
Java Input/Output. Java Input/output Input is any information that is needed by your program to complete its execution. Output is any information that.
import java.io.*; public class Customer implements Serializable { public Customer(int theAge, int theSex, String[] theHobbies) { age = theAge; sex.
James Tam Java Exception Handling Handling errors using Java’s exception handling mechanism.
Using RMI The Example of A Remote Calculator 1. Parts of A Working RMI System A working RMI system is composed of several parts. –Interface definitions.
Chapter 14 – Exception Handling
Principles of Software Development
CSE 341, S. Tanimoto Java networking-
Simple File Input And Output
Accessing Files in Java
Remote Method Invocation
Java RMI (more) CS-328 Internet Programming.
CS Week 11 Jim Williams, PhD.
Operators Laboratory /11/16.
הרצאה 12: קבצים וחריגות (Exceptions)
null, true, and false are also reserved.
Reading and Writing Text Files
Simple File Input And Output
Using RMI -The Example of A Remote Calculator
Simple File Input And Output
Web Design & Development Lecture 8
CS 584 Lecture 18 Assignment Glenda assignment extended to the Java RMI Deadline No Java RMI Assignment Test Friday, Saturday, Monday.
Chapter 15 – Exception Handling
Java Chapter 5 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Esercizio RMI

Server

import java.io.*; class Item implements Serializable { private String category, itemNumber, descr; private int value, cost, bidder, bidAmount, code; public Item () { category ="";itemNumber ="";descr ="";value = 0;cost = 0;bidder =-1;bidAmount = 0;code = 0; } public Item(String num, String pdescr, int pval) { category = ""; itemNumber = num; descr = pdescr; value = pval; cost = 0; bidder = -1; bidAmount = 0;code = 0; } public Item(String num, String pdescr, int pval, int pcost) { category = ""; itemNumber = num; descr = pdescr; value = pval; cost = pcost; bidder = -1; bidAmount = 0; code = 0; } 3

public void setCategory (String val) { category= val; } public String getCategory () { return category; } public void setItemNumber(String val) { itemNumber = val; } public String getItemNumber () { return itemNumber; } public void setDescr (String val) { descr = val; } public String getDescr () { return descr; } public void setValue (int val) { value = val; } public int getValue () { return value; } public void makeBid (int pbidder, int pbid) { bidder = pbidder; bidAmount = pbid; } public int getBidder() { return bidder; } public int getBidAmount() { return bidAmount; } 4

public int getDonationAmount () { if (value >= bidAmount) return 0; else return bidAmount - value; } public int getProfitAmount () { return bidAmount - cost; } public void setCode (int val) { code = val; } public int getCode () { return code; } 5

public void inFromCVS ( String arg) { System.out.println (arg); String[] results = getFromCVSForm (arg); category = results[0]; results = getFromCVSForm (results[1]); itemNumber = results[0]; results = getFromCVSForm (results[1]); descr = results[0]; results = getFromCVSForm (results[1]); try{ value = Integer.parseInt (results[0]); } catch (NumberFormatException e) { value = 0; } results = getFromCVSForm (results[1]); try{ bidder = Integer.parseInt (results[0]); } catch (NumberFormatException e) { bidder = -1; } results = getFromCVSForm (results[1]); try{ bidAmount = Integer.parseInt (results[0]); } catch (NumberFormatException e) { bidAmount = 0; } } 6

static public String [] getFromCVSForm (String arg) { String[] results = new String[2]; int endPos=1; boolean goOn=true; if (arg.length() == 0) { results[0] = ""; results[1] = ""; } else if (arg.charAt(0) == '\"') { while (goOn) { if (arg.charAt(endPos) != '\"') endPos++; else if (endPos+1 >= arg.length()) goOn = false; else if (arg.charAt(endPos+1) == '\"') endPos = endPos + 2; else goOn = false; } String temp = arg.substring (1,endPos); results[0] = temp.replaceAll("\"\"", "\""); results[1] = arg.substring (endPos+2); } else { results = arg.split (",", 2); } return results; } 7

public String outAsCVS () { return putInCVSForm(category) + "," + putInCVSForm(itemNumber) + "," + putInCVSForm (descr) + "," + value + "," + bidder + "," + bidAmount; } static public String putInCVSForm (String arg) { String retString = ""; boolean putInQuotes = false; if (arg.contains(",") || arg.contains("\"")) { putInQuotes = true; retString = retString + "\""; } String[] result = arg.split ("\"", -1); retString = retString + result[0]; for (int i = 1; i < result.length; i++) retString = retString + "\"\"" + result[i]; if (putInQuotes) retString = retString + "\""; return retString; } 8

public static void main (String[] args) { Item i1 = new Item("1", "Hello There", 50); System.out.println (i1.outAsCVS()); i1 = new Item("1", "Hello, There", 50); System.out.println (i1.outAsCVS()); i1 = new Item("1", "Hello \" There", 50); System.out.println (i1.outAsCVS()); i1.inFromCVS ("Category 1,1,\"Hello, \"\"The\"\"re\",50,-1,0"); System.out.println ("Category: " + i1.getCategory()); System.out.println (i1.getItemNumber()); System.out.println (i1.getDescr()); System.out.println (i1.getValue()); System.out.println (i1.getBidder()); System.out.println (i1.getBidAmount()); System.out.println (); i1.inFromCVS (",,,,"); System.out.println (i1.getItemNumber()); System.out.println (i1.getDescr()); System.out.println (i1.getValue()); System.out.println (i1.getBidder()); System.out.println (i1.getBidAmount()); } 9

import java.io.*; import java.util.*; import java.util.Map; import java.util.TreeMap; import java.util.Iterator; import java.rmi.*; public interface DataControl extends Remote{ public void readBidders (String filename) throws RemoteException; public void writeBidders (String filename) throws RemoteException; public void readItems (String filename) throws RemoteException; public void writeItems (String filename) throws RemoteException; public Item makeBid (int bnum, String inum, int bamount, boolean noCheck) throws RemoteException; public boolean validateItemNumber (String inum) throws RemoteException; public boolean validateBidderNumber (int bnum) throws RemoteException; public Vector getItemsForBidder (int bidderNum) throws RemoteException; public Vector findBidderNumber (String s) throws RemoteException; public Bidder getBidderRecord (int bnum) throws RemoteException; public boolean updateBidderRecord (Bidder newBidder) throws RemoteException; public int getNextCashierNum () throws RemoteException; } 10

import java.io.*; import java.util.*; import java.util.Map; import java.util.TreeMap; import java.util.Iterator; public class DataControlImpl extends java.rmi.server.UnicastRemoteObject implements DataControl { private SortedMap bidders; private SortedMap items; private int cashierNumber; public DataControlImpl ()throws java.rmi.RemoteException { super(); bidders = Collections.synchronizedSortedMap(new TreeMap () ); items = Collections.synchronizedSortedMap(new TreeMap () ); cashierNumber = 0; } 11

public void readBidders (String filename) throws java.rmi.RemoteException { try { String s1; Bidder b1; BufferedReader br = new BufferedReader (new FileReader (filename)); s1 = br.readLine(); while (s1 != null) { b1 = new Bidder(); b1.inFromCVS(s1); bidders.put ( b1.getBidNumber(), b1); s1 = br.readLine(); } br.close(); } catch ( Exception e ) { e.printStackTrace(); } } 12

public void writeBidders (String filename)throws java.rmi.RemoteException { try { // Set up the output file FileWriter fw = new FileWriter (filename); BufferedWriter bw = new BufferedWriter (fw); PrintWriter pw = new PrintWriter (bw); // for all items in the TreeMap for (Map.Entry e : bidders.entrySet()) pw.println(e.getValue().outAsCVS() ); pw.close(); } catch ( Exception e ) { e.printStackTrace(); } } 13

public void readItems (String filename) throws java.rmi.RemoteException { String s1; Item i1; try { BufferedReader br = new BufferedReader (new FileReader (filename)); s1 = br.readLine(); while (s1 != null) { i1 = new Item(); i1.inFromCVS(s1); items.put ( i1.getItemNumber(), i1); s1 = br.readLine(); } br.close(); } catch ( Exception e ) { e.printStackTrace(); } 14

public void writeItems (String filename) throws java.rmi.RemoteException { try { // Set up the output file FileWriter fw = new FileWriter (filename); BufferedWriter bw = new BufferedWriter (fw); PrintWriter pw = new PrintWriter (bw); // for all items in the TreeMap for (Map.Entry e : items.entrySet()) pw.println(e.getValue().outAsCVS() ); pw.close(); } catch ( Exception e ) { e.printStackTrace(); } 15

public Item makeBid (int bnum, String inum, int bamount, boolean noCheck) throws java.rmi.RemoteException { Item returnItem = new Item(); Item bidItem; if (!items.containsKey (inum)) { // verify item exists returnItem.setCode (-2); // no such item exists return returnItem; } if (!bidders.containsKey (bnum)) {// verify bidder exists returnItem.setCode (-4); // no such bidder exists return returnItem; } bidItem = items.get (inum ); // get item from Item Map if (noCheck == false && bidItem.getBidder() != -1) {// check if a bid has been made returnItem.setCode (-3); // item already has bid returnItem.makeBid (bidItem.getBidder(), bidItem.getBidAmount()); return returnItem; } bidItem.makeBid (bnum, bamount); // store the bid returnItem.setCode (1);// successful bid return returnItem; } 16

public boolean validateItemNumber (String inum) throws java.rmi.RemoteException { if (items.containsKey (inum)) return true; else return false; } public boolean validateBidderNumber (int bnum) throws java.rmi.RemoteException { if (bidders.containsKey (bnum)) return true; else return false; } 17

public Vector getItemsForBidder (int bidderNum) throws java.rmi.RemoteException { Vector itemVector = new Vector (); for (Map.Entry e : items.entrySet()) { if (e.getValue().getBidder() == bidderNum) { itemVector.addElement (e.getValue() ); } } return itemVector; } public Vector findBidderNumber (String s)throws java.rmi.RemoteException { Vector bidderVector = new Vector (); for (Map.Entry e : bidders.entrySet()) { if (e.getValue().getName().toLowerCase().startsWith(s.toLowerCase())) { bidderVector.addElement(e.getValue()); } return bidderVector; } 18

public Bidder getBidderRecord (int bnum) throws java.rmi.RemoteException { if (validateBidderNumber(bnum)) return bidders.get(bnum); else return null; } public boolean updateBidderRecord (Bidder newBidder) throws java.rmi.RemoteException { if (validateBidderNumber(newBidder.getBidNumber())) { bidders.put (newBidder.getBidNumber(), newBidder); return true; } else return false; } public int getNextCashierNum () throws java.rmi.RemoteException { cashierNumber ++; return cashierNumber; } 19

static public void main (String[] args) { try { DataControlImpl dc = new DataControlImpl (); dc.readBidders ("Bidders.csv"); dc.writeBidders ("outBid.txt"); dc.readItems ("Items.csv"); dc.writeItems ("outItem.txt"); } catch (Exception e) { e.printStackTrace(); } } 20

import java.io.*; public class Bidder implements Serializable { private int bidNumber; private String lname; private String fname; private String phone; private int cashAmount; private int checkAmount; private int checkNumber; private int chargeAmount; private int chargeAmount2; private int cashierNum; private int code; public Bidder() { bidNumber = -1; lname = ""; fname = ""; phone = ""; cashAmount = 0; checkAmount = 0; checkNumber = -1; chargeAmount = 0; chargeAmount2 = 0; cashierNum = 0; code = 0; } public Bidder(int num, String pName) { bidNumber = num; lname = pName; fname = ""; phone = ""; cashAmount = 0; checkAmount = 0; checkNumber = -1; chargeAmount = 0; chargeAmount2 = 0; cashierNum = 0; code = 0; } 21

public void setBidNumber(int val) { bidNumber = val; } public int getBidNumber () { return bidNumber; } public void setName (String val) { lname = val; } public String getName () { return lname + ", " + fname; } public void setLName (String val) { lname = val; } public String getLName () { return lname; } public void setFName (String val) { fname = val; } public String getFName () { return fname; } public void setPhone (String val) { phone = val; } public String getPhone () { return phone; } public void setCashAmount (int val) { cashAmount = val; } public int getCashAmount () { return cashAmount; } public void setCheckAmount (int val) { checkAmount = val; } public int getCheckAmount () { return checkAmount; } public void setCheckNumber (int val) { checkNumber = val; } public int getCheckNumber () { return checkNumber; } public void setChargeAmount (int val) { chargeAmount = val; } public int getChargeAmount () { return chargeAmount; } public void setChargeAmount2 (int val) { chargeAmount2 = val; } public int getChargeAmount2 () { return chargeAmount2; } public int getTotalAmount () { return cashAmount + checkAmount + chargeAmount + chargeAmount2; } public void setCode (int val) { code = val; } public int getCode () { return code; } public void setCashier (int val) { cashierNum = val; } public int getCashier () { return cashierNum; } 22

public void inFromCVS ( String arg) { String[] results = getFromCVSForm (arg); try{ bidNumber = Integer.parseInt (results[0]); } catch (NumberFormatException e) { bidNumber = -1; } results = getFromCVSForm (results[1]); lname = results[0]; results = getFromCVSForm (results[1]); fname = results[0]; results = getFromCVSForm (results[1]); phone = results[0]; results = getFromCVSForm (results[1]); try{ cashAmount = Integer.parseInt (results[0]); } catch (NumberFormatException e) { cashAmount = 0; } results = getFromCVSForm (results[1]); try{ checkAmount = Integer.parseInt (results[0]); } catch (NumberFormatException e) { checkAmount = 0; } results = getFromCVSForm (results[1]); try{ checkNumber = Integer.parseInt (results[0]); } catch (NumberFormatException e) { checkNumber = -1; } results = getFromCVSForm (results[1]); try{ chargeAmount = Integer.parseInt (results[0]); } catch (NumberFormatException e) { chargeAmount = 0; } results = getFromCVSForm (results[1]); try{ chargeAmount2 = Integer.parseInt (results[0]); } catch (NumberFormatException e) { hargeAmount2 = 0; } results = getFromCVSForm (results[1]); try{ cashierNum = Integer.parseInt (results[0]); } catch (NumberFormatException e) { cashierNum = 0; } } 23

static public String [] getFromCVSForm (String arg) { String[] results = new String[2]; int endPos; boolean goOn; if (arg.length() == 0) {results[0] = "";results[1] = "";} else if (arg.charAt(0) == '\"') { endPos = 1; goOn = true; while (goOn) { if (arg.charAt(endPos) != '\"') endPos++; else if (endPos+1 >= arg.length()) goOn = false; else if (arg.charAt(endPos+1) == '\"') endPos = endPos + 2; else goOn = false; } String temp = arg.substring (1,endPos); results[0] = temp.replaceAll("\"\"", "\""); results[1] = arg.substring (endPos+2); } else { results = arg.split (",", 2); } return results; } 24

public String outAsCVS () { return "" + bidNumber + "," + putInCVSForm (lname) + "," + putInCVSForm (fname) + "," + putInCVSForm (phone) + "," + cashAmount + "," + checkAmount + "," + checkNumber + "," + chargeAmount + "," + chargeAmount2 + "," + cashierNum; } static public String putInCVSForm (String arg) { String retString = ""; boolean putInQuotes = false; if (arg.contains(",") || arg.contains("\"")) { putInQuotes = true; retString = retString + "\""; } String[] result = arg.split ("\"", -1); retString = retString + result[0]; for (int i = 1; i < result.length; i++) retString = retString + "\"\"" + result[i]; if (putInQuotes) retString = retString + "\""; return (retString); } 25

public static void main (String[] args) { Bidder i1 = new Bidder(1, "Hello There"); System.out.println (i1.outAsCVS()); i1 = new Bidder(1, "Hello, There"); System.out.println (i1.outAsCVS()); i1 = new Bidder(1, "Hello \" There"); System.out.println (i1.outAsCVS()); i1.inFromCVS ("1,\"Hello, \"\"The\"\"re\",50,,,"); i1.inFromCVS ("1,Troy,Pat, ,1,2,3,4,5,6"); System.out.println (i1.getBidNumber()); System.out.println (i1.getName()); System.out.println (i1.getLName()); System.out.println (i1.getFName()); System.out.println (i1.getPhone()); System.out.println (i1.getCashAmount()); System.out.println (i1.getCheckAmount()); System.out.println (i1.getCheckNumber()); System.out.println (i1.getChargeAmount()); System.out.println (i1.getChargeAmount2()); System.out.println (i1.getCashier()); System.out.println (i1.outAsCVS()); } } 26

import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.Registry; import java.rmi.registry.LocateRegistry; import java.net.*; import java.io.*; // imports for GUI import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*; public class AuctionServer extends JFrame implements ActionListener { private DataControlImpl dc; private JButton saveButton; private JButton exitButton; public AuctionServer (DataControlImpl dcParm) { super ("Auction Server Interface"); dc = dcParm; FlowLayout layout = new FlowLayout(); // get content pane and set its layout Container container = getContentPane(); container.setLayout( layout ); // set up the save button saveButton = new JButton ("Save Data to File"); saveButton.addActionListener (this); container.add (saveButton); // set up the exit button exitButton = new JButton ("Shut Down Server"); exitButton.addActionListener (this); container.add (exitButton); setSize( 700, 500 ); setVisible( true ); } 27

// handle button events public void actionPerformed( ActionEvent event ) { if (event.getSource() == saveButton) doSaveData (); else if (event.getSource() == exitButton) doShutDownServer(); } public void doSaveData() { try { String s = (String)JOptionPane.showInputDialog(this,"Enter Filename to Save Bidder Data:\n", "Save Bidder Data",JOptionPane.PLAIN_MESSAGE, null,null, "bidder.csv«); if (s != null) dc.writeBidders(s); s = (String)JOptionPane.showInputDialog( this,"Enter Filename to Save Item Data:\n", "Save Item Data", JOptionPane.PLAIN_MESSAGE, null, null, "item.csv"); if (s != null) dc.writeItems(s); } catch (Exception e) { e.printStackTrace(); } } 28

public void doShutDownServer() { int n = JOptionPane.showConfirmDialog(this, "Would you like to save the data before shutting down the server?", "Shut Down Server", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) doSaveData(); n = JOptionPane.showConfirmDialog(this, "Would you really wish to shut down the server?", "Shut Down Server", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) System.exit( 0 ); } 29

//This method starts a RMI registry on the local host, if //it does not already exists at the specified port number. private static void startRegistry(int RMIPortNum) throws RemoteException{ try { Registry registry = LocateRegistry.getRegistry(RMIPortNum); registry.list( ); // This call will throw an exception // if the registry does not already exist } catch (RemoteException e) { // No valid registry at that port. Registry registry = LocateRegistry.createRegistry(RMIPortNum); } } // end startRegistry } // end class 30

public static void main(String args[]) { InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); String portNum, registryURL; try{ int RMIPortNum = 1099; startRegistry(RMIPortNum); // set up the database DataControlImpl dc = new DataControlImpl(); dc.readBidders ("Bidders.csv"); dc.readItems ("Items.csv"); registryURL = "rmi://localhost:" + RMIPortNum + "/AuctionServer"; Naming.rebind(registryURL, dc); System.out.println("Auction Server ready."); AuctionServer application = new AuctionServer(dc); application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } catch (Exception re) {System.out.println("Exception in AuctionServer.main: " + re);} } // end main 31

Client In Eclipse