I'm working on a 3 tier Java application with a GUI front end. The front end is fairly complex so I would like to have my domain objects available on the client as well as the server. So this is what the architecture looks like:
UI -> Presenter -> Commands -> Domain objects -> Data Access Layer
The commands are executed on the server in a command processor (which is implemented as a session bean) and the data access layer uses Hibernate.
So here's the issue. The presenter sends a command to the server and get's back the results. The presenter now has a graph of objects. Later the presenter sends another command that returns a graph of objects, some of which are already in the previous graph of objects. Since they are deserialized, I know have duplicate objects on the client. This is bad.
My bright idea is to create a Registry on the client that keeps track of client side objects. When an object's readResolve method is called, it can look in the registry and if it's already there, return the object from the registry instead.
Are there any (hopefully open source non-GPL) products out there that already do this sort of thing?
Thanks,
John