Tobias Ivarsson wrote:
> Hi all,
> 
> Is there a way for an EntityStore to get access to the UoW for which
> it is being queried for an EntityState?

Inject it:
@Structure UnitOfWorkFactory uowf;

uowf.currentUnitOfWork();

> If we are going to have resources (such as transactions in this case)
> associated with the UoW in the EntityStore it might make sense to add
> support for notifying the EntityStore when a UoW transfers from one
> thread to another, so that it may move the resources in the same way.

Ok, that would require some kind of listener thingy I guess. Doable.

> On the top of my head, I would propose a change something like this:
>  * Move the current EntityStore methods to a new Interface called
> EntitySession (or something like that).
>  * The new EntityStore interface should contain one method:
>   EntitySession getSession();
>   which gets invoked once for an UoW, the returned session object is
> then associated with that UoW.
>  * EntitySession should, in addition to the methods from the old
> EntityStore interface have methods for transfering resources to
> annother thread:
>    void suspend();
>    void resume();
>    or something else which might make more sense to Qi4j, as log as it
> supports as least as much as suspending and resuming does.
>    These methods will be called for each EntitySession associated with
> an UoW when pause()/resume() is called on the UoW, perhaps in other
> cases where/if automatic thread transfer occurs.
> 
> What do you think?
> My proposed API changes is of course only my take on it, someone else
> might be able to come up with a better way of enabling associating
> resources with UoWs, for example simplified by prohibiting
> transferring a UoW from one thread to another.

Hm... this needs thinking. Hard to see what the consequences will be, 
but I think I understand the problem anyway. Anyone else with comments 
on this one?

/Rickard

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

Reply via email to