Package net.sf.ehcache

Examples of net.sf.ehcache.Element


  @Override
  public Number nextValue(NextValueRequest request) {
    final Cache<SerializableIdSourceKey> cache = datastoreProvider.getIdentifierCache();
    SerializableIdSourceKey key = new SerializableIdSourceKey( request.getKey() );

    Element previousValue = cache.get( key );
    if ( previousValue == null ) {
      previousValue = cache.putIfAbsent( new Element( key, request.getInitialValue() ) );
    }
    if ( previousValue != null ) {
      while ( !cache.replace( previousValue,
          new Element( key, ( (Integer) previousValue.getObjectValue() ) + request.getIncrement() ) ) ) {
        previousValue = cache.get( key );
      }
      return ( (Integer) previousValue.getObjectValue() ) + request.getIncrement();
    }
    else {
      return request.getInitialValue();
    }
  }
View Full Code Here


    Cache<SerializableEntityKey> entityCache = datastoreProvider.getEntityCache();
    for ( SerializableEntityKey key : entityCache.getKeys() ) {
      for ( EntityKeyMetadata entityKeyMetadata : entityKeyMetadatas ) {
        // Check if there is a way to load keys applying a filter
        if ( key.getTable().equals( entityKeyMetadata.getTable() ) ) {
          Element element = entityCache.get( key );
          consumer.consume( createTuple( element ) );
        }
      }
    }
  }
View Full Code Here

     return this.cache.isValueInCache(value);
   }
  public V get(Object key) {
    Object result = null;
    Element element = null;
    element = this.cache.get(key);
    if (element != null) {
      result = element.getValue();
    }
    return (V) result;
  }
View Full Code Here

    }
    return (V) result;
  }
  public V put(K key, V value) {
    Element element = new Element(key, value);
    this.cache.put(element);
    return null;
  }
View Full Code Here

     Collection collection = null;
     if ((m != null) && (!m.isEmpty())) {
       collection = new ArrayList();
       for (Iterator i = m.entrySet().iterator(); i.hasNext(); ) {
         Map.Entry e = (Map.Entry)i.next();
         collection.add(new Element(e.getKey(), e.getValue()));
       }
     }
     if (collection != null)
       this.cache.putAll(collection);
   }
View Full Code Here

    public String getToken(User user) {

        if (user == null) {
            return RandomStringUtils.randomAscii(10);
        }
        Element e = userTokenCache.get(user);
        if (e != null) {
            String token = (String) e.getValue();
            log.debug("Found existing token for: " + user + " token: "
                    + token);
            return token;
        } else {

            String token = RandomStringUtils.randomAscii(10);
            log.debug("No existing token for: " + user + " new token: "
                    + token);
            Element newElement = new Element(user, (Serializable) token);
            userTokenCache.put(newElement);
            return token;
        }
    }
View Full Code Here

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        String username = (String)token.getPrincipal();
        //retry count + 1
        Element element = passwordRetryCache.get(username);
        if(element == null) {
            element = new Element(username , new AtomicInteger(0));
            passwordRetryCache.put(element);
        }
        AtomicInteger retryCount = (AtomicInteger)element.getObjectValue();
        if(retryCount.incrementAndGet() > 5) {
            //if retry count > 5 throw
            throw new ExcessiveAttemptsException();
        }
View Full Code Here

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        String username = (String)token.getPrincipal();
        //retry count + 1
        Element element = passwordRetryCache.get(username);
        if(element == null) {
            element = new Element(username , new AtomicInteger(0));
            passwordRetryCache.put(element);
        }
        AtomicInteger retryCount = (AtomicInteger)element.getObjectValue();
        if(retryCount.incrementAndGet() > 5) {
            //if retry count > 5 throw
            throw new ExcessiveAttemptsException();
        }
View Full Code Here

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        String username = (String)token.getPrincipal();
        //retry count + 1
        Element element = passwordRetryCache.get(username);
        if(element == null) {
            element = new Element(username , new AtomicInteger(0));
            passwordRetryCache.put(element);
        }
        AtomicInteger retryCount = (AtomicInteger)element.getObjectValue();
        if(retryCount.incrementAndGet() > 5) {
            //if retry count > 5 throw
            throw new ExcessiveAttemptsException();
        }
View Full Code Here

   @Override
   public void put(String region, String key, Object object)
   {
      Cache cache = getCacheRegion(region);
      Element element = new Element(key, object);
      cache.put(element);
   }
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.