Hi,

1) I agree with Simon that the SCA spec is not clear whether a method with 
@Init can call other services. IMO, it's probably not safe to do so no matter 
how the SCA runtime controls the ordering of "start". For example, we could 
have two composite-scoped components, the 1st one tries to invoke the 2nd one 
within the init method. Then we need to make sure 2nd component is started 
before the 1st one. We should raise this issue to the spec group.

2) For each component, the following order probably makes more sense:

a) reference (Get external dependencies ready ...)
b) implementation provider (Get the implementation ready ...)
c) scoped implementation (Init the instance within the scope ...)
d) service (Start to provide services to other components ...)

Thanks,
Raymond

 
From: Simon Laws 
Sent: Monday, February 02, 2009 9:04 AM
To: tuscany-dev 
Subject: [2.x] [DISCUSS] calling references from withing @Init methods


Raymond had to adjust the binding-ws-calculator test case where we are calling 
references from within an @Init method which was deadlocking. In this case the 
reference/service interface is over web services. The problem is that the 
CompositeActivator is written so that each component is started completely and 
one after another and hence target service bindings are not necessarily active 
when the first @Init is run, e.g. in CompositeActivator.start(Component 
component)...

For each component
  start reference provider
  start service provider
  start implementation provider
  start scoped component - Whic in turn calls @Init method

Which I think should be 

For each component
  start reference provider
  start service provider
  start implementation provider

For each component
  start scoped component

In order that all the implementations and reference/service bindings are 
started before any @Init methods run. 

I'm saying this based on the assumption that it's valid to call injected 
references from within methods marked as @Init. The Java common annotations and 
APIs say's that @Init must be called after injection is complete. It doesn't 
explcitly say that you can use the injected references but I don't see how you 
can stop developers doing this if injection is complete. 

Simon

Reply via email to