dreedyman / Rio

Rio is an open source technology that provides a dynamic architecture for developing, deploying and managing distributed systems composed of services.
Apache License 2.0
21 stars 17 forks source link

@PreAdvertise called on service bean before @Started completes #29

Closed DawidLoubser closed 11 years ago

DawidLoubser commented 11 years ago

A @Started-annotated callback method is often used to perform some sort of inital setup (such as read information from an external source). It's reasonable to expect that the bean should only be @Advertised once it has completely started up, but the bean's @Advertised callback is called before @Started completes, forcing the bean implementor to use Locks + Conditions to wait for startup work to have completed before processing incoming requests (which are already received, because the bean has been advertised).

Exhaustive testing has not been performed, but this happens with beans with "required", eagerly-injected associations. Affects Rio-5.0-M1.

dreedyman commented 11 years ago

This issue has been fixed as part of M2. Its is somewhat odd to have a requires association that is eagerly injected. Since it is eagerly injected using "uses" would suffice, since association management will always inject the generated proxy.

DawidLoubser commented 11 years ago

Fair enough - but there is a reason for my madness - only if the association type is "require" will Rio first inject the associations before calling @PreAdvertise. I wanted to implement minimal "wait for space" type of behaviour in my JavaSpaces-based workers, and only the combination of "requires" plus eager injection has historically satisfied that need (i.e. first injected associations to space, transaction manager, and only called @PreAdvertise once the two associations are actually satisfied. If this is no longer the case, I am happy to simply switch to "requires" without eager injection.

Either way, thank you for fixing the issue Dennis!