That's true. And that you have to catch the RemoteException is quiet normal, because that's a consequence of not knowing which mode you are running your application in.I guess there is no way out of this, if you want to keep your client unaware of what type it is.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
SCJP 6.0(95%), SCWCD 5(94%), SCJD (working on B&S v.2.3.1)
I'm not Roberto, but I also didn't extend from UnicastRemoteObject (I even didn't extend from anything, just an implements) and just used the exportObject-method.Andriy Pererva wrote:If I understand correctly, you are using UnicastRemoteObject.exportObject() method instead of inheritance?
Roel De Nijs wrote:...and just used the exportObject-method.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
SCJA, SCJP, SCJD, SCWCD and SCBCD Certified.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Roberto Perillo wrote:Howdy, Mikael!
I am ultimately wanting to eliminate duplicate code for both the RMI implementation and Local implementation. From my understanding, the DefaultServices IS the local implementation of Services and each method in the DefaultServices class throws the same exceptions as in the Services methods (ServiceException and RemoteException).
However, is it okay that the DefaultServices methods throw RemoteException even though for a Local-connection, the RemoteExceptions will never be used?
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Now, are there any tests that I can use to verify that my RMI connection works? I ran my server on my laptop, and the client on a desktop machine and did a few tests.
Test 1: Connect client to server using valid IP and valid Port number - seems as if it works fine (Client Window appears and JTable is populated).
Test 2: Connect client to server using invalid IP address, but valid Port number - "Failed to connect to the database" appears as expected.
Test 3: Connect client to server using vaild IP but invalid port number. - Client Window does NOT appear and the program is still running. Not what I expected-- I was expecting a "Failed to connect" message as in test case #2.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Roberto Perillo wrote:Howdy, Kenneth!
How did you connect to your server with an invalid IP address?
Roberto Perillo wrote:
Roberto Perillo wrote:
The Services interface offers the methods to be consumed by the presentation layer. These methods are to be used in the TableModel or in ActionListeners
Norbert Lebenthal wrote:Isn't it rather the controller which should use them ?
Norbert Lebenthal wrote:Hum, I've a different implementation of the RMIRemoteServices. Indeed, here you extend DefaultServices, which then requires its content to be serializable. It's quite a pity though because it's not strictly required so: indeed, from what I understood from RMI, the stub will be created through a proxy and only the proxy will be given away. This proxy then delegates, after transport, to the actual instance.
Norbert Lebenthal wrote:Side note: on my side I made this RMIRemoteServices extending UnicastRemoteObject, since one instance can be used through all clients. And on top of that I've no factory or the like: just the instance is put in the RMI registry, the clients directly go at it.
Norbert Lebenthal wrote:Isn't it rather the controller which should use them ?
Norbert Lebenthal wrote:EDIT: side question: what do you do if/when the configuration isn't proper. Error message and then stop or something cleverer with a new edit dialog being displayed as long as config wasn't good?
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
Well, today I'd say that a more appropriate approach would be to provide to the TableModel only the data that is displayed on the JTable, and not provide the Services object to it, just like I've shown in this other thread (which was started by you). Other than that, an ActionListener is a Controller. So, it can have a reference to the Services object. For instance, the listener of the Book Room button can have a reference to the Services object and, after verifying the data provided by the user, invoke the bookRoom method from the Services object.
Consider Paul's rocket mass heater. |