I have a problem relating data transmission between ipojo components during reconfiguration.
Here's an example:
- A component
Calcul_1provides a calculation service to return a value(a+b)(ex:f(a,b)=> (a+b)) - A component
Calcul_2provides 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
CallCalculthat uses the calculation service ofCalcul_1. The componentCallCalculcallsf(5,6)in the componentCalcul_1. Then, theCallCalcul componentreceives the value of 11.
Problem:
When
Calcul_1receives the value(5,6)(not yet calculate) fromCallCalcul,CallCalculreconfigure by changing connector toCalcul_2, i.e., it binds toCalcul_2. In this case, how can I transmit(5,6)fromCalcul_1toCalcul_2and return(5*6=30)toCallCalcul?When
Calcul_1receives the value(5,6)(and calculate their, i.e. 5+6=11) fromCallCalcul,CallCalculreconfigure. In this case, how can I transmit11toCalcul_2and 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
fis synchronous, so tell me if I am wrong). ACalcul_1component will not be replaced by aCalcul_2in 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
myServiceeven 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 :