Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client id for Remote Connection

 
Rachna Chaturvedi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , i am going mad trying to find a way to assign the client id for my remote conenction,
can someone advise
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rachna,
You and every other developer candidate! I remember my fretting over it. Do a search on ConnectionFactory or unique client ID and that should give you plenty of reading.
In a nutshell, if all clients are issued a unique connection, then the client ID is "this".

Hope this helps,
Michael Morris
 
Rachna Chaturvedi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Micheal, Thanks for your repsonse, but in my case i do not use separate connections .

I will try the search and get back ., THanks again
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rachna,
Bummer! Then you're probably stuck with generating some sort of hash code based on remote invocation. Or you could keep a static long, that is initially set to Long.MIN_VALUE that is incremented each time a client calls lock. Of course that value will have to be passed back to the client some way so it can later call unlock with the proper bona-fides.
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
Hi Micheal, Thanks for your repsonse, but in my case i do not use separate connections .

Then start using them
You will find that the changes you need to make to follow this design will be quick and easy.
I also had the same situation, It took me a little while to understand the COnnection and ConnectionManager design, but when I did I immediately went to tchange all my code, and it only ended up taking about 15 minutes to do so, because the design is so elegant.
Mark
 
Rachna Chaturvedi
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Micheal and Mark,
Thanks for your suggestion.
I have realised that i am better of changing the design and code of connection and ConnectionManager. I now have the design clear in my mind
. But it is indeed a tricky one
Thankyou both
 
Mag Hoehme
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mark Spritzler:

I also had the same situation, It took me a little while to understand the COnnection and ConnectionManager design, but when I did I immediately went to tchange all my code, and it only ended up taking about 15 minutes to do so, because the design is so elegant.

Hi Mark!
can you help me to understand Connection and ConnectionManager, too? Maybe some reading suggestions, patterns, etc.
Thank you!
 
Nate Johnson
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mag Hoehme:

can you help me to understand Connection and ConnectionManager, too? Maybe some reading suggestions, patterns, etc.

I used the factory pattern to implement my ConnectionFactory.
In general the factory sat in my client and was passed the command line options that were given when the client was started up. From these options, the factory would decide which kind of DataAccess object to create (either LocalData or RemoteData). Then it would create the connection and hand it off to the client. That way the client was always dealing with the DataAccess interface and did not get cluttered up with a bunch of if-then statements for local/remote modes.
Hopefully that helps a bit...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic