[jboss-dev-forums] [Design of OSGi Integration] - Re: Runtime and bundle lifecycle/dependency resolution

alesj do-not-reply at jboss.com
Tue Mar 3 10:15:52 EST 2009


"alesj" wrote : "thomas.diesler at jboss.com" wrote : 
  |   | I'd suggest the BundleStartStopDeployer maintains a list of unresolved bundles and tries to resolve them before bundle.start() is attempted.
  |   | 
  | MC already does this.
  | Bundle == DeploymentControllerContext.
  | 
  | You're missing my point.
  | We should make sure the Bundle only gets to BSSD if it's properly resolved.
  | Any other hacking/duplicating is a step in the wrong direction.
  | 
Why do I see 

  |    // The list of unresolved bundles
  |    private List<Bundle> unresolvedBundles = new ArrayList<Bundle>();
  | 
when I explicitly said this is wrong?
Don't get me wrong or harsh or ..., but this way of interaction won't work.
At least you could argue/discuss/justify with me on this before you put it in.

To get into details even more.
All this code is just unnecessary, as it over complicates things

  |       // Get the required dependency on the PackageAdmin service
  |       if (packageAdmin == null)
  |       {
  |          ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
  |          packageAdmin = (PackageAdmin)systemContext.getService(sref);
  |          if (packageAdmin == null)
  |             throw new IllegalStateException("Cannot obtain PackageAdmin service");
  |       }
  |       
  |       // Always add the bundle as unresolved
  |       unresolvedBundles.add(bundle);
  |       
  |       Bundle[] bundleArr = new Bundle[unresolvedBundles.size()];
  |       unresolvedBundles.toArray(bundleArr);
  |       
  |       // Try to resolve the bundles
  |       packageAdmin.resolveBundles(bundleArr);
  |       
  |       // Find resolved bundles and start them
  |       Iterator<Bundle> it = unresolvedBundles.iterator();
  |       while(it.hasNext())
  |       {
  |          Bundle auxBundle = it.next();
  |          int state = auxBundle.getState();
  |          if (Bundle.RESOLVED == state)
  |          {
  |             it.remove();
  |             try
  |             {
  |                auxBundle.start();
  |                log.info("Started: " + auxBundle.getSymbolicName() + ",state=" + auxBundle.getState());
  |             }
  |             catch (BundleException e)
  |             {
  |                log.warn("Cannot start bundle", e);
  |             }
  |          }
  |       }
  | 
A simple proper DI creation in BundleClassLoaderDependencyDeployer would do all of the "tricks" necessary:
 * create proper spi/abstraction over what we can use
 * limit PackageAdmin usage to DI
 * no need to start all off the non-involved bundles

And I guess usage of system Bundle could also be reduced to minimum.
Perhaps moving the DI creation into OSGiDeployer.
Something to discuss ... 


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4214571#4214571

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4214571



More information about the jboss-dev-forums mailing list