java - Data transmission during ipojo reconfiguration -
i have problem relating data transmission between ipojo
components during reconfiguration. here's example:
- a component
calcul_1
provides calculation service return value(a+b)
(ex:f(a,b)=> (a+b)
) - a component
calcul_2
provides calculation service return value(a*b)
(ex:f(a,b)=> (a*b)
)
these 2 components implement same calculation service (ex: f
).
- now, have component
callcalcul
uses calculation service ofcalcul_1
. componentcallcalcul
callsf(5,6)
in componentcalcul_1
. then,callcalcul component
receives value of 11.
problem:
when
calcul_1
receives value(5,6)
(not yet calculate)callcalcul
,callcalcul
reconfigure changing connectorcalcul_2
, i.e., bindscalcul_2
. in case, how can transmit(5,6)
calcul_1
calcul_2
, return(5*6=30)
callcalcul
?when
calcul_1
receives value(5,6)
(and calculate their, i.e. 5+6=11)callcalcul
,callcalcul
reconfigure. in case, how can transmit11
calcul_2
, return valuecallcalcul
?
as far know, ipojo handle synchronization behavior not happen.
from ipojo documentation :
the synchronization managed ipojo. 'touching' dependency in method, ipojo ensure keep these objects until end of method. nested methods share same service object set.
so long in same method (or nested method), know service has not been modified since first time accessed (i assume call f
synchronous, tell me if wrong). calcul_1
component not replaced calcul_2
in middle of method invocation.
however, guess means if want reconfiguration take effect, have reach end of method using service. instance, if component launch thread function :
public void run() { while(!end) { //while function running, myservice not change int var = myservice.f(a,b); // ... result thread.sleep(sleep_time); } }
if function keeps running, ipojo not bind new service myservice
if filter modified. should put call service in helper method. allow ipojo lock access service while component being reconfigured. instance :
public void run() { while(!end) { // service may not same each time because function // not directly use service int var = calldynamicservice(a,b); // ... result thread.sleep(sleep_time); } } private int calldynamicservice(int a, int b) { return myservice.f(a,b); }
Comments
Post a Comment