Likely my last question before I wrap up the assignment.
The instructions state that in the non-networked mode, the network code shouldn't be accessed at all. What I really don't like is having my interface extend remote and having all the methods throw the base IOException. If one abstracts away whether or not they are using sockets or RMI, then having the interface extend an RMI interface kind of defeats the purpose right?
So what I have done is made an interface for a "Server" class which the following methods
Underneath the implementation, hidden to the caller, is the RMI interface. There are three main classes.
1.) A dedicated RMI interface, call it RMIExecutor
2.) A dedicated Client Endpoint
3.) A dedicated Server Endpoint
Each time a caller wishes to make an object "remote" the underlying server implementation wraps that implementation in a Server Endpoint, which is a UnicastRemoteObject and implements the RMI interface (all standard RMI stuff...). It binds it to the name of the interface class type provided for later retrieval.
When a caller wishes to retrieve a particular object from the server, they do so by class type, and since it's an interface. I find the Server Endpoint under the class name. Here's the tricky part - since the retreival is based on a class type, which will be an interface, I create a java.lang.reflect.Proxy class for the interface, and use the client endpoint as the invocation handler. Then any invocation to the remote object goes to the invocation handler, which contacts the server endpoint through the RMI interface.
Theres definitely some benefits to doing it this way
1.) One central location for all remote interaction (through dedicated RMI interface)
2.) No need for an interface to extend or a class to implement any RMI interfaces.
1.) Its not exactly straight forward.
2.) Exceptions can still be lost so my interface still has to through the an IOException otherwise the Remote exceptions will fall back to my fault barrier (an uncaught exception handler for all Threads).
So Im wondering trade offs. Have my interface extend Remote and then have a dependency which would kind of make my Server interface a moot point, or have something thats somewhat complicated and explain it in my choices. I guess I just liked having the actual server implementation under the hood but it looks like most people don't care about that in terms of their projects.
Thanks again for the support!