Package org.jboss.cache

Examples of org.jboss.cache.CacheManagerImpl


    */
   public void testBasic() throws Exception
   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig("stacks.xml"); // the default stacks in jgroups.jar
      CacheManagerImpl registry = new CacheManagerImpl(DEFAULT_CONFIGURATION_FILE, cf);
      registry.start();

      ConfigurationRegistry configRegistry = registry.getConfigurationRegistry();

      Set<String> configNames = registry.getConfigurationNames();
      assertEquals(7, configNames.size());
      Set<String> cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());

      for (String configName : configNames)
      {
         assertNull(configName + " not created", registry.getCache(configName, false));
         Cache<Object, Object> cache = registry.getCache(configName, true);
         caches.add(cache);

         // Cache shouldn't be started
         assertEquals(CacheStatus.INSTANTIATED, cache.getCacheStatus());
         cache.create();
         cache.start();

         // Config should be a clone
         Configuration rawConfig = configRegistry.getConfiguration(configName);
         Configuration realConfig = cache.getConfiguration();
         assertFalse(rawConfig == realConfig);
         assertEquals(rawConfig.getClusterName(), realConfig.getClusterName());
      }

      cacheNames = registry.getCacheNames();
      assertEquals(configNames, cacheNames);

      // Test basic releasing of caches
      for (String configName : configNames)
      {
         registry.releaseCache(configName);
      }

      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());

      // We shouldn't have affected configuration set
      Set<String> configNames2 = registry.getConfigurationNames();
      assertEquals(configNames, configNames2);

      // Releasing only checkout of cache should have destroyed it
      for (Iterator<Cache<Object, Object>> it = caches.iterator(); it.hasNext();)
      {
         assertEquals(CacheStatus.DESTROYED, it.next().getCacheStatus());
         it.remove();
      }

      // Get cache w/o asking to create returns null
      String configName = configNames.iterator().next();
      assertNull(configName + " not created", registry.getCache(configName, false));
      // Get cache w/ asking to create returns cache
      Cache<Object, Object> cache = registry.getCache(configName, true);
      assertFalse(null == cache);
      caches.add(cache);

      cache.create();
      cache.start();

      // Test 2 checkouts of the same cache
      Cache<Object, Object> cache2 = registry.getCache(configName, true);
      assertTrue(cache == cache2);

      registry.releaseCache(configName);

      // One release does not cause registry to stop cache
      assertEquals(CacheStatus.STARTED, cache.getCacheStatus());

      registry.stop();

      // Now it's stopped
      assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());
      caches.remove(cache);

      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
      assertEquals(cacheNames, registry.getConfigurationNames());
   }
View Full Code Here


   public void testNullConfigResource() throws Exception
   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig("stacks.xml"); // the default stacks in jgroups.jar
      String configResource = null;
      CacheManagerImpl registry = new CacheManagerImpl(configResource, cf);
      registry.start();

      assertEquals("No configs", 0, registry.getConfigurationNames().size());
   }
View Full Code Here

                        channelFactory.setMultiplexerConfig(muxStacks);
                    }
                }
               
                String factoryRes = PropertiesHelper.getString(CACHE_FACTORY_RESOURCE_PROP, properties, DEF_CACHE_FACTORY_RESOURCE);
                jbcFactory = new CacheManagerImpl(factoryRes, channelFactory);
                ((CacheManagerImpl) jbcFactory).start();
                selfCreatedFactory = true;
            }
           
            if (settings.isSecondLevelCacheEnabled()) {
View Full Code Here

               
                String factoryRes = PropertiesHelper.getString(CACHE_FACTORY_RESOURCE_PROP, properties, null);
                if (factoryRes == null) {
                  factoryRes = PropertiesHelper.getString(LEGACY_CACHE_FACTORY_RESOURCE_PROP, properties, DEF_CACHE_FACTORY_RESOURCE);
                }
                jbcFactory = new CacheManagerImpl(factoryRes, channelFactory);
                ((CacheManagerImpl) jbcFactory).start();
                selfCreatedFactory = true;
            }
           
            if (settings.isSecondLevelCacheEnabled()) {
View Full Code Here

      {
         this.channelFactory = new JChannelFactory();
         this.channelFactory.setMultiplexerConfig(this.jgConfig);
      }
     
      CacheManagerImpl jbcFactory = new CacheManagerImpl(this.jbcConfig, this.channelFactory);
      this.cacheManagerRef.set(jbcFactory);
      jbcFactory.start();
   }
View Full Code Here

      {
         this.channelFactory = new JChannelFactory();
         this.channelFactory.setMultiplexerConfig(this.jgConfig);
      }
     
      CacheManagerImpl jbcFactory = new CacheManagerImpl(this.jbcConfig, this.channelFactory);
      this.cacheManagerRef.set(jbcFactory);
      jbcFactory.start();
   }
