Package net.sf.ehcache

Examples of net.sf.ehcache.Element


   */
  public static Serializable getObjectCached(String cache_name, Serializable key){
    Cache cache = getCache(cache_name);
    if(cache!=null){
      try {
        Element elem = cache.get(key);
        if(elem!=null && !cache.isExpired(elem))
          return elem.getValue();
      } catch (Exception e) {
        log.error("Get cache("+cache_name+") of "+key+" failed.", e);
      }
    }
    return null;
View Full Code Here


  public synchronized static void putObjectCached(String cache_name, Serializable key, Serializable value){
    Cache cache = getCache(cache_name);
    if(cache!=null){
      try {
        cache.remove(key);
        Element elem = new Element(key, value);
        cache.put(elem);
      } catch (Exception e) {
        log.error("put cache("+cache_name+") of "+key+" failed.", e);
      }
    }
View Full Code Here

   */
  public static Channel fetchChannel(int type, String url){
    //get from the cache
    if(channels!=null){
      try {
        Element channel = channels.get(url);
        if(channel!=null)
          return (Channel)channel.getValue();
      } catch (IllegalStateException e) {
        //occur when this element is expire
      } catch (CacheException e) {
        log.error("Exception occurred when get from cache "+url, e);
      }
    }
    //fetch from http directly
   
    try {
      Channel channel = fetchChannelViaHTTP(url);
      if(channels!=null && channel!=null){
        channels.put(new Element(url, channel));
      }
      return channel;
    } catch (Exception e) {
      log.error("Exception occurred when fetch "+url, e);
    }
View Full Code Here

  /* (non-Javadoc)
   * @see com.hp.hpl.jena.gvs.impl.filesystem.GraphCache#get(java.io.File)
   */
  public Graph get(File modelFile) {
    Element cacheElement = cache.get(modelFile);
    if (cacheElement != null) {
      return (Graph) cacheElement.getObjectValue();
    } else {
      return null;
    }
  }
View Full Code Here

  /* (non-Javadoc)
   * @see com.hp.hpl.jena.gvs.impl.filesystem.GraphCache#put(java.io.File, org.wymiwyg.rdf.graphs.Graph)
   */
  public void put(File modelFile, Graph graph) {
    cache.put(new Element(modelFile, graph));
  }
View Full Code Here

    {

        Serializable k = ser(userKey);
        Serializable v = ser(cacheObject);

        cache.put(new Element(k, v));
    }
View Full Code Here


    public final Object getObject(Object key)
    {

        Element element = null;

        try
        {
            element = cache.get((Serializable) key);
        }
        catch (Exception e)
        {
            LOG.error("getObject", e);
        }

        return (element == null)
               ? null
               : element.getValue();
    }
View Full Code Here

    return maximumRows;
  }

  public TableModel get(final DataCacheKey key)
  {
    final Element element = cache.get(key);
    if (element == null)
    {
      return null;
    }
    return (TableModel) element.getObjectValue();
  }
View Full Code Here

    {
      return model;
    }

    final TableModel cacheModel = new CachableTableModel(model);
    cache.put(new Element(key, cacheModel));
    return cacheModel;
  }
View Full Code Here

  public void afterPropertiesSet() throws Exception {
    Validate.notNull(cache, "cache mandatory");
  }

  public CasAuthentication get(String serviceTicket) {
    Element element = null;
    try {
      element = cache.get(serviceTicket);
    } catch (CacheException cacheException) {
      throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage());
    }

    if (logger.isDebugEnabled()) {
      logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket);
    }

    if (element == null) {
      return null;
    } else {
      return (CasAuthentication) element.getValue();
    }
  }
View Full Code Here

TOP

Related Classes of net.sf.ehcache.Element

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.