philippe van dyck wrote:
It brings the following question, who is responsible for the content of an uow ?

Currently , I use some kind of "open session in view" solution by creating an uow at the beginning of a request and completing it at the end.

Sounds reasonable.

This is not the same use case, since I don't really know what is happening in between... So should I be responsible of the content of the uow, adding boolean flags or whatever, or should I be able to browse the uow content ?

What do you mean, you don't know? For what purpose do you need to know? If for "complete vs discard", like I said, PUT/POST/DELETE->complete() and GET->discard(). What do you need the flags for?

Previously, I used a specific "layer communication" service in order to call with my backend, and I was planning to use remoting on this service.

But lastly, I wrapped entities in a detachable wicket model, and it is really easy to use and to store in the wicket session (I only store the identity when I detach the model).

It simplifies a lot web coding since I can call business methods on my entities directly, it somehow violates the layering principle but I can live with that now.

My REST resources call method on the domain entities directly. Works just fine.

I really like the idea of my web layer calling business methods recording events (get,delete,put,...) in an uow and then applying those events, so should I update a flag like thisUnitOfWorkContainsUpdatingEvents in a threadLocal variable ?

See above.

Since all the info I need is stored in the uow, would it be possible to specifiy a Usecase like "discard if all uow events are get requests" or "replay this critical uow and ignore concurrency".

This would only be needed if the complete()/discard() code is not next to the code that does newUnitOfWork(). If so, then yes, you can add metainfo to the Usecase which hints to the completion code how to handle it. In your completion code you would do something like this:
UnitOfWork uow = uowf.currentUnitOfWork();
UsecaseType ut = uow.usecase().metaInfo().get(UsecaseType.class);
if (ut.isWriteUsecase()
  uow.complete();
else
  uow.discard();

where you decide what UsecaseType looks like and how to interpret it.

/Rickard


_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to