Hi again!
More comments and a JIRA coming up.
First the JIRA: https://issues.apache.org/jira/browse/TUSCANY-3464
Next, some comments:
Simon Laws wrote:
>> - Two Observer SCA components.
>> Each component has a reference to an Observable component with the
>> wiredByImpl="true".
>>
>
> Why wiredByImpl? Is that important in this scenario?
>
I wanted to write an example with more dynamic relations that are formed
at runtime, not by injecting references in a composite file.
Before adding the wiredByImpl, I had other errors, much earlier, when
the application was launched. I read in the specifications that setting
wiredByImpl to true is supposed to give the responsibility of wiring the
components to the implementation, as opposed to the composite file(s).
>
>> - One Observable SCA component.
>> This component has a callback with the interface of the Observer
>>
>
> Is this what you mean here...
> @Callback(Observer.class)
> public interface Observable{
>
Exactly.
>> component as parameter, but no callback is injected in the component.
>>
> How is the callback in the component implementation defined?
> public class ObservableImpl implements Observable {
> @Callback
> protected Observer callback;
>
No, since I want to be able to register multiple Observers with an
Observable, I use a map:
private Map<String, ServiceReference> mObservers = new HashMap<String,
ServiceReference>();
It is not annotated.
> What's the scope of the component implementation?
>
COMPOSITE
>> To register for notifications, an Observer calls register on an
>> Observable, without any parameters.
>> In the Observable, a callback service reference is retrieved like this:
>> ServiceReference<ObserverService> theObserverRef =
>> mRequestContext.getCallbackReference();
>>
>> This service reference is stored and later,
>>
>
> Are you storing in a member variable? If so you need to be careful of
> implementation scope.
>
Yes, it is stored in an implementation variable - see above.
Perhaps the way that I have done this is not the best way (can't be good
if it does not even succeed :-P ), please let me know if there are any
better alternatives.
If there are any problems with Tuscany, I really don't mind helping out
if I am able. The last issue I had (complex XML injection) was a tad bit
too complicated for me. :-(
Best wishes,
Ivan