Package org.jboss.cache

Examples of org.jboss.cache.Cache


      replListeners = new ReplicationListener[getNumCacheManagers()];
      /* Make sure that the buddy group is formed before starting the tests */
      List<Cache> createdCaches = new ArrayList<Cache>();
      for (int i = 0; i <  getCacheManagers().size(); i++)
      {
         Cache cache = getCacheManagers().get(i).getCache(getCacheConfigName(), false);
         createdCaches.add(cache);
         replListeners[i] = ReplicationListener.getReplicationListener(cache);
      }
      BuddyReplicationTestsBase.waitForSingleBuddy(createdCaches);
   }
View Full Code Here


@Test(groups = "functional", testName = "notifications.CacheListenerRemovalTest")
public class CacheListenerRemovalTest
{
   public void testListenerRemoval()
   {
      Cache cache = new UnitTestCacheFactory().createCache(getClass());
      AtomicInteger i = new AtomicInteger(0);
      try
      {
         assert 0 == cache.getCacheListeners().size();
         Listener l = new Listener(i);
         cache.addCacheListener(l);
         assert 1 == cache.getCacheListeners().size();
         assert cache.getCacheListeners().iterator().next() == l;
         assert 0 == i.get();
         cache.get(Fqn.ROOT, "x");
         assert 1 == i.get();

         // remove the listener
         cache.removeCacheListener(l);
         assert 0 == cache.getCacheListeners().size();
         i.set(0);
         assert 0 == i.get();
         cache.get(Fqn.ROOT, "x");
         assert 0 == i.get();
      }
      finally
      {
         cache.stop();
      }
   }
View Full Code Here

      Properties prop = UnitTestDatabaseManager.getTestDbProperties();

      // ensure cleanup after each test
      prop.setProperty("cache.jdbc.table.drop", "true");

      Cache cache = new UnitTestCacheFactory<Object, Object>().createCache(false, getClass());
      Configuration config = cache.getConfiguration();
      config.setUseRegionBasedMarshalling(useRegionBased);
      config.setInactiveOnStartup(useRegionBased);

      int wakeupInterval = 1000000; // a long time; really disabled
      EvictionConfig ec = new EvictionConfig(
View Full Code Here

   */
  private void registerAllJBossTreeCacheMBeans() {
      try {
        log.info("start to register all JBoss Treecache MBeans...");
        CacheFactory factory = new DefaultCacheFactory();
        Cache cache = factory.createCache("treecache.xml");
        ObjectName cacheObjectName = new ObjectName("jboss.cache:service=Cache");
        JmxRegistrationManager jmxRegistrationManager = new JmxRegistrationManager(server, cache, cacheObjectName );
        jmxRegistrationManager.registerAllMBeans();
        log.info("registered all JBoss Treecache MBeans");
      } catch (MalformedObjectNameException e) {
View Full Code Here

     
      Set<Cache> caches = new HashSet<Cache>();
     
      for (String name : cores)
      {
         Cache cache = registry.getCache(name, false);
         assertNotNull(cache);
         assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
         caches.add(cache);
      }
     
//      for (String name : pojos)
//      {
//         PojoCache pojocache = registry.getPojoCache(name, false);
//         assertNotNull(pojocache);
//         Cache cache = pojocache.getCache();
//         assertEquals(CacheStatus.STARTED, cache.getCacheStatus());
//         caches.add(cache);
//      }
//     
      for (String name : cores)
      {
         registry.releaseCache(name);
      }
     
//      for (String name : pojos)
//      {
//         registry.releaseCache(name);
//      }
     
      for (Cache cache : caches)
      {
         assertEquals(CacheStatus.STARTED, cache.getCacheStatus());        
      }
     
      registry.stop();
     
      for (Cache cache : caches)
      {
         assertEquals(CacheStatus.DESTROYED, cache.getCacheStatus());        
      }
     
   }
View Full Code Here

     
      configNames = registry.getConfigurationNames();
      assertEquals(18, configNames.size());
      assertTrue(configNames.contains("alias"));
     
      Cache cache = registry.getCache("alias", true);
      assertNotNull(cache);
      Cache other = registry.getCache(DEFAULT_CONFIG, false);
      assertEquals(cache, other);
     
      assertEquals(1, registry.getCacheNames().size());
     
      registry.releaseCache(DEFAULT_CONFIG);
View Full Code Here

         if (cacheHandler == null)
         {
            throw new IllegalStateException("No clustered cache available");
         }
        
         @SuppressWarnings("unchecked")
         Cache c = null;
         synchronized (cacheHandler)
         {
            c = cacheHandler.getCache();
            if (c == null)
View Full Code Here

   private DistributedCacheManagerFactoryImpl delegate = new DistributedCacheManagerFactoryImpl();

   public void configure(boolean local, String passivationDir, boolean totalReplication, boolean marshalling,
         boolean purgeCacheLoader)
   {
      Cache pc = createCache(local, passivationDir, totalReplication, marshalling, purgeCacheLoader);
      delegate.setPlainCache(pc);
   }
View Full Code Here

      return delegate.getDistributedCacheManager(localManager);
  

   public void cleanup(boolean doRemove)
   {
      Cache cache = delegate.getPlainCache();
      if (cache == null)
         return;
     
      if (doRemove && CacheStatus.STARTED.equals(cache.getCacheStatus()))
      {
         // Try to clean up so we avoid loading sessions
         // from storage in later tests
         try
         {
            log.info("Removing /JSESSION from " + cache.getLocalAddress());
            cache.removeNode(Fqn.fromString("/JSESSION"));
         }
         catch (Exception e)
         {
            log.error("Cache " + cache + ": " + e.getMessage(), e);
         }
      }
     
      try
      {
         cache.stop();
         cache.destroy();
      }
      catch (Exception e)
      {
         log.error("Cache " + cache + ": " + e.getMessage(), e);
      }
View Full Code Here

      return config;
   }

   public Object getLocalAddress()
   {
      Cache pc = delegate.getPlainCache();
      return pc == null ? null : pc.getLocalAddress();
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.Cache

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.