P
Pete
HI
I am currently working on my SCJD assignment and if you are aware of
this, it is really composed of 3 parts - client side, network layer &
server side.
I am at the stage of implememting the network layer and need some
advice of what I have done is reasonable or are there some issues that
I have overlooked.
I appreciate presenting snippets of code is not the best .. I am
sorry.
Below is my remote interface definition.
public interface DatabaseRemote extends Remote {
public String[] readRecord(long recNo) throws
RecordNotFoundException, RemoteException;
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public long[] findByCriteria(String[] criteria)throws
InvalidArgumentException, RemoteException;
public long createRecord(String[] data) throws
InvalidArgumentException, DuplicateKeyException, RemoteException;
public long lockRecord(long recNo) throws RecordNotFoundException,
RemoteException;
public void unlock(long recNo, long cookie) throws SecurityException,
RemoteException;
}
The remote interface provides all the methods that need to supported
on the server side. Is this approach good or should I consider an
alternative approach where by a remote object is returned to the
client which provides all the methods that need to supported ie as per
DatabaseRemote above. With the alternative approach, the remote
interface to the client would a single method which would return a
remote object
public interface DatabaseRemote extends Remote {
public RemoteClient getClient( ) throws RemoteException;
}
public interface RemoteClient extends Remote {
public String[] readRecord(long recNo) throws
RecordNotFoundException, RemoteException;
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public long[] findByCriteria(String[] criteria)throws
InvalidArgumentException, RemoteException;
public long createRecord(String[] data) throws
InvalidArgumentException, DuplicateKeyException, RemoteException;
public long lockRecord(long recNo) throws RecordNotFoundException,
RemoteException;
public void unlock(long recNo, long cookie) throws SecurityException,
RemoteException;
}
1) What are pros and cons of the two approachs.?
2) When I throw any of the above exceptions ( RecordNotFoundException,
SecurityException, InvalidArgumentException ) from my data layer, I
presume they will be propagated back to the client, or do I have to do
something extra ?
3) There no objects exchanged between the client and server so I don't
think I need to implement serializble maybe for new excpetions that I
have declared ie RecordNotFoundException, DuplicateKeyException &
InvalidArgumentException. Is this correct.
Any feedback would be very much appreciated. Thank you.
Pete
I am currently working on my SCJD assignment and if you are aware of
this, it is really composed of 3 parts - client side, network layer &
server side.
I am at the stage of implememting the network layer and need some
advice of what I have done is reasonable or are there some issues that
I have overlooked.
I appreciate presenting snippets of code is not the best .. I am
sorry.
Below is my remote interface definition.
public interface DatabaseRemote extends Remote {
public String[] readRecord(long recNo) throws
RecordNotFoundException, RemoteException;
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public long[] findByCriteria(String[] criteria)throws
InvalidArgumentException, RemoteException;
public long createRecord(String[] data) throws
InvalidArgumentException, DuplicateKeyException, RemoteException;
public long lockRecord(long recNo) throws RecordNotFoundException,
RemoteException;
public void unlock(long recNo, long cookie) throws SecurityException,
RemoteException;
}
The remote interface provides all the methods that need to supported
on the server side. Is this approach good or should I consider an
alternative approach where by a remote object is returned to the
client which provides all the methods that need to supported ie as per
DatabaseRemote above. With the alternative approach, the remote
interface to the client would a single method which would return a
remote object
public interface DatabaseRemote extends Remote {
public RemoteClient getClient( ) throws RemoteException;
}
public interface RemoteClient extends Remote {
public String[] readRecord(long recNo) throws
RecordNotFoundException, RemoteException;
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public void deleteRecord(long recNo, long lockCookie)
throws RecordNotFoundException, SecurityException, RemoteException;
public long[] findByCriteria(String[] criteria)throws
InvalidArgumentException, RemoteException;
public long createRecord(String[] data) throws
InvalidArgumentException, DuplicateKeyException, RemoteException;
public long lockRecord(long recNo) throws RecordNotFoundException,
RemoteException;
public void unlock(long recNo, long cookie) throws SecurityException,
RemoteException;
}
1) What are pros and cons of the two approachs.?
2) When I throw any of the above exceptions ( RecordNotFoundException,
SecurityException, InvalidArgumentException ) from my data layer, I
presume they will be propagated back to the client, or do I have to do
something extra ?
3) There no objects exchanged between the client and server so I don't
think I need to implement serializble maybe for new excpetions that I
have declared ie RecordNotFoundException, DuplicateKeyException &
InvalidArgumentException. Is this correct.
Any feedback would be very much appreciated. Thank you.
Pete