[jboss-dev-forums] [JBoss OSGi Development] - Re: Cannot resolve circular dependencies

thomas.diesler@jboss.com do-not-reply at jboss.com
Wed Sep 9 06:25:05 EDT 2009


I isolated the issue sufficiently to this problem

BundleC 
  exports A, B
  imports A
 
BundleD 
  exports A,
  imports A, B

Both bundles will only resolve if one uses a self dependency.

I modified the code such that the Domain warns if a requirement resolves against multiple modules


  |       Module firstMatch = null;
  |       for (Module other : modules)
  |       {
  |          List<Capability> capabilities = other.getCapabilities();
  |          if (capabilities != null)
  |          {
  |             for (Capability capability : capabilities)
  |             {
  |                if (capability.resolves(other, module, requirement))
  |                {
  |                   if (firstMatch != null)
  |                   {
  |                      String otherName = other.getName() + ":" + other.getVersion(); 
  |                      String firstName = firstMatch.getName() + ":" + firstMatch.getVersion(); 
  |                      log.warn("Requirement " + requirement + " resolves agaist " + firstName + " and " + otherName + " - using first.");
  |                   }
  |                   if (firstMatch == null)
  |                      firstMatch = other;
  |                }
  |             }
  |          }
  |       }
  | 

and 


  | I extended the interface like this
  | 
  | public interface Capability extends Serializable
  | {
  |    /**
  |     * Whether this capability resolves the requirement
  |     *
  |     * @param capModule the capability module
  |     * @param reqModule the requirement module
  |     * @param requirement the requirement
  |     * @throws IllegalArgumentException for a null requirement
  |     * @return true when it is resolves the requirement
  |     */
  |    boolean resolves(Module capModule, Module reqModule, Requirement requirement);
  | }
  | 
  | which allows capability/requirement matching in the context of both modules.
  | 
  | 
  |   | public interface Capability extends Serializable
  |   | {
  |   |    /**
  |   |     * Whether this capability resolves the requirement
  |   |     * 
  |   |     * @param capModule the capability module
  |   |     * @param reqModule the requirement module
  |   |     * @param requirement the requirement
  |   |     * @throws IllegalArgumentException for a null requirement
  |   |     * @return true when it is resolves the requirement
  |   |     */
  |   |    boolean resolves(Module capModule, Module reqModule, Requirement requirement);
  |   | }
  |   | 
  | 
  | 

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

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



More information about the jboss-dev-forums mailing list