I'm building a "backend" or administration site for a website which allows
the user to add/modify/delete various Middle Objects. It has two frames -
a narraw one down the left side (a menu) and a main "content" frame. I'm
using Servlets (subclassed from Page) to serve all of the pages, and I've
taken the idea suggested by the MKBrowser implementation to create an
instance of "store" in each servlet which needs access to the store.
I modify an object in the main "content" frame, and click "Save" (which
modifies the object's attributes and then causes store.saveChanges()
to be called). However, even though these changes are visible in the
subsequent page in the main frame, I can reload the menu frame all I like
and the changes do not appear there at all.
I suspect this is because the "ObjectStore" caches the objects to avoid
unnecessary DB queries, and is not actually checking the database
for modified objects. So my solutions, as I see them, are:
1. Have a global instance of "ObjectStore". I'm not sure how to rig
this up, but I'm sure it's possible.
Advantage: one store and one cache, so there wouldn't be problems with
Disadvantage: Changes to objects would be visible to other servlets,
even before "saveChanges" is called to persist them to the DB. So
there's not really any isolation between servlets/users.
2. Create a new instance of the store for every request.
Advantage: No stale data. There would be isolation between servlets.
Disadvantage: Poor performance (haven't tested yet, though; it might not be all that
3. Disable the caching in the Store, but keep one instance of the store for every
Advantage: No stale data. Have isolation between servlets.
Disadvantage: Poorer performance than with the cache, but not as bad as creating a new
instance with every request.
4. Extend the MiddleKit caching mechanism to store a timestamp field in each object,
so that it's possible to query the DB for just the objects which have been updated
since the last query. Submit the patch to webware so that all can benefit.
Advantage: a Good Solution (IMO)
Disadvantage: I'm not so familiar with the internals of the MiddleKit that I
could implement this very quickly.
I'd really appreciate it if someone who's dealt with this before could offer
some comments about their experiences.
Jason D. Hildebrand