- for(Bundle bundle : bundleContext.getBundles()){
- if(bundle.getState() != Bundle.ACTIVE && bundle.getState() != Bundle.RESOLVED) {
- System.out.println("Failed to activate/resolve bundle = " + bundle.getSymbolicName() + " state = " + stateToString(bundle.getState()));
- failed = true;
+ boolean resolved = false;
+ while (!resolved) {
+ resolved = true;
+ failed = false;
+ for(Bundle bundle : bundleContext.getBundles()){
+ /*
+ * A bundle should be ACTIVE, unless it a fragment, in which case it should be RESOLVED
+ */
+ int state = bundle.getState();
+ if ((bundle.adapt(BundleRevision.class).getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) {
+ //fragment
+ if (state != Bundle.RESOLVED) {
+ System.out.println("------ Failed to activate/resolve fragment = " + bundle.getSymbolicName() + " state = " + stateToString(bundle.getState()));
+ failed = true;
+ if (state == Bundle.STARTING)
+ resolved = false;
+ }
+ } else {
+ if(state != Bundle.ACTIVE) {
+ System.out.println("------ Failed to activate/resolve bundle = " + bundle.getSymbolicName() + " state = " + stateToString(bundle.getState()));
+ failed = true;
+ if (state == Bundle.STARTING)
+ resolved = false;
+ }
+ }
+ }
+ if (!resolved) {
+ countup++;
+ if (countup < 60) {
+ System.out.println("all bundles haven't finished starting, will repeat");
+ try {
+ Thread.sleep(SUBSEQUENT_DELAY);
+ } catch (Exception e) {
+ ;
+ }
+ } else
+ resolved = true;