This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

NX: Urlybird (Data and Locking)

 
Phil Harron
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I've recently joined up for my SCJD exam and have been reading the many various interesting posts.

I have a couple of questions - sorry if they have been answered before.

I've decided to use the many instances of the Data class, and hold a static list of recIds that are currently locked. (as in M Habbibi's book). In my exam i'm told that Data must implement DBMain

1) Does this mean that I can't create an adapter class, which implements DBmain, and then have a reference to Data from the Adapter? How else could I get round this? I suppose I could have a DataManager which deals with locking etc.. with a reference to Data and note in the documentation that any new developments should use the DataManager class.

2) If I synchronize the list of RecIds, in the lock and unlock methods why would I need the isLocked method ?

Thanks v much
Phil
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Phil,

Does this mean that I can't create an adapter class, which implements DBmain, and then have a reference to Data from the Adapter? How else could I get round this?


Your adapter could not implement DBmain and own a reference to Data which implements it. Where is the issue?

If I synchronize the list of RecIds, in the lock and unlock methods why would I need the isLocked method ?


Do you have an isLocked() method in your interface? (in my version there is no isLocked()).

Regards,

Phil.
 
Phil Harron
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Phil

Do you have an isLocked() method in your interface? (in my version there is no isLocked()).

Yes I have an isLocked() method in my interface. If I synchronize my static list in the lock() and unLock() methods then the JVM will know if its locked or not? I know I must implement the isLocked() method, but I dont want to do it for no good reason.

Your adapter could not implement DBmain and own a reference to Data which implements it. Where is the issue?


So, do you mean that Data could implement DBMain and my Adapter could implement DBMain as well?

Thanks again for your help

[ May 14, 2004: Message edited by: Phil Harron ]
[ May 14, 2004: Message edited by: Phil Harron ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic