patient.setAilmentDescription("Money coming out the wazoo.");
System.out.println("*** Have a new patient that needs a doctor. The patient is:\n" + patient);
// now create remote provide interface to call on
ProviderInterface providerProcessor = (ProviderInterface) TransporterClient.createTransporterClient(locatorURI, ProviderInterface.class);
try
{
// find a doctor that can help our patient. Note, if none found, will throw an exception
System.out.println("*** Looking for doctor that can help our patient...\n");
Doctor doctor = providerProcessor.findDoctor(patient);
// notice that list of patients now includes our patient, Bill Gates
System.out.println("*** Found doctor for our patient. Doctor found is:\n" + doctor);
// assign doctor as patient's doctor
patient.setDoctor(doctor);
System.out.println("*** Set doctor as patient's doctor. Patient info is now:\n" + patient);
// let's say our doctor made enough money to retire after helping out our patient, Bill.
providerProcessor.retireDoctor(doctor);
// let's create a new patient and find a doctor for him
Patient patient2 = new Patient("Larry", "Page");
patient2.setAilmentType("financial");
patient2.setAilmentDescription("Money coming out the wazoo.");
System.out.println("*** Have a new patient that we need to find a doctor for (remember, the previous one retired and there are no others)");
providerProcessor.findDoctor(patient2);
}
catch(NoDoctorAvailableException e)
{
System.out.println("*** Could not find doctor for patient. This is an expected exception when there are not doctors available.");
e.printStackTrace();