Examples of UtilCache


Examples of org.ofbiz.base.util.cache.UtilCache

        UtilCache<WidgetContextCacheKey, GenericWidgetOutput> screenCache = getOrCreateCache(screenName);
        return screenCache.put(wcck, output);
    }

    public GenericWidgetOutput remove(String screenName, WidgetContextCacheKey wcck) {
        UtilCache screenCache = getCache(screenName);
        if (Debug.verboseOn()) Debug.logVerbose("Removing from ScreenCache with key [" + wcck + "], will remove from this cache: " + (screenCache == null ? "[No cache found to remove from]" : screenCache.getName()), module);
        if (screenCache == null) return null;
        GenericWidgetOutput retVal = (GenericWidgetOutput) screenCache.remove(wcck);
        if (Debug.verboseOn()) Debug.logVerbose("Removing from ScreenCache with key [" + wcck + "], found this in the cache: " + retVal, module);
        return retVal;
    }
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

            number = Integer.parseInt(numString);
        } catch (Exception e) {
            return "error";
        }

        UtilCache utilCache = (UtilCache) UtilCache.utilCacheTable.get(name);

        if (utilCache != null) {
            Object key = null;

            if (utilCache.getMaxSize() > 0) {
                try {
                    key = utilCache.cacheLineTable.getKeyFromMemory(number);
                } catch (Exception e) {}
            } else {
                // no LRU, try looping through the keySet to see if we find the specified index...
                Iterator ksIter = utilCache.cacheLineTable.keySet().iterator();
                int curNum = 0;

                while (ksIter.hasNext()) {
                    if (number == curNum) {
                        key = ksIter.next();
                        break;
                    } else {
                        ksIter.next();
                    }
                    curNum++;
                }
            }

            if (key != null) {
                utilCache.remove(key);
                errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.removeElementWithKey", UtilMisc.toMap("key", key.toString()), locale) + ".";
                request.setAttribute("_EVENT_MESSAGE_", errMsg);
            } else {
                errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotRemoveElementNumber", UtilMisc.toMap("name", name, "numString", numString), locale) + ".";
                request.setAttribute("_ERROR_MESSAGE_", errMsg);
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

        if (name == null) {
            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotClearCache", locale) + ".";
            request.setAttribute("_ERROR_MESSAGE_", errMsg);
            return "error";
        }
        UtilCache utilCache = (UtilCache) UtilCache.utilCacheTable.get(name);

        if (utilCache != null) {
            utilCache.clear();
            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.clearCache", UtilMisc.toMap("name", name), locale) + ".";
            request.setAttribute("_EVENT_MESSAGE_", errMsg);
        } else {
            errMsg = UtilProperties.getMessage(UtilCacheEvents.err_resource, "utilCache.couldNotClearCacheNotFoundName", UtilMisc.toMap("name", name), locale) + ".";
            request.setAttribute("_ERROR_MESSAGE_", errMsg);
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

        } catch (Exception e) {}
        try {
            expireTime = Long.valueOf(expireTimeStr);
        } catch (Exception e) {}

        UtilCache utilCache = (UtilCache) UtilCache.utilCacheTable.get(name);

        if (utilCache != null) {
            if (maxSize != null)
                utilCache.setMaxSize(maxSize.intValue());
            if (expireTime != null)
                utilCache.setExpireTime(expireTime.longValue());
            if (useSoftReferenceStr != null) {
                utilCache.setUseSoftReference("true".equals(useSoftReferenceStr));
            }
        }
        return "success";
    }
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

    }

    protected UtilCache getOrCreateCache(String entityName) {
        synchronized (UtilCache.utilCacheTable) {
            String name = getCacheName(entityName);
            UtilCache cache = (UtilCache) UtilCache.utilCacheTable.get(name);
            if (cache == null) {
                cache = new UtilCache(name, 0, 0, true);
                String[] names = getCacheNames(entityName);
                cache.setPropertiesParams(names);
            }
            return cache;
        }
    }
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

    public EntityCache(String delegatorName) {
        super(delegatorName, "entity");
    }

    public GenericEntity get(GenericPK pk) {
        UtilCache entityCache = getCache(pk.getEntityName());
        if (entityCache == null) return null;
        return (GenericEntity) entityCache.get(pk);
    }
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

            entity = GenericEntity.NULL_ENTITY;
        } else {
            // before going into the cache, make this value immutable
            entity.setImmutable();
        }
        UtilCache entityCache = getOrCreateCache(pk.getEntityName());
        return (GenericEntity)entityCache.put(pk, entity);
    }
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

        UtilCache entityCache = getOrCreateCache(pk.getEntityName());
        return (GenericEntity)entityCache.put(pk, entity);
    }

    public void remove(String entityName, EntityCondition condition) {
        UtilCache entityCache = getCache(entityName);
        if (entityCache == null) return;
        Iterator it = entityCache.getCacheLineValues().iterator();
        while (it.hasNext()) {
            CacheLine line = (CacheLine) it.next();
            if (entityCache.hasExpired(line)) continue;
            GenericEntity entity = (GenericEntity) line.getValue();
            if (entity == null) continue;
            if (condition.entityMatches(entity)) it.remove();
        }
    }
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

    public GenericEntity remove(GenericEntity entity) {
        return remove(entity.getPrimaryKey());
    }

    public GenericEntity remove(GenericPK pk) {
        UtilCache entityCache = getCache(pk.getEntityName());
        if (Debug.verboseOn()) Debug.logVerbose("Removing from EntityCache with PK [" + pk + "], will remove from this cache: " + (entityCache == null ? "[No cache found to remove from]" : entityCache.getName()), module);
        if (entityCache == null) return null;
        GenericEntity retVal = (GenericEntity) entityCache.remove(pk);
        if (Debug.verboseOn()) Debug.logVerbose("Removing from EntityCache with PK [" + pk + "], found this in the cache: " + retVal, module);
        return retVal;
    }
View Full Code Here

Examples of org.ofbiz.base.util.cache.UtilCache

    }
   
    public static Map clearContentAssocViewCache(DispatchContext dctx, Map context) throws GenericServiceException{
        Map results = new HashMap();

        UtilCache utilCache = (UtilCache) UtilCache.utilCacheTable.get("entitycache.entity-list.default.ContentAssocViewFrom");

        if (utilCache != null) {
            utilCache.clear();
        }
       
        utilCache = (UtilCache) UtilCache.utilCacheTable.get("entitycache.entity-list.default.ContentAssocViewTo");
        if (utilCache != null) {
            utilCache.clear();
        }

        return results;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.