net.sf.ehcache.CacheException Java Examples

The following examples show how to use net.sf.ehcache.CacheException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EHCacheProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 7 votes vote down vote up
public ResourceDataCache createDataCache() {
  try {
    final CacheManager manager = getCacheManager();
    synchronized( manager ) {
      if ( manager.cacheExists( DATA_CACHE_NAME ) == false ) {
        final Cache libloaderCache = new Cache( DATA_CACHE_NAME,   // cache name
          500,         // maxElementsInMemory
          false,       // overflowToDisk
          false,       // eternal
          600,         // timeToLiveSeconds
          600,         // timeToIdleSeconds
          false,       // diskPersistent
          120 );        // diskExpiryThreadIntervalSeconds
        manager.addCache( libloaderCache );
        return new EHResourceDataCache( libloaderCache );
      } else {
        return new EHResourceDataCache( manager.getCache( DATA_CACHE_NAME ) );
      }
    }
  } catch ( CacheException e ) {
    logger.debug( "Failed to create EHCache libloader-data cache", e );
    return null;
  }
}
 
Example #2
Source File: EhCacheSupportTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void testCacheManagerConflict() throws Exception {
	EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
	cacheManagerFb.setCacheManagerName("myCacheManager");
	assertEquals(CacheManager.class, cacheManagerFb.getObjectType());
	assertTrue("Singleton property", cacheManagerFb.isSingleton());
	cacheManagerFb.afterPropertiesSet();
	try {
		CacheManager cm = cacheManagerFb.getObject();
		assertTrue("Loaded CacheManager with no caches", cm.getCacheNames().length == 0);
		Cache myCache1 = cm.getCache("myCache1");
		assertTrue("No myCache1 defined", myCache1 == null);

		EhCacheManagerFactoryBean cacheManagerFb2 = new EhCacheManagerFactoryBean();
		cacheManagerFb2.setCacheManagerName("myCacheManager");
		cacheManagerFb2.afterPropertiesSet();
		fail("Should have thrown CacheException because of naming conflict");
	}
	catch (CacheException ex) {
		// expected
	}
	finally {
		cacheManagerFb.destroy();
	}
}
 
Example #3
Source File: AbstractCacheableService.java    From lutece-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Reset the cache.
 */
@Override
public void resetCache( )
{
    try
    {
        if ( _cache != null )
        {
            _cache.removeAll( );
        }
    }
    catch( CacheException | IllegalStateException e )
    {
        AppLogService.error( e.getMessage( ), e );
    }
}
 
Example #4
Source File: EhCache.java    From document-management-software with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public V get(K key) {
	try {
		Element element = cache.get(key);
		if (element != null) {
			return (V) element.getObjectValue();
		} else {
			return null;
		}
	} catch (IllegalStateException ie) {
		throw new RuntimeException("Failed to get from EhCache as state invalid: \n" + "  state: "
				+ cache.getStatus() + "\n" + "   key: " + key, ie);
	} catch (CacheException e) {
		throw new RuntimeException("Failed to get from EhCache: \n" + "   key: " + key, e);
	}
}
 
Example #5
Source File: CacheWrapperImpl.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @param cache
 */
protected CacheWrapperImpl(String cacheName, CacheConfig config) {
    this.cacheName = cacheName;
    this.config = config;
    this.cachemanager = CacheManager.getInstance();
    // now we need a cache which has appropriate (by configuration) values for cache configs such as ttl, tti, max elements and so on.
    // next line needed since cache can also be initialized through ehcache.xml
    if (cachemanager.cacheExists(cacheName)) {
        this.cache = cachemanager.getCache(cacheName);
        log.warn("using cache parameters from ehcache.xml for cache named '" + cacheName + "'");
    } else {
        this.cache = config.createCache(cacheName);
        try {
            cachemanager.addCache(this.cache);
        } catch (CacheException e) {
            throw new OLATRuntimeException("Problem when initializing the caches", e);
        }
    }
}
 
Example #6
Source File: EHResourceBundleDataCache.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Retrieves the given data from the cache.
 *
 * @param key the resource key for the data.
 */
