[jboss-cvs] JBossAS SVN: r93350 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade: service and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 10 06:39:17 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-09-10 06:39:17 -0400 (Thu, 10 Sep 2009)
New Revision: 93350

Added:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiModuleAssociationHelper.java
Removed:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java
Modified:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
Log:
Reduce log to debug

Copied: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiModuleAssociationHelper.java (from rev 93345, projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiModuleAssociationHelper.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiModuleAssociationHelper.java	2009-09-10 10:39:17 UTC (rev 93350)
@@ -0,0 +1,179 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.plugins.facade.classloading;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.classloading.plugins.metadata.PackageRequirement;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.dependency.RequirementDependencyItem;
+import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
+
+/**
+ * A capabilty module association cache that helps the OSGiPackageCapability.
+ * 
+ * It decides if a given requirement matches against a capability in the context of both modules.
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 08-Sep-2009
+ */
+public class OSGiModuleAssociationHelper
+{
+   /** The log */
+   private static final Logger log = Logger.getLogger(OSGiModuleAssociationHelper.class);
+
+   private Map<String, List<Module>> moduleAssociations = new HashMap<String, List<Module>>();
+   private Map<String, Module> blacklistedModules = new HashMap<String, Module>();
+   private Map<String, Module> endorsedModules = new HashMap<String, Module>();
+
+   public static OSGiModuleAssociationHelper getInstance(OSGiBundleState bundleState)
+   {
+      DeploymentUnit unit = bundleState.getDeploymentUnit();
+      return unit.getAttachment(OSGiModuleAssociationHelper.class);
+   }
+
+   public void addModuleAssociation(PackageRequirement requirement, Module module)
+   {
+      String packageName = requirement.getName();
+      if (isBlacklisted(requirement, module))
+         throw new IllegalStateException("Cannot add blacklisted association: [" + packageName + "=" + getModuleName(module) + "]");
+      
+      List<Module> modules = moduleAssociations.get(packageName);
+      if (modules == null)
+      {
+         modules = new ArrayList<Module>();
+         moduleAssociations.put(packageName, modules);
+         modules.add(module);
+      }
+      else
+      {
+         Module firstMatch = modules.get(0);
+         if (firstMatch != module && modules.contains(module) == false)
+         {
+            log.debug("Add [" + packageName + "=[" + getModuleName(firstMatch)+ " ... " + getModuleName(module) + "]]");
+            modules.add(module);
+         }
+      }
+   }
+
+   public Module getCachedModule(PackageRequirement requirement)
+   {
+      String packageName = requirement.getName();
+      return endorsedModules.get(packageName);
+   }
+
+   public boolean isBlacklisted(PackageRequirement requirement, Module module)
+   {
+      String packageName = requirement.getName();
+      Module other = blacklistedModules.get(packageName);
+      boolean blacklisted = (module == other);
+      return blacklisted;
+   }
+
+   public void endorseModuleAssociations(Module module)
+   {
+      Map<String, Module> firstMatches = getMapOfFirstMatches(module);
+      if (firstMatches.isEmpty() == false)
+      {
+         log.debug(getLogMessage("Endorse module associations", firstMatches));
+         endorsedModules.putAll(firstMatches);
+      }
+      blacklistedModules.clear();
+      moduleAssociations.clear();
+   }
+   
+   public void blacklistModuleAssociations(Module module)
+   {
+      Map<String, Module> firstMatches = getMapOfFirstMatches(module);
+      if (firstMatches.isEmpty() == false)
+      {
+         log.debug(getLogMessage("Blacklist module associations", firstMatches));
+         blacklistedModules.putAll(firstMatches);
+      }
+      moduleAssociations.clear();
+   }
+
+   public void resetResolvedDependencies(ControllerContext context)
+   {
+      StringBuffer message = new StringBuffer("Unresolved requirements ");
+      DependencyInfo dependencyInfo = context.getDependencyInfo();
+      for (DependencyItem iDependOn : dependencyInfo.getIDependOn(RequirementDependencyItem.class))
+      {
+         // Reset all resolved dependency items
+         // [JBKERNEL-54] DependencyItem inconsistency when multiple possible matches
+         if (iDependOn.isResolved())
+         {
+            iDependOn.unresolved(context.getController());
+         }
+         else
+         {
+            RequirementDependencyItem reqdi = (RequirementDependencyItem)iDependOn;
+            Requirement unresolved = reqdi.getRequirement();
+            message.append("\n  " + unresolved);
+         }
+      }
+
+      // Log all unresolved dependency items
+      log.debug(message);
+   }
+
+   private Map<String, Module> getMapOfFirstMatches(Module module)
+   {
+      Map<String, Module> firstMatches = new HashMap<String, Module>();
+      for (Entry<String, List<Module>> entry : moduleAssociations.entrySet())
+      {
+         String packageName = entry.getKey();
+         List<Module> modules = entry.getValue();
+         Module other = modules.get(0);
+         if (module == other)
+            firstMatches.put(packageName, other);
+      }
+      return firstMatches;
+   }
+
+   private String getLogMessage(String message, Map<String, Module> matches)
+   {
+      StringBuffer buffer = new StringBuffer(message);
+      for (Entry<String, Module> entry : matches.entrySet())
+      {
+         String packageName = entry.getKey();
+         Module module = entry.getValue();
+         buffer.append("\n  [" + packageName + "=" + getModuleName(module) + "]");
+      }
+      return buffer.toString();
+   }
+
+   private String getModuleName(Module module)
+   {
+      return module.getName() + ":" + module.getVersion();
+   }
+}

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java	2009-09-10 10:38:54 UTC (rev 93349)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java	2009-09-10 10:39:17 UTC (rev 93350)
@@ -144,7 +144,7 @@
       PackageAttribute ourParameters = exportPackage;
       PackageAttribute otherParameters = packageRequirement.getRequirePackage();
 
-      OSGiPackageCapabilityCache capabilityCache = OSGiPackageCapabilityCache.getInstance(bundleState);
+      OSGiModuleAssociationHelper capabilityCache = OSGiModuleAssociationHelper.getInstance(bundleState);
       if (capabilityCache != null)
       {
          String packageName = packageRequirement.getName();

Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java	2009-09-10 10:38:54 UTC (rev 93349)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java	2009-09-10 10:39:17 UTC (rev 93350)
@@ -1,177 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.osgi.plugins.facade.classloading;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.jboss.classloading.plugins.metadata.PackageRequirement;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.dependency.RequirementDependencyItem;
-import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
-
-/**
- * A package capabilty cache that helps the OSGiPackageCapability to decide if a given requirement matches against a capability in the context of both modules.
- * 
- * @author Thomas.Diesler at jboss.com
- * @since 08-Sep-2009
- */
-public class OSGiPackageCapabilityCache
-{
-   /** The log */
-   private static final Logger log = Logger.getLogger(OSGiPackageCapabilityCache.class);
-
-   private Map<String, List<Module>> moduleAssociations = new HashMap<String, List<Module>>();
-   private Map<String, Module> blacklistedModules = new HashMap<String, Module>();
-   private Map<String, Module> endorsedModules = new HashMap<String, Module>();
-
-   public static OSGiPackageCapabilityCache getInstance(OSGiBundleState bundleState)
-   {
-      DeploymentUnit unit = bundleState.getDeploymentUnit();
-      return unit.getAttachment(OSGiPackageCapabilityCache.class);
-   }
-
-   public void addModuleAssociation(PackageRequirement requirement, Module module)
-   {
-      String packageName = requirement.getName();
-      if (isBlacklisted(requirement, module))
-         throw new IllegalStateException("Cannot add blacklisted association: [" + packageName + "=" + getModuleName(module) + "]");
-      
-      List<Module> modules = moduleAssociations.get(packageName);
-      if (modules == null)
-      {
-         modules = new ArrayList<Module>();
-         moduleAssociations.put(packageName, modules);
-         modules.add(module);
-      }
-      else
-      {
-         Module firstMatch = modules.get(0);
-         if (firstMatch != module && modules.contains(module) == false)
-         {
-            log.info("Add [" + packageName + "=[" + getModuleName(firstMatch)+ " ... " + getModuleName(module) + "]]");
-            modules.add(module);
-         }
-      }
-   }
-
-   public Module getCachedModule(PackageRequirement requirement)
-   {
-      String packageName = requirement.getName();
-      return endorsedModules.get(packageName);
-   }
-
-   public boolean isBlacklisted(PackageRequirement requirement, Module module)
-   {
-      String packageName = requirement.getName();
-      Module other = blacklistedModules.get(packageName);
-      boolean blacklisted = (module == other);
-      return blacklisted;
-   }
-
-   public void endorseModuleAssociations(Module module)
-   {
-      Map<String, Module> firstMatches = getMapOfFirstMatches(module);
-      if (firstMatches.isEmpty() == false)
-      {
-         log.info(getLogMessage("Endorse module associations", firstMatches));
-         endorsedModules.putAll(firstMatches);
-      }
-      blacklistedModules.clear();
-      moduleAssociations.clear();
-   }
-   
-   public void blacklistModuleAssociations(Module module)
-   {
-      Map<String, Module> firstMatches = getMapOfFirstMatches(module);
-      if (firstMatches.isEmpty() == false)
-      {
-         log.info(getLogMessage("Blacklist module associations", firstMatches));
-         blacklistedModules.putAll(firstMatches);
-      }
-      moduleAssociations.clear();
-   }
-
-   public void resetResolvedDependencies(ControllerContext context)
-   {
-      StringBuffer message = new StringBuffer("Unresolved requirements ");
-      DependencyInfo dependencyInfo = context.getDependencyInfo();
-      for (DependencyItem iDependOn : dependencyInfo.getIDependOn(RequirementDependencyItem.class))
-      {
-         // Reset all resolved dependency items
-         // [JBKERNEL-54] DependencyItem inconsistency when multiple possible matches
-         if (iDependOn.isResolved())
-         {
-            iDependOn.unresolved(context.getController());
-         }
-         else
-         {
-            RequirementDependencyItem reqdi = (RequirementDependencyItem)iDependOn;
-            Requirement unresolved = reqdi.getRequirement();
-            message.append("\n  " + unresolved);
-         }
-      }
-
-      // Log all unresolved dependency items
-      log.info(message);
-   }
-
-   private Map<String, Module> getMapOfFirstMatches(Module module)
-   {
-      Map<String, Module> firstMatches = new HashMap<String, Module>();
-      for (Entry<String, List<Module>> entry : moduleAssociations.entrySet())
-      {
-         String packageName = entry.getKey();
-         List<Module> modules = entry.getValue();
-         Module other = modules.get(0);
-         if (module == other)
-            firstMatches.put(packageName, other);
-      }
-      return firstMatches;
-   }
-
-   private String getLogMessage(String message, Map<String, Module> matches)
-   {
-      StringBuffer buffer = new StringBuffer(message);
-      for (Entry<String, Module> entry : matches.entrySet())
-      {
-         String packageName = entry.getKey();
-         Module module = entry.getValue();
-         buffer.append("\n  [" + packageName + "=" + getModuleName(module) + "]");
-      }
-      return buffer.toString();
-   }
-
-   private String getModuleName(Module module)
-   {
-      return module.getName() + ":" + module.getVersion();
-   }
-}

Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java	2009-09-10 10:38:54 UTC (rev 93349)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java	2009-09-10 10:39:17 UTC (rev 93350)
@@ -44,7 +44,7 @@
 import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
 import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
 import org.jboss.osgi.plugins.facade.bundle.OSGiBundleWrapper;
-import org.jboss.osgi.plugins.facade.classloading.OSGiPackageCapabilityCache;
+import org.jboss.osgi.plugins.facade.classloading.OSGiModuleAssociationHelper;
 import org.jboss.osgi.plugins.facade.plugins.AbstractServicePluginImpl;
 import org.jboss.osgi.spi.NotImplementedException;
 import org.osgi.framework.Bundle;
@@ -186,7 +186,7 @@
       int resolved = 1;
 
       // Repeatedly try to resolve the bundles until no more bundles can be resolved
-      OSGiPackageCapabilityCache cacheInstance = new OSGiPackageCapabilityCache();
+      OSGiModuleAssociationHelper cacheInstance = new OSGiModuleAssociationHelper();
       while (resolved > 0)
       {
          resolved = 0;
@@ -198,7 +198,7 @@
             Module module = assertModule(bundleState);
             
             DeploymentUnit unit = bundleState.getDeploymentUnit();
-            unit.addAttachment(OSGiPackageCapabilityCache.class, cacheInstance);
+            unit.addAttachment(OSGiModuleAssociationHelper.class, cacheInstance);
             
             if (bundleManager.resolve(bundleState, false))
             {




More information about the jboss-cvs-commits mailing list