Search in sources :

Example 21 with Element

use of net.sf.ehcache.Element in project spring-security by spring-projects.

the class EhCacheBasedAclCache method getFromCache.

public MutableAcl getFromCache(ObjectIdentity objectIdentity) {
    Assert.notNull(objectIdentity, "ObjectIdentity required");
    Element element = null;
    try {
        element = cache.get(objectIdentity);
    } catch (CacheException ignored) {
    }
    if (element == null) {
        return null;
    }
    return initializeTransientFields((MutableAcl) element.getValue());
}
Also used : CacheException(net.sf.ehcache.CacheException) Element(net.sf.ehcache.Element)

Example 22 with Element

use of net.sf.ehcache.Element in project spring-security by spring-projects.

the class EhCacheBasedAclCache method putInCache.

public void putInCache(MutableAcl acl) {
    Assert.notNull(acl, "Acl required");
    Assert.notNull(acl.getObjectIdentity(), "ObjectIdentity required");
    Assert.notNull(acl.getId(), "ID required");
    if (this.aclAuthorizationStrategy == null) {
        if (acl instanceof AclImpl) {
            this.aclAuthorizationStrategy = (AclAuthorizationStrategy) FieldUtils.getProtectedFieldValue("aclAuthorizationStrategy", acl);
            this.permissionGrantingStrategy = (PermissionGrantingStrategy) FieldUtils.getProtectedFieldValue("permissionGrantingStrategy", acl);
        }
    }
    if ((acl.getParentAcl() != null) && (acl.getParentAcl() instanceof MutableAcl)) {
        putInCache((MutableAcl) acl.getParentAcl());
    }
    cache.put(new Element(acl.getObjectIdentity(), acl));
    cache.put(new Element(acl.getId(), acl));
}
Also used : Element(net.sf.ehcache.Element) MutableAcl(org.springframework.security.acls.model.MutableAcl)

Example 23 with Element

use of net.sf.ehcache.Element in project spring-security by spring-projects.

the class EhCacheBasedTicketCache method putTicketInCache.

public void putTicketInCache(final CasAuthenticationToken token) {
    final Element element = new Element(token.getCredentials().toString(), token);
    if (logger.isDebugEnabled()) {
        logger.debug("Cache put: " + element.getKey());
    }
    cache.put(element);
}
Also used : Element(net.sf.ehcache.Element)

Example 24 with Element

use of net.sf.ehcache.Element in project caffeine by ben-manes.

the class Ehcache2Policy method record.

@Override
public void record(long key) {
    Object value = cache.get(key);
    if (value == null) {
        policyStats.recordMiss();
        if (cache.getSize() == maximumSize) {
            policyStats.recordEviction();
        }
        cache.put(new Element(key, key));
    } else {
        policyStats.recordHit();
    }
}
Also used : Element(net.sf.ehcache.Element)

Example 25 with Element

use of net.sf.ehcache.Element in project gocd by gocd.

the class GoCache method put.

private void put(String key, Object value, Predicate predicate) {
    logUnsavedPersistentObjectInteraction(value, "PersistentObject %s added to cache without an id.");
    if (predicate.isTrue()) {
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(String.format("transaction active during cache put for %s = %s", key, value), new IllegalStateException());
        }
        return;
    }
    ehCache.put(new Element(key, value));
}
Also used : Element(net.sf.ehcache.Element)

Aggregations

Element (net.sf.ehcache.Element)114 Test (org.junit.Test)21 CacheKey (org.apereo.portal.utils.cache.CacheKey)8 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 Cache (net.sf.ehcache.Cache)7 HashSet (java.util.HashSet)6 CacheException (net.sf.ehcache.CacheException)6 MalformedURLException (java.net.MalformedURLException)5 ConfigurationException (javax.naming.ConfigurationException)5 Ehcache (net.sf.ehcache.Ehcache)5 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)5 EntityIdentifier (org.apereo.portal.EntityIdentifier)5 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 URISyntaxException (java.net.URISyntaxException)4 SQLException (java.sql.SQLException)4 EntityExistsException (javax.persistence.EntityExistsException)4 RouteBuilder (org.apache.camel.builder.RouteBuilder)4 BaseCacheTest (org.apache.camel.component.BaseCacheTest)4