Hey, I'm about to start working on the main UI for the StreamFlow workflow application, and have some basic wonderings about how to handle UnitOfWork in Swing.
Basically, the "work" to be done are in a couple of categories. The first is to create the UI layout which will read/view Entity data. Then the user will work with that, and perform usecases that create/update/remove data. The question is how to manage UnitOfWork for that. One possibility is to create a base UnitOfWork for the application, and use this for the "read" view. I could create a custom EventQueue that automatically resume() and pause() the UnitOfWork for the event being processed, so that all that controller code/rendering/model code has to do is uowf.currentUnitOfWork(), and assume that it will be ok, and get Entity data from it and render in the view. This handles all the read-usecases. Then, for each case where dialog or usecase that modifies/creates state I can do a nestedUnitOfWork() for it. When the usecase completes the new state is essentially "pushed" down into the base "read" UoW. Once in a while the user can click "Save" which essentially does "Apply" on the read UoW so that state is persisted either locally or to the server. The main problem I see with this is that the UoW would be longrunning, and since it holds strong references to EntityState/EntityInstances it will cause memory leaks. This *could* be fixed by using WeakReferences in the UoW caches but I'm not entirely sure of the consequences of this. Another way to do it is to have a local EntityStore, and then for each read/render simply create a new UoW and read the entities. The UoW's will then never survive an event processing, i.e. they are always shortlived. This will avoid the (potential) memory leaks, and there is more control over how to do caching of state and refreshing from the underlying store, but it also feels more difficult to work with. We would have to do UoW.dereference()/getReference() all the time as Entity instance become invalid instantly. Any opinions on this? It feels kind of fundamental so I'd like to get it right from the start... /Rickard _______________________________________________ qi4j-dev mailing list [email protected] http://lists.ops4j.org/mailman/listinfo/qi4j-dev

