This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Architecture proposal

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

this is a description of my architecture. I am doing the
URLyBird.

I defined a class called Record which is a wrapper around the String[] record in the database which defines a room and contains other information (rowNumber, deleted flag)

I have a DBMain interface and a Data class that implements DBMain. The Data class has a reference to two singletons, LockManager and RecordManager.

RecordManager is used to access and persists Records. All his methods are synchronized since I want to make sure access to the file happens sequentially. I do use a cache when reading a record, and when writing a record I update the cache while writing the record back to the file. I have also a list of deleted records to reuse when create[]

LockManager maintains a weakhashmap where a logical lock on a record by
a DBMain instance is stored. Access to this weakhashmap is synchronized.
I assuming every client is using a different DBMain instance (I don't have
cookies)

I have two remote objects, DBMainAdapterPool and DBMainAdapter. The DBMainAdapterPool maintains a pool of DBMainAdapter in a HashMap.
The DBMainAdapter wraps a DBMain instance and exposes two business methods
for searching and booking, which use the methods exposed by the DBMain

To get a reference to a DBMainAdapter the client
has to lookup the DBMainAdapterPool, and call its method lookupAdapter,
which returns the JNDI name for an available DBMainAdapter. The client then
looks up this name for a DBMainAdapter instance. When done with it, the client calls the method releaseAdapter(String adapterName) so that the
adapter can be returned to the pool and another client can use it.
I synchronize calls to lookupAdapter and releaseAdapter, so that two clients
don't get the same DBMainAdapter instance

The gui maintains a reference to a DBMainAdapter during his lifetime and releases it on quitting. The DBMainAdapter asks the pool to release him when
unreferenced().

Do you see any problem with this architecture?

Greetings
Diego Amicabile
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic