Hey,

The more I look at the UoW event system the more bizarre it seems, and 
"old fashioned" compared to everything else. So here's an idea: what if 
we apply the notion of concerns and sideeffects to UoW as well, i.e. 
another level to declare them. You would then be able to say "for this 
Usecase, apply this Concern", and if that Concern implements "Property" 
then it would be applied to all Properties.

Example:
public abstract class PropertySetterConcern
    extends ConcernOf<Property>
    implements Property
{
     public void set( T newValue )
         throws IllegalArgumentException, IllegalStateException;
     {
         System.out.println("New value:"+newValue);
         next.set(newValue);
     }
}

This would give observers of UoW and state a very fine grained 
granularity and it would be easy to implement reasonably advanced scenarios.

One obvious problem is how to declare these concerns though. If they are 
declared on the Usecase of the UoW, then it would have to be as classes, 
i.e.
Usecase uc = UsecaseBuilder.buildUsecase("Some 
usecase").withConcerns(PropertySetterConcern.class).newUsecase();
UnitOfWorkFactory uowf = ...;
UnitOfWork uow = uowf.newUnitOfWork(uc);
---
The catch here is that the dependency resolution of the concern classes 
in the Usecase has to be done *when the UoW is instantiated*, as it 
depends on in which specific module the Usecase is being used in. This 
is highly impractical and will cost a lot of resources (unless it is 
done once and the result is cached!).

There is also the question of granularity. In the above case the concern 
will be applied to pretty much all properties in a UoW, i.e. there's no 
way to say "I want to listen to property Foo in Entity SomeType:123". 
This could, however, be implemented on top of a generic concern that 
only provides the listener functionality in general.

Should I attempt to implement this? Would it be better than the current 
general event listener scheme? I feel that we really do need some kind 
of event system...

/Rickard

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

Reply via email to