[jboss-cvs] JBossAS SVN: r106405 - projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jul 2 16:14:56 EDT 2010


Author: pferraro
Date: 2010-07-02 16:14:56 -0400 (Fri, 02 Jul 2010)
New Revision: 106405

Modified:
   projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java
Log:
Add install/uninstall callbacks for CacheManagerRegistryConfigurationEntry

Modified: projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java
===================================================================
--- projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java	2010-07-02 19:35:06 UTC (rev 106404)
+++ projects/cluster/ha-server-cache-ispn/trunk/src/main/java/org/jboss/ha/infinispan/CacheManagerRegistryImpl.java	2010-07-02 20:14:56 UTC (rev 106405)
@@ -32,6 +32,8 @@
 import javax.naming.NamingException;
 
 import org.infinispan.manager.CacheManager;
+import org.jboss.beans.metadata.api.annotations.Install;
+import org.jboss.beans.metadata.api.annotations.Uninstall;
 import org.jboss.ha.infinispan.config.CacheManagerRegistryConfiguration;
 import org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationEntry;
 import org.jboss.ha.infinispan.config.CacheManagerRegistryConfigurationSource;
@@ -83,22 +85,12 @@
       
       for (CacheManagerRegistryConfigurationEntry entry: registry.getEntries())
       {
-         String id = entry.getId();
-         String jndiName = entry.getJndiName();
-         
-         // If no jndi name was specified, construct one using the id
-         if (jndiName == null)
+         if (entry.getJndiName() == null)
          {
-            jndiName = this.context.composeName(id, registry.getBaseJndiName());
+            entry.setJndiName(this.context.composeName(entry.getId(), registry.getBaseJndiName()));
          }
          
-         CacheManager manager = this.factory.createCacheManager(new CacheManagerConfigurationAdapter(entry.getConfiguration()));
-         
-         // Store cache managers with jndi name, so they can be unbound during stop()
-         this.cacheManagers.put(id, new AbstractMap.SimpleImmutableEntry<String, CacheManager>(jndiName, manager));
-         
-         // Bind cache manager to jndi
-         this.context.bind(jndiName, manager);
+         this.add(entry);
       }
 
       CacheManagerRegistryConfigurationEntry defaultEntry = registry.getDefaultEntry();
@@ -153,4 +145,31 @@
       // Return default cache manager, if name was not found or if it was null
       return (entry != null) ? entry.getValue() : this.defaultCacheManager;
    }
+   
+   @Install
+   public void add(CacheManagerRegistryConfigurationEntry entry) throws NamingException
+   {
+      CacheManager manager = this.factory.createCacheManager(new CacheManagerConfigurationAdapter(entry.getConfiguration()));
+      
+      String jndiName = entry.getJndiName();
+      
+      // Store cache managers with jndi name, so they can be unbound during stop()
+      this.cacheManagers.put(entry.getId(), new AbstractMap.SimpleImmutableEntry<String, CacheManager>(jndiName, manager));
+      
+      // Bind cache manager to jndi
+      this.context.bind(jndiName, manager);
+   }
+   
+   @Uninstall
+   public void remove(CacheManagerRegistryConfigurationEntry config) throws NamingException
+   {
+      Map.Entry<String, CacheManager> entry = this.cacheManagers.remove(config.getId());
+      
+      if (entry != null)
+      {
+         entry.getValue().stop();
+         
+         this.context.unbind(entry.getKey());
+      }
+   }
 }



More information about the jboss-cvs-commits mailing list