Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion fo local&network

 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I've get the project several days,but I'still cannot kown how to implement the non-network/network.And I want to make the project with rmi.So,should I create LocalDataAcess.class and RemoteDataAcess seperatley to implement the local and remote ,or all use the RemoteDataAcess.class.
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would do two classes... you should be doing different things for the different modes. The requirements say that no sockets should be opened in local mode.
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks,another problem,there are some methods in the Data.class which is sychronized.When I implement those methods in my class RemoteData.class,could I plus 'synchronized'? (I use rmi)
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure that I understand your question
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry,i mean could i write like that:

Could i use synchronized here?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Ray"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well in remote mode your proxy object is just passing alls to the Data class, so therefore you do not need to include the Synchronized keyword. Plus each proxy object is only for one client each, so there is no synchronization issues.
Mark
 
Ray Cheeny
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Data.java ,there are some synchronized methods.Do you mean if I want to use those methods in my class which extends UnicastRemoteObject,I should delete the 'synchronized'.But i wonder that is that threadsafe?
Another question,should I implement the lock/unlock in my local design?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ray,

... But i wonder that is that threadsafe?

Since the Data methods are threadsafe, i.e. synchronized, and you will presumably be calling those method thru your remote implementation then there is no need to synchronize the methods in the remote implementation to maintain thread safety.
Hope this helps,
Michael Morris
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael my translator.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic