Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Jeff Shen

Ranch Hand
+ Follow
since Sep 04, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeff Shen

Anybody knows? should we send SUN email, in order to upload assignment?

Thanks
Did email SUN? in order to upload assginment. can we directly upload assignment?
I am using response.getOutputStream() to send a file to local machine. It works well, but the problem is the Mouse swich to hour glas and not change back even after the file succesful save on the local machine. I don't know what is the problem.
Jeff
15 years ago
Thanks Peter
That was exactly my problem, Now i feel very comfortable with remote Object.
So far I'm almost done the project and plan to submit at weekend.
Jeff
When I try to call getConnection method after the ConnectionFactory bound on the Clinet, I keep get following error message
java.rmi.UnmarshalException: error unmarshalling return; nested exception is:
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: suncertify.server.RemoteData
I don't know what is wrong, can you help me.
Jeff
Because to lock/unlock record according to the unique clientID is part of assignment requirement and also if you implement Unreferenced interface you can clear up the lock when the object is unreferenced.
hope this explains
Jeff
I think now i got it.
Should i do as following on the server side
Public class ConnectionFactory extends UnicastRemoteObject implements Remote
private DataInterface data;
...
public DataInterface getConnection() throws IOException, RemoteException, DatabaseException{
data = new RemoteData(databaseName); return (DataInterface)data;
}
Now the reference of data is the clientID, which can be used for lock/unlock the record
thanks
Jeff
Thanks Mark
I got the idea, I just don't understand what do you mean by the following.
----------------------------------------
The ConnectionFactory has a reference to the one Data class instance and passes this reference to the new Connection object.
---------------------------------------
Jeff
Thanks Mark
You mention the connection object, is it a instance of Data.
Jeff
Thanks Eugene
What I have done on the server is as following
try {
Naming.rebind("//localhost:" + serverPort + "/FBNSystem", data);
} catch (RemoteException remoteException) {
System.err.println(
"Failure during Name registration: " +
remoteException);
} catch (MalformedURLException malformedException) {
System.err.println(
"Failure during Name registration: " +
malformedException);
}
What I have done on the client is this
try{
data = (DataInterface)Naming.lookup(
"rmi://" + serverName + ":" + serverPort +
"/FBNSystem");
} catch
etc..
It works fine, I just can't get distingush ClinetID
please advivce what should be done.
Jeff
The problem is that even you have the ConnectionFactory which implements UnicastRemoteObject, Remote interface and has a Data Instance, you still don't have unique clientID.
I have tested from two computers to connect the RMI server and do booking flight. It seems only one Remote object created for the two different clients.
I really confused how the RMI manage the threads.
Jeff
One thing I am not sure, if your server side Data class does not implement DataInterface, how do you deal with data on the client side uniquely?
Using the Facade pattern to deal with all data related operations is an excellent idea, however my question is if the LocalData dose not implement DataInterface but the RemoteData implements the Datainterface, how can I use unique data object to represent both the LocalData and RemoteData.
Regards,
Jeff
Thanks so much for the useful help. Only one thing I don't understand is that Michael mentioned even the LockManager should not be singleton, what I'm thinking is the LockManager must be sigleton, would you advice me more regarding this issue.
Regards,
Jeff
I have a question about the RemoteData.
My RemoteData extends the UniqueCastObject and implement the DataInterface. To implement the RemoteData I have used the Data object. The Code is like following
DataInterface data = null;
try {
// Create a RemoteData object
data = new RemoteData(dbName);
//LocateRegistry.createRegistry( Integer.parseInt(port) );
LocateRegistry.createRegistry( port );
} catch (RemoteException remoteException) {
System.err.println(
"Failure during object export to RMI: " +
remoteException);
} catch (IOException ioException){
System.err.println(
"Failure during object export to RMI: " +
ioException);
}
This means that for each client the RMI create a new Object and open the database. My quesion is that should I use singelton pattern on the RMI server so that it only generate one instance of the database for all client?
Regards,
Jeff