polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kent SĂžlvsten <kent.soelvs...@gmail.com>
Subject Re: Common accessor for private State
Date Sun, 08 Nov 2015 18:06:03 GMT
Den 08-11-2015 kl. 15:18 skrev Niclas Hedhman:
> An interesting thought: Could it be possible to create a
> JpaEntityAssociationStateDecorator? (not sure it is really a good idea,
> might be too complicated
> and integration might be better done by integrating the UOW with the
> global transaction management).
> A little bit hard to see the complications. Are you talking about a Zest
> entity composites behaving like JPA persistence capable beans?? Or the
> other way around?
I was thinking along the lines of using  a Zest-unaware JPA Entity as
underlying state of en EntityComposite - but i suspect that we would be
up for some unpleasant surprises.
Especially since JPA sometimes wish to autoflush stuff.
>> Not quite convinced that core is the right place though - it probably
>> depends on how certain we are to get the API right the first time. So a
>> library *might* be better.
> Yeah perhaps that is a good reason.
>
>> Can You explain why *constuctor* injection is necessary in this case?
> Two things are required. Something needs to have a @This declaration,
> otherwise the state isn't brought into the composite.
> Secondly, whatever does the mapping needs a reference to that private
> mixin, primarily for performance reasons. Well, I guess an abstract method
> would also work...
>
> class PersonMixin extends DefaultAssociationStateDecorator
> {
>      @This
>      private State state;
>
>      protected Object state()
>      {
>          return state;
>      }
> }
You should be able to do it without the method (iterate all fields of
"this" class and check for annotations, but not very nice - the getter
is better) - but i agree it would be nice to have constructor injections
work.
Both for your case and generally.
I am unfamiliar with this stuff .... what exactly is not working? Is it
all constructor injections on private mixins, or just @This injections?
(could give a hint where to look for a solution)



>> You could be running into some chicken-and-egg-problem. Could making the
>> State interface static help?
> Doh... interfaces are always static. As mentioned earlier, there is no
> "bond" between the "interface State" and its containing class. The link
> happens with the @This annotation on either a field or
> parameter/constructor injection.
I actually didn't know that - soooo obvious in hindsight! I was just
thinking if there could be some type matching not taking place.

/Kent

Mime
View raw message