|
| Hi,
In my project I'm trying to use the Value Object Patern (aka Bulck Data Object Patern)
Nut, my VOs can refer to other VOs like a tree in witch a node can refer to another node.
Is a structure like this one, is possible that in some point a VO references a VO in its owner upper
structure , like this
A -> B -> C -> A
The problem when loading this VO is that I get a infinite loop.
The client requests a VO from the server. In the server, a facade Stateless Session Bean is in
charge of compiling the request. For this , the bean consults various entity beans constructing the
various VO.
So to parcialy resolve the problem I use a POJO that acts as a memory (a cache). Each time a VO is
loaded is added to the memory. The next time is requested, the cached object is returned.
This works fine, the problem is that by caching the objects I lose control if they are updated or
not since another separated process is in charge of saving the VO send by the client. (this process
is implemented in the stateless bean). So, when saving I remove the object from the loading memory,
and when loading I remove the object from the saving memory. (the same loop occurs when saving, so
use the memory to avoid saving the same object over and over).
For a single client acessing the server this works , but for multiple clientes I have a serious
cuncurrency problem. Because this is becaming very non-standard I ask you if anyone had a similar
problem and how it was workedarround. Or, if there is a special pattern for this kind of VO. Or, if
anyone as any idea , at all, that can help solving the cunccurency problem.
Thanks in advance.
|
|