Package com.opensymphony.oscache.general

Examples of com.opensymphony.oscache.general.GeneralCacheAdministrator


            int maxCacheSize = getIntConfigurationValue(facesContext, CoreConfiguration.Items.resourcesCacheSize);
            LOG.info(MessageFormat.format("Maximum cache size hasn''t been set, resetting to {0} max items", maxCacheSize));
            cacheProperties.put(AbstractCacheAdministrator.CACHE_CAPACITY_KEY, Integer.toString(maxCacheSize));
        }

        GeneralCacheAdministrator cacheAdministrator = new GeneralCacheAdministrator(cacheProperties);
        cacheAdministrators.add(cacheAdministrator);
        return new OSCacheCache(cacheAdministrator.getCache());
    }
View Full Code Here


      }
    }
  }

  private void assertCacheManagerWasConfigured() {
    GeneralCacheAdministrator cacheAdministrator = getCacheManager();

    assertNotNull(cacheAdministrator);

    String expected = configProperties
        .getProperty(CACHE_CAPACITY_PROPERTY_NAME);

    String actual = cacheAdministrator
        .getProperty(CACHE_CAPACITY_PROPERTY_NAME);

    assertEquals(expected, actual);
  }
View Full Code Here

      cacheAdministrator.destroy();
    }
  }

  private void setUpCacheAdministrator() {
    cacheAdministrator = new GeneralCacheAdministrator();

    Cache cache = cacheAdministrator.getCache();

    cacheEntryEventListener = new CacheEntryEventListenerImpl();
    cache.addCacheEventListener(cacheEntryEventListener,
View Full Code Here

   * @see AbstractCacheManagerFactoryBean#createCacheManager()
   */
  protected void createCacheManager() throws Exception {
    Properties configProperties = getConfigProperties();
    if (configProperties == null) {
      cacheManager = new GeneralCacheAdministrator();
    } else {
      cacheManager = new GeneralCacheAdministrator(configProperties);
    }
  }
View Full Code Here

  public void testDestroyCacheManager() throws Exception {
    setUpAlternativeConfigurationProperties();
    cacheManagerFactoryBean.createCacheManager();

    GeneralCacheAdministrator cacheManager = getCacheManager();

    String key = "jedi";
    String entry = "Anakin";
    cacheManager.putInCache(key, entry);
    assertSame(entry, cacheManager.getFromCache(key));

    cacheManagerFactoryBean.destroyCacheManager();

    try {
      cacheManager.getFromCache(key);
      fail("There should not be any cache elements");

    } catch (NeedsRefreshException needsRefreshException) {
      // we are expecting this exception.
    }
View Full Code Here

        if ( this.getCacheKey() != null )
        {
            cacheProperties.put( "cache.key", this.getCacheKey() );
        }
        cacheProperties.put( "cache.use.host.domain.in.key", Boolean.toString( this.isCacheUseHostDomainInKey() ) );
        this.generalCacheAdministrator = new GeneralCacheAdministrator( cacheProperties );
        this.osCacheStatistics = new OsCacheStatistics( this.generalCacheAdministrator.getCache() );
    }
View Full Code Here

    //cacacity of cache (how many entries)
    int cacheCapacity=conf.getInt("cache.capacity", 1000);
    p.setProperty("cache.capacity", Integer.toString(cacheCapacity));
   
    cacheadmin=new GeneralCacheAdministrator(p);
    cache=cacheadmin.getCache();
  }
View Full Code Here

            String configResourceName = null;
            if (hibernateSystemProperties != null) {
                configResourceName = (String) hibernateSystemProperties.get(OSCACHE_CONFIGURATION_RESOURCE_NAME);
            }
            if (StringUtil.isEmpty(configResourceName)) {
                cache = new GeneralCacheAdministrator();
            } else {
                Properties propertiesOSCache = Config.loadProperties(configResourceName, this.getClass().getName());
                cache = new GeneralCacheAdministrator(propertiesOSCache);
            }
            LOG.debug("OSCacheProvider started.");
        } else {
            LOG.warn("Tried to restart OSCacheProvider, which is already running.");
        }
View Full Code Here

    public void testDefaultOverrides() {

        Properties props = new Properties();
        props.put(OSQueryCache.DEFAULT_REFRESH_KEY, "15");
        props.put(OSQueryCache.DEFAULT_CRON_KEY, "9 * * * * *");
        OSQueryCache cache = new OSQueryCache(new GeneralCacheAdministrator(), props);

        assertNull(cache.refreshSpecifications);
        assertEquals("9 * * * * *", cache.defaultRefreshSpecification.cronExpression);
        assertEquals(15, cache.defaultRefreshSpecification.refreshPeriod);
    }
View Full Code Here

        props.put(OSQueryCache.GROUP_PREFIX + "XYZ" + OSQueryCache.REFRESH_SUFFIX, "35");
        props.put(
                OSQueryCache.GROUP_PREFIX + "XYZ" + OSQueryCache.CRON_SUFFIX,
                "24 * * * * *");

        OSQueryCache cache = new OSQueryCache(new GeneralCacheAdministrator(), props);

        assertNotNull(cache.refreshSpecifications);
        assertEquals(2, cache.refreshSpecifications.size());

        RefreshSpecification abc = cache.refreshSpecifications.get("ABC");
View Full Code Here

TOP

Related Classes of com.opensymphony.oscache.general.GeneralCacheAdministrator

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.