public ResourceBundleDataCacheEntry get( final ResourceKey key ) {
  if ( key == null ) {
    throw new NullPointerException();
  }

  try {
    final Element element = dataCache.get( (Object) key );
    if ( element != null ) {
      if ( EHCacheModule.CACHE_MONITOR.isDebugEnabled() ) {
        EHCacheModule.CACHE_MONITOR.debug( "Bund Cache Hit  " + key );
      }
      return (ResourceBundleDataCacheEntry) element.getObjectValue();
    } else {
      if ( EHCacheModule.CACHE_MONITOR.isDebugEnabled() ) {
        EHCacheModule.CACHE_MONITOR.debug( "Bund Cache Miss " + key );
      }
      return null;
    }
  } catch ( CacheException e ) {
    logger.debug( "Failed to query cache", e );
    return null;
  }
}
 
Example #7
Source File: EhCacheSupportTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void testCacheManagerConflict() {
	EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
	cacheManagerFb.setCacheManagerName("myCacheManager");
	assertEquals(CacheManager.class, cacheManagerFb.getObjectType());
	assertTrue("Singleton property", cacheManagerFb.isSingleton());
	cacheManagerFb.afterPropertiesSet();
	try {
		CacheManager cm = cacheManagerFb.getObject();
		assertTrue("Loaded CacheManager with no caches", cm.getCacheNames().length == 0);
		Cache myCache1 = cm.getCache("myCache1");
		assertTrue("No myCache1 defined", myCache1 == null);

		EhCacheManagerFactoryBean cacheManagerFb2 = new EhCacheManagerFactoryBean();
		cacheManagerFb2.setCacheManagerName("myCacheManager");
		cacheManagerFb2.afterPropertiesSet();
		fail("Should have thrown CacheException because of naming conflict");
	}
	catch (CacheException ex) {
		// expected
	}
	finally {
		cacheManagerFb.destroy();
	}
}
 
Example #8
Source File: EHCacheProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ResourceFactoryCache createFactoryCache() {
  try {
    final CacheManager manager = getCacheManager();
    synchronized( manager ) {
      if ( manager.cacheExists( FACTORY_CACHE_NAME ) == false ) {
        final Cache libloaderCache = new Cache( FACTORY_CACHE_NAME,   // cache name
          500,         // maxElementsInMemory
          false,       // overflowToDisk
          false,       // eternal
          600,         // timeToLiveSeconds
          600,         // timeToIdleSeconds
          false,       // diskPersistent
          120 );        // diskExpiryThreadIntervalSeconds
        manager.addCache( libloaderCache );
        return new EHResourceFactoryCache( libloaderCache );
      } else {
        return new EHResourceFactoryCache( manager.getCache( FACTORY_CACHE_NAME ) );
      }
    }
  } catch ( CacheException e ) {
    logger.debug( "Failed to create EHCache libloader-factory cache", e );
    return null;
  }
}
 
Example #9
Source File: EHCacheProvider.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
public ResourceBundleDataCache createBundleDataCache() {
  try {
    final CacheManager manager = getCacheManager();
    synchronized( manager ) {
      if ( manager.cacheExists( BUNDLES_CACHE_NAME ) == false ) {
        final Cache libloaderCache = new Cache( BUNDLES_CACHE_NAME,   // cache name
          500,         // maxElementsInMemory
          false,       // overflowToDisk
          false,       // eternal
          600,         // timeToLiveSeconds
          600,         // timeToIdleSeconds
          false,       // diskPersistent
          120 );        // diskExpiryThreadIntervalSeconds
        manager.addCache( libloaderCache );
        return new EHResourceBundleDataCache( libloaderCache );
      } else {
        return new EHResourceBundleDataCache( manager.getCache( BUNDLES_CACHE_NAME ) );
      }
    }
  } catch ( CacheException e ) {
    logger.debug( "Failed to create EHCache libloader-bundles cache", e );
    return null;
  }
}
 
