Passing an object remotely

D

Daniel

Hello all,

I have this object

private Patient maakDezePatient() throws java.rmi.RemoteException
{
return new Patient(Integer.parseInt(sleutelVeld.getText()),
Integer.parseInt(sofiNummerVeld.getText()),
verzekeringsMaVeld.getText(),
Integer.parseInt(polisNummerVeld.getText()),
naamVeld.getText(),
adresVeld.getText(),
postcodeVeld.getText(), woonplaatsVeld.getText(),
gebDatumVeld.getText());
}

Im still a beginner, This object is on the client pc, The Patient Class is
on the server. I have a PatientInterface. I know my classes are
serializable. It it have to be when i want to pass whole object through the
line. I cannot find any examples on how to define this in my Interface.

And can someone please tell me what does this object actually? Is it that
the first line starting with private calls a reference to the Patient class?
and then returns the constands given by the Patient class? Im really lost,
becouse i understand how to use the Interface to define methods, where the
server class implents the Interface. But in this case i dont know how to
change this merhod to do so becouse it always gives me an error that the
Class isnt available on the client, its true, so thats why i think i the
best way is to call a remote object with serializability.

Thanks a lot for all the help.

Danny
 
S

Steve Horsley

Daniel said:
Hello all,

I have this object

private Patient maakDezePatient() throws java.rmi.RemoteException
{
return new Patient(Integer.parseInt(sleutelVeld.getText()),
Integer.parseInt(sofiNummerVeld.getText()),
verzekeringsMaVeld.getText(),
Integer.parseInt(polisNummerVeld.getText()),
naamVeld.getText(),
adresVeld.getText(),
postcodeVeld.getText(), woonplaatsVeld.getText(),
gebDatumVeld.getText());
}

Im still a beginner, This object is on the client pc, The Patient Class is
on the server. I have a PatientInterface. I know my classes are
serializable. It it have to be when i want to pass whole object through the
line. I cannot find any examples on how to define this in my Interface.

And can someone please tell me what does this object actually? Is it that
the first line starting with private calls a reference to the Patient class?
and then returns the constands given by the Patient class? Im really lost,
becouse i understand how to use the Interface to define methods, where the
server class implents the Interface. But in this case i dont know how to
change this merhod to do so becouse it always gives me an error that the
Class isnt available on the client, its true, so thats why i think i the
best way is to call a remote object with serializability.

Thanks a lot for all the help.

Danny

Serialization can transfer an object betwnn VMs (using
ObjectInputStream and ObjectOutputStream) but the class of this
object MUST be known at both ends. This means that the file
Patient.class must be readable by both the sender and recipient.

This is because serialization basically sends "Here is an object
of type Patient, and these are all the field values...". Unless
the recipient can then load the Patient class with its
classloader, it cannot reconstitute a Patient object. This is
very similar to a VM executing code "p = new Patient" when it
cannot find a Patient class file.

HTH
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top