> Requires - but I am thinking now of switching to uses (because the
> only sense that "requires" would really make in Jini is if Rio also
> actually stopped your component when all required associations are not
> available, and restarted it later).
It will not stop your service, but if you use requires it will unadvertise it.
> Otherwise, one has to in anyway
> cater for the fact that they could come and go.
Such is the nature of distributed systems.
> So I am seeing the
> value in "requires" only in terms of startup (i.e. the waiting to call
> @PreAdvertise) - but there is definitely a bug in StaticCybernode in
> this regard, I can only run one test (ever) per VM invocation.
StaticCybernode is not meant to be used in a dynamic setting (hence it's static nature). I even state the following in StaticCybernode's doc:
If associations have been declared (with setter properties) the injection of associated services is undefined at this time.
So I'm not sure what you're getting at here.
>
> I am about to proof this, but will "uses" cause Associations them to
> be injected earlier (before @Started) ?
>
> I have also made the decision to switch from injecting the bare
> services (public void setFoo( Foo foo)) to using your
> AssociationProxy<Foo> -
You should rather use Association<Foo> instead
> one can then write nice code to, for example,
> halt a loop processing items off the space based on the state of the
> proxy (pending/discovered/changed/broken).
It seems you want specific handling for associations. What I have done in cases like this is to write a custom association management proxy. The AMP can be used to manage the discovered services, as needed iterating over a collection of services. Rio comes with a couple of these (called service selection strategies): FailOver (default), RoundRobin and Utilization. With this approach you could make a set of services appear as one (although thats what the association proxies try to do for you by default), and even eagerly inject it so you dont have to wait for the 'real' services to appear [1]. If you haven't already, take a look at the writeup here http://www.rio-project.org/associations.html#Service_Selection_Strategies
> if I do this, I am hoping
> that those proxies (in a state of, say, PENDING) will be injected by
> the time @Started is called?
Nope, they are still associations, and still are waiting to be discovered. Rio will only inject them early if you tell it to.
Dennis
1. You can declare any association to be injected eagerly by using the inject property of the association management:
association(name: 'Foo', type: 'requires', property: 'foo') {
management inject: 'eager'
}