Example #10
Source File: EhCacheSupportTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void testCacheManagerConflict() {
	EhCacheManagerFactoryBean cacheManagerFb = new EhCacheManagerFactoryBean();
	cacheManagerFb.setCacheManagerName("myCacheManager");
	assertEquals(CacheManager.class, cacheManagerFb.getObjectType());
	assertTrue("Singleton property", cacheManagerFb.isSingleton());
	cacheManagerFb.afterPropertiesSet();
	try {
		CacheManager cm = cacheManagerFb.getObject();
		assertTrue("Loaded CacheManager with no caches", cm.getCacheNames().length == 0);
		Cache myCache1 = cm.getCache("myCache1");
		assertTrue("No myCache1 defined", myCache1 == null);

		EhCacheManagerFactoryBean cacheManagerFb2 = new EhCacheManagerFactoryBean();
		cacheManagerFb2.setCacheManagerName("myCacheManager");
		cacheManagerFb2.afterPropertiesSet();
		fail("Should have thrown CacheException because of naming conflict");
	}
	catch (CacheException ex) {
		// expected
	}
	finally {
		cacheManagerFb.destroy();
	}
}
 
Example #11
Source File: WebEhCacheManagerFacotryBean.java    From Lottery with GNU General Public License v2.0 6 votes vote down vote up
public void afterPropertiesSet() throws IOException, CacheException {
	log.info("Initializing EHCache CacheManager");
	Configuration config = null;
	if (this.configLocation != null) {
		config = ConfigurationFactory
				.parseConfiguration(this.configLocation.getInputStream());
		if (this.diskStoreLocation != null) {
			DiskStoreConfiguration dc = new DiskStoreConfiguration();
			dc.setPath(this.diskStoreLocation.getFile().getAbsolutePath());
			try {
				config.addDiskStore(dc);
			} catch (ObjectExistsException e) {
				log.warn("if you want to config distStore in spring,"
						+ " please remove diskStore in config file!", e);
			}
		}
	}
	if (config != null) {
		this.cacheManager = new CacheManager(config);
	} else {
		this.cacheManager = new CacheManager();
	}
	if (this.cacheManagerName != null) {
		this.cacheManager.setName(this.cacheManagerName);
	}
}
 
