I have a problem relating data transmission between ipojo
components during reconfiguration.
Here's an example:
- A component
Calcul_1
provides a calculation service to return a value(a+b)
(ex:f(a,b)=> (a+b)
) - A component
Calcul_2
provides a calculation service to return a value(a*b)
(ex:f(a,b)=> (a*b)
)
These two components implement the same calculation service (ex: f
).
- Now, I have a component
CallCalcul
that uses the calculation service ofCalcul_1
. The componentCallCalcul
callsf(5,6)
in the componentCalcul_1
. Then, theCallCalcul component
receives the value of 11.
Problem:
When
Calcul_1
receives the value(5,6)
(not yet calculate) fromCallCalcul
,CallCalcul
reconfigure by changing connector toCalcul_2
, i.e., it binds toCalcul_2
. In this case, how can I transmit(5,6)
fromCalcul_1
toCalcul_2
and return(5*6=30)
toCallCalcul
?When
Calcul_1
receives the value(5,6)
(and calculate their, i.e. 5+6=11) fromCallCalcul
,CallCalcul
reconfigure. In this case, how can I transmit11
toCalcul_2
and return this value toCallCalcul
?
As far as I know, ipojo handle synchronization so that this behavior does not happen.
From the ipojo documentation :
So as long as you are in the same method (or a nested method), you know that your service has not been modified since the first time you accessed it (I assume that your call to
f
is synchronous, so tell me if I am wrong). ACalcul_1
component will not be replaced by aCalcul_2
in the middle of a method invocation.However, I guess this also means that if you want the reconfiguration to take effect, you have to reach the end of the method using your service. For instance, if your component launch a thread with a function like :
If this function keeps running, ipojo will not bind a new service to
myService
even if your filter is modified. You should put the call to the service in another helper method. It will allow ipojo to lock the access to the service while your component is being reconfigured. for instance :