Hello everyone,
I have made great progress so far, but I still fail to understand how to implement the Factory
pattern in RMI. I have read many posts on this wonderful site (without which I would not even stand a chance of passing the assignment), but I do not understand how to implement the above.
I have a ContractorServices interface, which is the main interface which acts a the connection interface. As a result, I have an implementation with the LocalContractorServicesImpl class for the "alone" mode and this works fine. On the server side, I have created a new interface, RemoteContractorServices, which implements both ContractorServices and Remote. My implementation of this interface, RemoteContractorServicesImpl implements the RemoteContractorServices interface and extends UnicastRemoteObject. It also contains an instance variable of the Data class which provides access to the database (read, update, find, etc.).
Now, my understanding of the RMI Factory is that it would contain a createRemoteImpl method (or whatever one might want to call it) that would return a new instance of RemoteContractorServicesImpl every time it is invoked by a different client. However, from the RMI Factory examples that I have seen, the objects returned by the factory implement the Serializable interface, which would imply that the RemoteContractorServicesImpl would implement the Serializable interface and that Data would have to implement the Serializable interface as well and so on. However, this just does not seem right and given that other people have managed to use an RMI Factory, I am asking all talented people for their help in understanding this issue. I am probably completely misunderstanding this RMI Factory concept, but I would be very grateful if someone could help me understand it.
Thank you very much indeed.
Oli