[jboss-osgi-commits] JBoss-OSGI SVN: r93285 - projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue Sep 8 12:33:03 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-09-08 12:33:03 -0400 (Tue, 08 Sep 2009)
New Revision: 93285

Added:
   projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java
Log:
Add capability cache - wip

Added: 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	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapabilityCache.java	2009-09-08 16:33:03 UTC (rev 93285)
@@ -0,0 +1,87 @@
+/*
+* 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.HashMap;
+import java.util.Map;
+
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.classloading.spi.metadata.Requirement;
+
+
+/**
+ * [TODO] 
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 08-Sep-2009
+ */
+public class OSGiPackageCapabilityCache
+{
+   // [TODO] remove static usage
+   private static OSGiPackageCapabilityCache cacheInstance;
+   
+   private Map<Requirement, Module> preliminaryMatches = new HashMap<Requirement, Module>();
+   private Map<Requirement, Module> blacklistedMatches = new HashMap<Requirement, Module>();
+   private Map<Requirement, Module> cachedMatches = new HashMap<Requirement, Module>();
+
+   private OSGiPackageCapabilityCache()
+   {
+      cacheInstance = this;
+   }
+   
+   public static OSGiPackageCapabilityCache getInstance()
+   {
+      if (cacheInstance == null)
+      {
+         cacheInstance = new OSGiPackageCapabilityCache();
+      }
+      return cacheInstance; 
+   }
+   
+   public Module getCachedMatch(Requirement requirement)
+   {
+      return cachedMatches.get(requirement);
+   }
+   
+   public void addPreliminaryMatch(Requirement requirement, Module module)
+   {
+      preliminaryMatches.put(requirement, module);
+   }
+   
+   public boolean isValidMatch(Requirement requirement, Module module)
+   {
+      Module other = blacklistedMatches.get(requirement);
+      return module != other;
+   }
+   
+   public void storePreliminaryMatches()
+   {
+      cachedMatches.putAll(preliminaryMatches);
+      preliminaryMatches.clear();
+   }
+   
+   public void blacklistPreliminaryMatches()
+   {
+      blacklistedMatches.putAll(preliminaryMatches);
+      preliminaryMatches.clear();
+   }
+}



More information about the jboss-osgi-commits mailing list