Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking impl using AtomicLong

 
steve mcdonald
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I have an idea and wanted to run it by the folks here.

What if we could use AtomicLong as a static variable that produces unique identifiers for the client.

Scenario:
When running in the server mode, once the UI establishes a connection to the Server, the server acquires an id long from the AtomicLong static object and returns, Client caches this one and uses for further requests to the server.

This id could be used all through out as long as the client is life.

personally i like this idea more than passing connection object's or of some sort for client identification.

Any thoughts ? problems ? before i go pursuint this route.

Regards,

[ December 02, 2005: Message edited by: steve mcdonald ]
[ December 02, 2005: Message edited by: steve mcdonald ]
 
Lara McCarver
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like the idea. 1 vote = yea. I think it fits naturally into the id of eventually having the user enter a userid/password. Though you can't change your DBMain interface, which may or may not want an id. Also, I am wondering how, in your implementation, the server knows that it is a new client that it needs to create a new ID for.

Lara
 
steve mcdonald
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although my code is not complete yet, here's the idea

There will be a facade businessServices in front of the DBMain implementation and implementing the remote interface as well.

When the GUI makes makes an initial connection with the server, the constructor with one of the parameter clientID passes 0, which means initial connection and server generates a client id and returns.
After receiving server generated clientID, UI caches this id until client is closed/stopped and passes this clientID on ever subsequent business services call, that way the clientID goes back and forth UI to Server.

[ December 02, 2005: Message edited by: steve mcdonald ]
[ December 02, 2005: Message edited by: steve mcdonald ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic