The optional reference from A1 to B1 creates a cycle.  The DS
implementation should be able to handle this since the reference is
optional it should be able to break the cycle and I assume provide a
consistent activation order of A1 and B1.

I recommend opening a bug against Equinox->Bundles to track the issue.  It
would really help if you could provide a testcase to reproduce.

Tom




                                                                                
                                                              
  From:       "Foerster, Stefan" <[EMAIL PROTECTED]>                            
                                                       
                                                                                
                                                              
  To:         equinox-dev@eclipse.org                                           
                                                              
                                                                                
                                                              
  Date:       02/22/2008 10:52 AM                                               
                                                              
                                                                                
                                                              
  Subject:    [equinox-dev] DS invocation order of bind and activate (timing    
issue???)                                                     
                                                                                
                                                              





Hello,

I'm having three bundles providing three services using the declarative
service (version 1.0.0.v20080218):

bundle A:
<component name="A1" immediate="true">
  <implementation class="A1"/>
  <service>
    <provide interface="IA"/>
  </service>
  <property name="service.pid"     value="A1"/>
  <property name="service.ranking" value="1000"/>
  <reference name="b" interface="IB" bind="setB" unbind="unsetB"
cardinality="0..n" policy="dynamic"/>
  <reference name="c" interface="IC" bind="setC" unbind="unsetC"
cardinality="0..1" policy="dynamic"/>
  <reference name="d" interface="ID" bind="setD" unbind="unsetD"
cardinality="1..1"/>
  <reference name="e" interface="IE" bind="setE" unbind="unsetE"
cardinality="0..n" policy="dynamic"/>
</component>

bundle B:
<component name="B1">
  <implementation class="B1"/>
  <service>
    <provide interface="IB"/>
  </service>
  <property name="service.pid"         value="B1"/>
  <property name="service.ranking"     value="1000"/>
  <reference name="a" interface="IA" bind="setA" unbind="unsetA"
cardinality="1..1"/>
  <reference name="d" interface="ID" bind="setD" unbind="unsetD"
cardinality="1..1"/>
</component>

bundle D:
<component name="D1">
  <implementation class="D1"/>
  <service>
    <provide interface="ID"/>
  </service>
  <property name="service.pid"         value="D1"/>
  <property name="service.ranking"     value="1000"/>
  <reference name="logger" interface="org.osgi.service.log.LogService"
bind="setLog" unbind="unsetLog" cardinality="0..1" policy="dynamic"/>
</component>

Reading the OSGi DS spec I assume the only valid method invocation order
(if the methods exists and are accessible) is:
1) D1.activate()                   -> some instanceD
2) A1.setD(instanceD)
3) A1.activate()                   -> some instanceA
4) B1.setA(instanceA) and B1.setD(instanceD) in any order
5) B1.activate()                   -> some instanceB
6) A1.setB(instanceB)

Sometimes, it happens that B1 is activated before!!! A1. and I get the
following
order of calls from the OSGi log (calls to setD() are not logged!):

==
1: >Debug [51] D1: activate() [EMAIL PROTECTED]:file:../../build/d1.jar/
2: >Info [51] ServiceEvent REGISTERED {service.id=29}
3: >Info [54] ServiceEvent REGISTERED {service.id=30}
4: >Info [37] ServiceEvent REGISTERED {service.id=31}
5: >Info [52] ServiceEvent REGISTERED {service.id=32}
6: >Info [53] ServiceEvent REGISTERED {service.id=33}
7: >Warn [4] ComponentReference.bind(): bind method setE is not accessible!
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
8: >Warn [4] ComponentReference.bind(): bind method setB is not accessible!
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
9: >Debug [51] B1: activate() [EMAIL PROTECTED]:file:../../build/d1.jar/
10:>Debug [51] A1: setB() [EMAIL PROTECTED]:file:../../build/d1.jar/
11:>Debug [51] A1: setB() A1 not yet activated!!! [EMAIL PROTECTED]:
file:../../build/d1.jar/
12:>Debug [51] A1: activate() [EMAIL PROTECTED]:file:../../build/d1.jar/
13:>Debug [51] E1: activate() [EMAIL PROTECTED]:file:../../build/d1.jar/
14:>Debug [51] A1: setE() [EMAIL PROTECTED]:file:../../build/d1.jar/
15:>Debug [51] B2: activate() [EMAIL PROTECTED]:file:../../build/d1.jar/
16:>Debug [51] A1: setB() [EMAIL PROTECTED]:file:../../build/d1.jar/
17:>Warn [4] ComponentReference.bind(): service reference already bound:
{IB}={service.ranking=1000, service.pid=B1, component.name=B1,
component.id=4, service.id=33} [EMAIL PROTECTED]:
file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
==

Please observe line 11! I inserted the check for activation since else some
internal data structures of A1 were not
initialised and I had NullPointerExceptions.
Since I check for activation, all services are at least started.


I also have a run the whole thing with DS debugging enabled, interestingly
no service is started at all:

==
>Info [6] Log created; Log Size=100; Log Threshold=4 [EMAIL PROTECTED]:
file:org.eclipse.equinox.log_1.1.0.v20071203.jar/
>Info [6] ServiceEvent REGISTERED {service.id=23}
>Info [6] ServiceEvent REGISTERED {service.id=24}
>Info [6] ServiceEvent REGISTERED {service.id=25}
>Info [6] BundleEvent STARTED [EMAIL PROTECTED]:
file:org.eclipse.equinox.log_1.1.0.v20071203.jar/
>Debug [5] bundleentry://7/OSGI-INF/Activator.xml [EMAIL PROTECTED]:
file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Debug [5] [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Warn [5] [SCR - WorkThread] Timeout ocurred! Thread was blocked on
processing [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Info [7] BundleEvent STARTED [EMAIL PROTECTED]:file:../../build/b1.jar/
>Info [8] BundleEvent STARTED [EMAIL PROTECTED]:
file:org.apache.commons.logging_1.0.4.v200711021015.jar/
>Info [11] BundleEvent STARTED [EMAIL PROTECTED]:
file:org.eclipse.osgi.services_3.1.200.v20071203.jar/
>Debug [5] bundleentry://12/OSGI-INF/Activator.xml [EMAIL PROTECTED]:
file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Debug [5] [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Warn [5] [SCR - WorkThread] Timeout ocurred! Thread was blocked on
processing [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Info [12] BundleEvent STARTED [EMAIL PROTECTED]:file:../../build/a1.jar/
>Debug [5] bundleentry://14/OSGI-INF/Activator.xml [EMAIL PROTECTED]:
file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Debug [5] [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Warn [5] [SCR - WorkThread] Timeout ocurred! Thread was blocked on
processing [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Info [14] BundleEvent STARTED [EMAIL PROTECTED]:file:../../build/b2.jar/
>Debug [5] bundleentry://15/OSGI-INF/Activator.xml [EMAIL PROTECTED]:
file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Debug [5] [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Warn [5] [SCR - WorkThread] Timeout ocurred! Thread was blocked on
processing [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Info [15] BundleEvent STARTED [EMAIL PROTECTED]:file:../../build/e1.jar/
>Debug [5] bundleentry://16/OSGI-INF/Activator.xml [EMAIL PROTECTED]:
file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Debug [5] bundleentry://16/OSGI-INF/Command.xml [EMAIL PROTECTED]:
file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Debug [5] [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Warn [5] [SCR - WorkThread] Timeout ocurred! Thread was blocked on
processing [QueuedJob] WorkPerformer:
[EMAIL PROTECTED]; actionType 1
[EMAIL PROTECTED]:file:org.eclipse.equinox.ds_1.0.0.v20080218.jar/
>Info [16] BundleEvent STARTED [EMAIL PROTECTED]:file:../../build/d1.jar/
>Debug [17] DEBUG 17  [0] 1 :  [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 1001 : 0 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 101 : 0 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 102 : 0 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 3001 : 0 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 2001 : 0 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 3 : 4 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Info [17] ServiceEvent REGISTERED {service.id=26}
>Debug [17] DEBUG 17  [0] 4 : 1 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 33 : 3 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Info [17] ServiceEvent REGISTERED {service.id=27}
>Debug [17] DEBUG 17  [0] 5 : 0 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Debug [17] DEBUG 17  [0] 16 : 8 [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Info [17] BundleEvent STARTED [EMAIL PROTECTED]:
file:org.eclipse.equinox.util_1.0.0.v20080218.jar/
>Info [0] FrameworkEvent STARTLEVEL CHANGED System Bundle
==

Is there something wrong with my understanding of the DS or is there a
(timing related) issue
within the DS?

Yours sincerely

Stefan
_______________________________________________
equinox-dev mailing list
equinox-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev

<<inline: graycol.gif>>

<<inline: ecblank.gif>>

_______________________________________________
equinox-dev mailing list
equinox-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Reply via email to