Example #12
Source File: EhcacheLoaderImpl.java    From c2mon with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Loads the object with the provided key into the cache (called for instance
 * by getWithLoader if element not found in the cache.
 *
 * <p>If this loader is in preloading mode (as indicated by the <code>preload</code>
 * field, then this method looks for the object in the preload Map. If not
 * in preload mode, it will look for the object in the database directly. If
 * it is found in either of these, it will be loaded into the cache and
 * returned. If not found in either, nothing is added to the cache and null
 * is returned.
 *
 * <p>Notice that the returned null is never returned by a direct query to a
 * {@link C2monCache}, in which case a {@link CacheElementNotFoundException} is
 * thrown.
 */
@Override
public Object load(Object key) throws CacheException {

  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("Fetching cache object with Id " + key + " from database.");
  }
  Object result = fetchFromDB(key);

  //put in cache if found something
  if (result != null) {
    cache.putQuiet(new Element(key, result));
  }

  return result;
}
 
Example #13
Source File: DomainAccessControlStoreEhCache.java    From joynr with Apache License 2.0 5 votes vote down vote up
private boolean removeAce(CacheId cacheId, Object aceKey) {
    Cache cache = getCache(cacheId);
    boolean removeResult = false;
    try {
        removeResult = cache.remove(aceKey);
    } catch (IllegalArgumentException | IllegalStateException | CacheException e) {
        logger.error("Remove {} failed.", cacheId, e);
    }

    return removeResult;
}
 
Example #14
Source File: EhcacheCache.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void notifyElementUpdated(Ehcache ehcache, Element element) throws CacheException {
    if (this.cacheEventListener != null) {
        ArrayList<CacheEntryEvent> events = makeCacheEntryEvents(EventType.UPDATED, element);
        //noinspection unchecked
        this.cacheEventListener.onUpdated(events);
    }
}
 
Example #15
Source File: EhcacheCache.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void notifyElementUpdated(Ehcache ehcache, Element element) throws CacheException {
    if (this.cacheEventListener != null) {
        ArrayList<CacheEntryEvent> events = makeCacheEntryEvents(EventType.UPDATED, element);
        //noinspection unchecked
        this.cacheEventListener.onUpdated(events);
    }
}
 
Example #16
Source File: SiteCacheImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void notifyElementRemoved(Ehcache cache, Element element)
		throws CacheException {
	if (log.isDebugEnabled()) {
		log.debug("ehcache event: notifyElementRemoved: "+element.getKey());	
	}
       notifyCacheRemove(element.getObjectKey().toString(), element.getObjectValue());
	updateSiteCacheStatistics();
}
 
Example #17
Source File: DomainAccessControlStoreEhCache.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean updateDomainRole(DomainRoleEntry updatedEntry) {
    boolean updateSuccess = false;
    Cache cache = getCache(CacheId.DOMAIN_ROLES);
    UserRoleKey dreKey = new UserRoleKey(updatedEntry.getUid(), updatedEntry.getRole());
    try {
        cache.put(new Element(dreKey, updatedEntry));
        updateSuccess = true;
    } catch (IllegalArgumentException | IllegalStateException | CacheException e) {
        logger.error("UpdateDomainRole failed.", e);
    }

    return updateSuccess;
}
 
Example #18
Source File: EhCacheManagerFactoryBean.java    From entando-components with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws IOException, CacheException {
	logger.info("Initializing EhCache CacheManager");
	InputStream is = this.extractEntandoConfig();
	try {
		// A bit convoluted for EhCache 1.x/2.0 compatibility.
		// To be much simpler once we require EhCache 2.1+
		if (this.cacheManagerName != null) {
			if (this.shared && createWithConfiguration == null) {
				// No CacheManager.create(Configuration) method available before EhCache 2.1;
				// can only set CacheManager name after creation.
				this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create());
				this.cacheManager.setName(this.cacheManagerName);
			} else {
				Configuration configuration = (is != null ? ConfigurationFactory.parseConfiguration(is) :
						ConfigurationFactory.parseConfiguration());
				configuration.setName(this.cacheManagerName);
				if (this.shared) {
					this.cacheManager = (CacheManager) ReflectionUtils.invokeMethod(createWithConfiguration, null, configuration);
				} else {
					this.cacheManager = new CacheManager(configuration);
				}
			}
		} else if (this.shared) {
			// For strict backwards compatibility: use simplest possible constructors...
			this.cacheManager = (is != null ? CacheManager.create(is) : CacheManager.create());
		} else {
			this.cacheManager = (is != null ? new CacheManager(is) : new CacheManager());
		}
	} finally {
		if (is != null) {
			is.close();
		}
	}
}
 
Example #19
Source File: EhCacheManagerFactoryBean.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws CacheException {
	if (logger.isInfoEnabled()) {
		logger.info("Initializing EhCache CacheManager" +
				(this.cacheManagerName != null ? " '" + this.cacheManagerName + "'" : ""));
	}

	Configuration configuration = (this.configLocation != null ?
			EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration());
	if (this.cacheManagerName != null) {
		configuration.setName(this.cacheManagerName);
	}

	if (this.shared) {
		// Old-school EhCache singleton sharing...
		// No way to find out whether we actually created a new CacheManager
		// or just received an existing singleton reference.
		this.cacheManager = CacheManager.create(configuration);
	}
	else if (this.acceptExisting) {
		// EhCache 2.5+: Reusing an existing CacheManager of the same name.
		// Basically the same code as in CacheManager.getInstance(String),
		// just storing whether we're dealing with an existing instance.
		synchronized (CacheManager.class) {
			this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName);
			if (this.cacheManager == null) {
				this.cacheManager = new CacheManager(configuration);
			}
			else {
				this.locallyManaged = false;
			}
		}
	}
	else {
		// Throwing an exception if a CacheManager of the same name exists already...
		this.cacheManager = new CacheManager(configuration);
	}
}
 