View Full Code Here

    */
   public void testBasic() throws Exception
   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig("stacks.xml"); // the default stacks in jgroups.jar
      CacheManagerImpl registry = new CacheManagerImpl(DEFAULT_CONFIGURATION_FILE, cf);
      registry.start();

      ConfigurationRegistry configRegistry = registry.getConfigurationRegistry();

      Set<String> configNames = registry.getConfigurationNames();
      assertEquals(7, configNames.size());
      Set<String> cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());

      for (String configName : configNames)
      {
         assertNull(configName + " not created", registry.getCache(configName, false));
         Cache<Object, Object> cache = registry.getCache(configName, true);
         caches.add(cache);

         // Cache shouldn't be started
         assertEquals(CacheStatus.INSTANTIATED, cache.getCacheStatus());
         cache.create();
         cache.start();

         // Config should be a clone
         Configuration rawConfig = configRegistry.getConfiguration(configName);
         Configuration realConfig = cache.getConfiguration();
         assertFalse(rawConfig == realConfig);
         assertEquals(rawConfig.getClusterName(), realConfig.getClusterName());
      }

      cacheNames = registry.getCacheNames();
      assertEquals(configNames, cacheNames);

      // Test basic releasing of caches
      for (String configName : configNames)
      {
         registry.releaseCache(configName);
      }

      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());

      // We shouldn't have affected configuration set
      Set<String> configNames2 = registry.getConfigurationNames();
      assertEquals(configNames, configNames2);

      // Releasing only checkout of cache should have destroyed it
      for (Iterator<Cache<Object, Object>> it = caches.iterator(); it.hasNext();)
      {
         assertEquals(CacheStatus.DESTROYED, it.next().getCacheStatus());
         it.remove();
      }

      // Get cache w/o asking to create returns null
      String configName = configNames.iterator().next();
      assertNull(configName + " not created", registry.getCache(configName, false));
      // Get cache w/ asking to create returns cache
      Cache<Object, Object> cache = registry.getCache(configName, true);
      assertFalse(null == cache);
      caches.add(cache);

      cache.create();
      cache.start();

      // Test 2 checkouts of the same cache
      Cache<Object, Object> cache2 = registry.getCache(configName, true);
      assertTrue(cache == cache2);

      registry.releaseCache(configName);

      // One release does not cause registry to stop cache
      assertEquals(CacheStatus.STARTED, cache.getCacheStatus());

      registry.stop();

      // Now it's stopped
      assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());
      caches.remove(cache);

      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
      assertEquals(cacheNames, registry.getConfigurationNames());
   }
View Full Code Here

   public void testNullConfigResource() throws Exception
   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig("stacks.xml"); // the default stacks in jgroups.jar
      String configResource = null;
      CacheManagerImpl registry = new CacheManagerImpl(configResource, cf);
      registry.start();

      assertEquals("No configs", 0, registry.getConfigurationNames().size());
   }
View Full Code Here

                        channelFactory.setMultiplexerConfig(muxStacks);
                    }
                }
               
                String factoryRes = PropertiesHelper.getString(CACHE_FACTORY_RESOURCE_PROP, properties, DEF_CACHE_FACTORY_RESOURCE);
                jbcFactory = new CacheManagerImpl(factoryRes, channelFactory);
                ((CacheManagerImpl) jbcFactory).start();
                selfCreatedFactory = true;
            }
           
            if (settings.isSecondLevelCacheEnabled()) {
View Full Code Here

    */
   public void testBasic() throws Exception
   {
      JChannelFactory cf = new JChannelFactory();
      cf.setMultiplexerConfig("stacks.xml"); // the default stacks in jgroups.jar
      CacheManagerImpl registry = new CacheManagerImpl(DEFAULT_CONFIGURATION_FILE, cf);
      registry.start();
     
      ConfigurationRegistry configRegistry = registry.getConfigurationRegistry();
     
      Set<String> configNames = registry.getConfigurationNames();
      assertEquals(7, configNames.size());
      Set<String> cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
     
      for (String configName : configNames)
      {
         assertNull(configName + " not created", registry.getCache(configName, false));
         Cache<Object, Object> cache = registry.getCache(configName, true);        
         caches.add(cache);
        
         // Cache shouldn't be started
         assertEquals(CacheStatus.INSTANTIATED, cache.getCacheStatus());
         cache.create();
         cache.start();
        
         // Config should be a clone
         Configuration rawConfig = configRegistry.getConfiguration(configName);
         Configuration realConfig = cache.getConfiguration();
         assertFalse(rawConfig == realConfig);
         assertEquals(rawConfig.getClusterName(), realConfig.getClusterName());
      }
     
      cacheNames = registry.getCacheNames();
      assertEquals(configNames, cacheNames);
     
      // Test basic releasing of caches
      for (String configName : configNames)
      {
         registry.releaseCache(configName);        
      }
     
      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
     
      // We shouldn't have affected configuration set
      Set<String> configNames2 = registry.getConfigurationNames();
      assertEquals(configNames, configNames2);
     
      // Releasing only checkout of cache should have destroyed it
      for (Iterator<Cache<Object, Object>> it = caches.iterator(); it.hasNext();)
      {
         assertEquals(CacheStatus.DESTROYED, it.next().getCacheStatus());
         it.remove();
      }
     
      // Get cache w/o asking to create returns null
      String configName = configNames.iterator().next();
      assertNull(configName + " not created", registry.getCache(configName, false));
      // Get cache w/ asking to create returns cache
      Cache<Object, Object> cache = registry.getCache(configName, true);
      assertFalse(null == cache);
      caches.add(cache);
     
      cache.create();
      cache.start();
     
      // Test 2 checkouts of the same cache
      Cache<Object, Object> cache2 = registry.getCache(configName, true);     
      assertTrue(cache == cache2);
     
      registry.releaseCache(configName);
     
      // One release does not cause registry to stop cache
      assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
     
      registry.stop();
     
      // Now it's stopped
      assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());
      caches.remove(cache);
     
      cacheNames = registry.getCacheNames();
      assertEquals(0, cacheNames.size());
      assertEquals(cacheNames, registry.getConfigurationNames());
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.CacheManagerImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.