Not sure to understand your design 100 % too
Was I right regarding your DatabaseAdapter and RemoteDatabaseAdapter classes ?
I can't use the DBMain interface for both cause in the networked case it won't work cause it doesn't allow for the throwing of a RemoteException.
I think it doesn't solve your problem : Do you think that in alone mode, client has to deal with RemoteException ?
And in networked mode, what differences for the client between receiving a RemoteException or a DataException from the database ? (If I remember, DataException is your RuntimeException throwed in case of IOException).
I had in mind discussed here many times (see below), and which is, IMO, a good way do deal with your problem.
(Is there a problem with <code> tags ? Looks good when I type my message...)
Where :
# Service interface defines some methods.
# ServiceImpl is the major implementation (deals with database)
# RemoteService extends Remote, redefine Service methods with throws RemoteException clauses
# RemoteServiceImpl is the object bounded in RMIRegistry, and delegates calls to a Service instance
# RemoteServiceWrapper delegates calls to a RemoteService instance.
And client will only see a "Service" reference, which can be :
- a ServiceImpl (alone mode)
- a RemoteServiceWrapper (networked mode). In this case, RemoteException thrown by the RemoteService are re-thrown as "ServiceException" (RuntimeException)