Example #20
Source File: EhCache.java    From document-management-software with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean contains(K key) {
	try {
		return (cache.get(key) != null);
	} catch (CacheException e) {
		throw new RuntimeException("contains failed", e);
	}
}
 
Example #21
Source File: EhCacheManagerFactoryBean.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws CacheException {
	logger.info("Initializing EhCache CacheManager");
	Configuration configuration = (this.configLocation != null ?
			EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration());
	if (this.cacheManagerName != null) {
		configuration.setName(this.cacheManagerName);
	}
	if (this.shared) {
		// Old-school EhCache singleton sharing...
		// No way to find out whether we actually created a new CacheManager
		// or just received an existing singleton reference.
		this.cacheManager = CacheManager.create(configuration);
	}
	else if (this.acceptExisting) {
		// EhCache 2.5+: Reusing an existing CacheManager of the same name.
		// Basically the same code as in CacheManager.getInstance(String),
		// just storing whether we're dealing with an existing instance.
		synchronized (CacheManager.class) {
			this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName);
			if (this.cacheManager == null) {
				this.cacheManager = new CacheManager(configuration);
			}
			else {
				this.locallyManaged = false;
			}
		}
	}
	else {
		// Throwing an exception if a CacheManager of the same name exists already...
		this.cacheManager = new CacheManager(configuration);
	}
}
 
Example #22
Source File: CacheTemplate.java    From smart-cache with Apache License 2.0 5 votes vote down vote up
/**
 * 创建本地缓存
 */
private Ehcache getEhcache(final String name) {
    Future<Ehcache> future = this.ehcaches.get(name);
    if (future == null) {
        Callable<Ehcache> callable = new Callable<Ehcache>() {
            @Override
            public Ehcache call() throws Exception {
                Ehcache cache = cacheManager.getEhcache(name);
                if (cache == null) {
                    cacheManager.addCache(name);
                    cache = cacheManager.getEhcache(name);
                }
                return cache;
            }
        };
        FutureTask<Ehcache> task = new FutureTask<>(callable);
        future = this.ehcaches.putIfAbsent(name, task);
        if (future == null) {
            future = task;
            task.run();
        }
    }
    try {
        return future.get();
    } catch (Exception e) {
        this.ehcaches.remove(name);
        throw new CacheException(e);
    }
}
 
Example #23
Source File: AllCachesController.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * @param ureq
 * @param wControl
 */
public AllCachesController(final UserRequest ureq, final WindowControl wControl) {
    super(ureq, wControl);
    // create page
    myContent = createVelocityContainer("index");

    final TableGuiConfiguration tableConfig = new TableGuiConfiguration();

    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.name", 0, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.disk", 1, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.hitcnt", 2, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcexp", 3, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcnotfound", 4, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.quickcount", 5, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.tti", 6, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.ttl", 7, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.maxElements", 8, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new StaticColumnDescriptor("empty", "cache.empty", translate("action.choose")));
    listenTo(tableCtr);
    myContent.contextPut("title", translate("caches.title"));

    // eh cache
    try {
        cm = CacheManager.getInstance();
    } catch (final CacheException e) {
        throw new AssertException("could not get cache", e);
    }
    cnames = cm.getCacheNames();
    tdm = new AllCachesTableDataModel(cnames);
    tableCtr.setTableDataModel(tdm);
    myContent.put("cachetable", tableCtr.getInitialComponent());

    // returned panel is not needed here, because this controller only shows content with the index.html velocity page
    putInitialPanel(myContent);

}
 
Example #24
Source File: AllCachesController.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * @param ureq
 * @param wControl
 */
