love your job and not your company;
...because you never know when your company will stop loving you!
I set certain variable into the servlet context. If i change them the context need to be reloaded for them to take effect.
John Schretz wrote:ok so i can do something like
in my jsp i can have:
${factory.getVendors}
Im just not sure on how to tell what is cached or not.
Bear Bibeault wrote:Is this from within the same application? If so, this is easy.
What I would do is to create a factory class who's job it is to supply the information rather than storing the info in servlet context. All parts of the application obtain the info from this class (which itself can live in servlet context) rather than directly.
With this abstraction in place, how the data is actually handled is moot as far as the rest of the app is concerned. Abstraction is our friend!
When someone asks for the data, this factory is smart enough to go fetch the data if it doesn't already have it cached internally. Once fetched, subsequent requests for the data simply return the cached data.
When an operation that invalidates the data is executed, it can tell the factory to dump the cache. That way, the next time that the data is asked for, the factory will know to go and reload it from the DB.
Steve Dyke wrote:However, I cannot understand how to do the refresh when the remote data changes.
Bear Bibeault wrote:
You do know when your application takes an action that changes the data.
Bear Bibeault wrote:Answer your own question: which line sets the data into a context? Is that context the session?
Bear Bibeault wrote:Correct. Setting a value into the application context will not affect any session.
Often the most important part of the news is what they didn't tell.
Tim Holloway wrote:I don't like the idea of using a constructor to get a database connection. It makes it appear as though you're not using connection pooling.
Bear Bibeault wrote:
Tim Holloway wrote:I don't like the idea of using a constructor to get a database connection. It makes it appear as though you're not using connection pooling.
Ding! Ding! Ding! Ding! Ding!
Often the most important part of the news is what they didn't tell.
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|