Hi folks i would like to discuss the following scenario:
I have got a business object called Chain. That 'business object' consists of a header object with attributes specifying the start and end point of this chain plus additional attributes. A Chain consists also of one or more link object with attributes describing the start and end point of a link plus additional attributes also here. Header and links are stored in two seperate tables.
Depending on what business case at hand Chains are validated differently. Therefore header and link object implement an accept method that takes an abstract visitor as argument. I have got several ruler classes implemented as singleton that extend the visitor that shall validate a given chain.
The header and link objects are validated against a domain that is only accessable via webservices. To avoid that the same webservice with same parameters will be executed within the same session I would like to keep the results returned by the last webservice call.
Because of some cooperate political decision the entity session facade has to be stateless. The problem is by caching the last returned results I'll introduce 'state'.
I would like to hear Your opinion about two possible approaches I can see ( or of course a totally new one).
Because the webservice is invoked via a bridge the bridge methods could be declared 'synchronized' in order to avoid concurent access at the level where the webservice is actually invoked.
Alternatively the facade methods via which Chains are manipulated can be synchronized.
I'd avoid getting into caching as long as possible.
1. Make your application working in a straight way.
2. Run load tests and identify bottlenecks.
3. Fix identified performance problems.
This approach will allow you to get a working application first and than take care about the rest - if you have time and resources.
I agree entirely with avoiding caching. But I am still curious about what a good aproach good be.
To rephrase my problem: I ve got a stateless session bean facade that before it will push data into the database (via dao) invokes several business services in order to validate input data against data fetched via webservices.
The point is how to avoid that the same data is fetched more than one time per session cycle. Anyone faced this problem before