public AllCachesController(final UserRequest ureq, final WindowControl wControl) {
    super(ureq, wControl);
    // create page
    myContent = createVelocityContainer("index");

    final TableGuiConfiguration tableConfig = new TableGuiConfiguration();

    tableCtr = new TableController(tableConfig, ureq, getWindowControl(), getTranslator());
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.name", 0, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.disk", 1, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.hitcnt", 2, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcexp", 3, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.mcnotfound", 4, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.quickcount", 5, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.tti", 6, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.ttl", 7, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("cache.maxElements", 8, null, ureq.getLocale()));
    tableCtr.addColumnDescriptor(new StaticColumnDescriptor("empty", "cache.empty", translate("action.choose")));
    listenTo(tableCtr);
    myContent.contextPut("title", translate("caches.title"));

    // eh cache
    try {
        cm = CacheManager.getInstance();
    } catch (final CacheException e) {
        throw new AssertException("could not get cache", e);
    }
    cnames = cm.getCacheNames();
    tdm = new AllCachesTableDataModel(cnames);
    tableCtr.setTableDataModel(tdm);
    myContent.put("cachetable", tableCtr.getInitialComponent());

    // returned panel is not needed here, because this controller only shows content with the index.html velocity page
    putInitialPanel(myContent);

}
 
Example #25
Source File: EhcacheCache.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/***************************************************************************************************************
 * Ehcache CacheEventListener implementation
 */

@Override
public void notifyElementRemoved(Ehcache ehcache, Element element) throws CacheException {
    if (this.cacheEventListener != null) {
        ArrayList<CacheEntryEvent> events = makeCacheEntryEvents(EventType.REMOVED, element);
        //noinspection unchecked
        this.cacheEventListener.onRemoved(events);
    }
}
 
Example #26
Source File: SiteCacheImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void notifyElementUpdated(Ehcache cache, Element element)
		throws CacheException {
	if (log.isDebugEnabled()) {
		log.debug("ehcache event: notifyElementUpdated: "+element.getKey());
	}
	updateSiteCacheStatistics();
}
 
Example #27
Source File: EhCacheManagerFactoryBean.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws CacheException {
	if (logger.isInfoEnabled()) {
		logger.info("Initializing EhCache CacheManager" +
				(this.cacheManagerName != null ? " '" + this.cacheManagerName + "'" : ""));
	}

	Configuration configuration = (this.configLocation != null ?
			EhCacheManagerUtils.parseConfiguration(this.configLocation) : ConfigurationFactory.parseConfiguration());
	if (this.cacheManagerName != null) {
		configuration.setName(this.cacheManagerName);
	}

	if (this.shared) {
		// Old-school EhCache singleton sharing...
		// No way to find out whether we actually created a new CacheManager
		// or just received an existing singleton reference.
		this.cacheManager = CacheManager.create(configuration);
	}
	else if (this.acceptExisting) {
		// EhCache 2.5+: Reusing an existing CacheManager of the same name.
		// Basically the same code as in CacheManager.getInstance(String),
		// just storing whether we're dealing with an existing instance.
		synchronized (CacheManager.class) {
			this.cacheManager = CacheManager.getCacheManager(this.cacheManagerName);
			if (this.cacheManager == null) {
				this.cacheManager = new CacheManager(configuration);
			}
			else {
				this.locallyManaged = false;
			}
		}
	}
	else {
		// Throwing an exception if a CacheManager of the same name exists already...
		this.cacheManager = new CacheManager(configuration);
	}
}
 
Example #28
Source File: SiteCacheImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void notifyElementRemoved(Ehcache cache, Element element)
		throws CacheException {
	if (log.isDebugEnabled()) {
		log.debug("ehcache event: notifyElementRemoved: "+element.getKey());	
	}
       notifyCacheRemove(element.getObjectKey().toString(), element.getObjectValue());
	updateSiteCacheStatistics();
}
 
Example #29
Source File: SiteCacheImpl.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void notifyElementPut(Ehcache cache, Element element)
		throws CacheException {
	if (log.isDebugEnabled()) {
		log.debug("ehcache event: notifyElementPut: "+element.getKey());
	}
       notifyCachePut(element.getObjectKey().toString(), element.getObjectValue());
	updateSiteCacheStatistics();
}
 
Example #30
Source File: EhcacheCache.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void notifyElementPut(Ehcache ehcache, Element element) throws CacheException {
    if (this.cacheEventListener != null) {
        ArrayList<CacheEntryEvent> events = makeCacheEntryEvents(EventType.CREATED, element);
        //noinspection unchecked
        this.cacheEventListener.onCreated(events);
    }
}