0 Replies Latest reply on Jun 10, 2010 3:58 AM by thomas.diesler

    Apache Felix Resolver integration

    thomas.diesler

      The JBossOSGi Framework now sucessfully integrates the Felix Resolver.

       

      The code for the resolver integration is here

       

      http://github.com/jbosgi/jbosgi-framework/tree/master/resolver/src/main/java/org/jboss/osgi/framework/resolver

       

      By design, this module does not have a dependency on the jboss framework. Instead it extends the felix resolver API to cleanup and provide the necessary extension points for an arbitary framework to integrate with the felix resolver.

       

      Unfortunately, some changes to the felix resolver API were necessary to remove dependencies on felix framework internals.

      I made those changes to the jbosg320 branch on the felix-framework git-svn mirror. (You can click on the blue dots to see the content of the individual commits)

       

      Ideally, and over time those abstract classes in org.jboss.osgi.framework.resolver would bubble up to the felix code base and felix would provide a standalone resolver maven artifact that is independent of the felix framework (I could help with that if needed)

       

      In the jboss framework, I integrate with the reslover abstract classes here

      http://github.com/jbosgi/jbosgi-framework/tree/master/core/src/main/java/org/jboss/osgi/framework/resolver/felix

       

      The resolver is configured like this

       

      <bean name="OSGiResolverPlugin" class="org.jboss.osgi.framework.resolver.felix.FelixResolverPlugin">
          <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
      </bean>
      

       

      JBoss as well as Felix has the notion of requirements and capabilities. The integration essentially maps jboss reqs/caps to Felix reqs/caps and runs the resolver with it. The result is returned as a set of felix Wire objects. Those wires are examined when the MC tries to match its osgi reqs with the available caps. (i.e. in OSGiPackageCapability.resolves(Module reqModule, Requirement mcreq))

       

       

            // Get the optional ResolverPlugin
            OSGiBundleManager bundleManager = bundleState.getBundleManager();
            ResolverPlugin resolver = bundleManager.getOptionalPlugin(ResolverPlugin.class);
            if (resolver != null)
            {
               // [JBOSGI-330] Revisit capability matching for dynamic imports
               if (resolver instanceof FelixResolverPlugin)
               {
                  if (osgireq.isDynamic() && osgireq.isOptional() == false)
                  {
                     match = super.resolves(reqModule, mcreq);
                     return match;
                  }
               }
               
               // Match the requirement through the Resolver
               match = resolver.match(this, osgireq);
            }
            else
            {
               // Match package name and version plus additional OSGi attributes
               match = super.resolves(reqModule, mcreq);
               match &= matchAttributes(osgireq);
            }
      

       

      OSGiPackageCapability