Examples of RefreshableCachedObject


Examples of org.apache.fulcrum.cache.RefreshableCachedObject

        }
        if (obj.isStale())
        {
            if (obj instanceof RefreshableCachedObject)
            {
                RefreshableCachedObject rco = (RefreshableCachedObject) obj;
                if (rco.isUntouched())
                {
                    throw new ObjectExpiredException();
                }
                // Refresh Object
                rco.refresh();
                if (rco.isStale())
                {
                    throw new ObjectExpiredException();
                }
            }
            else
            {
                // Expired.
                throw new ObjectExpiredException();
            }
        }
        if (obj instanceof RefreshableCachedObject)
        {
            // notify it that it's being accessed.
            RefreshableCachedObject rco = (RefreshableCachedObject) obj;
            rco.touch();
        }
        return obj;
    }
View Full Code Here

Examples of org.apache.fulcrum.cache.RefreshableCachedObject

            {
                String key = (String) e.nextElement();
                CachedObject co = (CachedObject) this.cache.get(key);
                if (co instanceof RefreshableCachedObject)
                {
                    RefreshableCachedObject rco = (RefreshableCachedObject) co;
                    if (rco.isUntouched())
                    {
                        this.cache.remove(key);
                    }
                    else if (rco.isStale())
                    {
                        // to prolong holding the lock on this object
                        refreshThese.add(key);
                    }
                }
                else if (co.isStale())
                {
                    this.cache.remove(key);
                }
            }
        }
        for (Iterator i = refreshThese.iterator(); i.hasNext();)
        {
            String key = (String) i.next();
            CachedObject co = (CachedObject) this.cache.get(key);
            RefreshableCachedObject rco = (RefreshableCachedObject) co;
            rco.refresh();
        }
    }
View Full Code Here

Examples of org.apache.fulcrum.cache.RefreshableCachedObject

       
        if (obj.isStale())
        {
            if (obj instanceof RefreshableCachedObject)
            {
                RefreshableCachedObject rco = (RefreshableCachedObject) obj;
                if (rco.isUntouched())
                {
                    // Do not refresh an object that has exceeded TimeToLive
                    removeObject(id);
                    throw new ObjectExpiredException();
                }

                // Refresh Object
                rco.refresh();
                if (rco.isStale())
                {
                    // Object is Expired, remove it from cache.
                    removeObject(id);
                    throw new ObjectExpiredException();
                }
            }
            else
            {
                // Expired.
                removeObject(id);
                throw new ObjectExpiredException();
            }
        }

        if (obj instanceof RefreshableCachedObject)
        {
            // notify it that it's being accessed.
            RefreshableCachedObject rco = (RefreshableCachedObject) obj;
            rco.touch();
        }

        return obj;
    }
View Full Code Here

Examples of org.apache.fulcrum.cache.RefreshableCachedObject

               
                Object o = cachedElement.getObjectValue();
               
                if (o instanceof RefreshableCachedObject)
                {
                    RefreshableCachedObject rco = (RefreshableCachedObject) o;
                    if (rco.isUntouched())
                    {
                        this.cache.remove(key);
                    }
                    else if (rco.isStale())
                    {
                        rco.refresh();
                    }
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.fulcrum.cache.RefreshableCachedObject

        if (obj.isStale())
        {
            if (obj instanceof RefreshableCachedObject)
            {
                RefreshableCachedObject rco = (RefreshableCachedObject) obj;
                if (rco.isUntouched())
                {
                    // Do not refresh an object that has exceeded TimeToLive
                    removeObject(id);
                    throw new ObjectExpiredException();
                }

                // Refresh Object
                rco.refresh();
                if (rco.isStale())
                {
                    // Object is Expired, remove it from cache.
                    removeObject(id);
                    throw new ObjectExpiredException();
                }
            }
            else
            {
                // Expired.
                removeObject(id);
                throw new ObjectExpiredException();
            }
        }

        if (obj instanceof RefreshableCachedObject)
        {
            // notify it that it's being accessed.
            RefreshableCachedObject rco = (RefreshableCachedObject) obj;
            rco.touch();
        }

        return obj;
    }
View Full Code Here

Examples of org.apache.fulcrum.cache.RefreshableCachedObject

                }
                else
                {
                    if (o instanceof RefreshableCachedObject)
                    {
                        RefreshableCachedObject rco = (RefreshableCachedObject) o;
                        if (rco.isUntouched())
                        {
                            this.cacheManager.remove(key, group);
                        }
                        else if (rco.isStale())
                        {
                            rco.refresh();
                        }
                    }
                }
            }
        }
View Full Code Here

Examples of org.apache.turbine.services.cache.RefreshableCachedObject

     */
    public void testRefreshableObject() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;

        GlobalCacheService globalCache = (GlobalCacheService)TurbineServices
        .getInstance()
        .getService( GlobalCacheService.SERVICE_NAME );

        // Create and add Object that expires in TEST_EXPIRETIME millis.
        cacheObject = new RefreshableCachedObject(new RefreshableObject(), TEST_EXPIRETIME);
        assertNotNull( "Failed to create a cachable object", cacheObject);
        long addTime = System.currentTimeMillis();
        globalCache.addObject(cacheKey, cacheObject);

        // Try to get un-expired object
View Full Code Here

Examples of org.apache.turbine.services.cache.RefreshableCachedObject

     */
    public void testRefreshableTimeToLive() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;

        GlobalCacheService globalCache = (GlobalCacheService)TurbineServices
        .getInstance()
        .getService( GlobalCacheService.SERVICE_NAME );

        // Create and add Object that expires in TEST_EXPIRETIME millis.
        cacheObject = new RefreshableCachedObject(new RefreshableObject(), TEST_EXPIRETIME);
        assertNotNull( "Failed to create a cachable object", cacheObject);
        cacheObject.setTTL(TEST_TIMETOLIVE);

        // Verify TimeToLive was set
        assertEquals( "Returned TimeToLive", TEST_TIMETOLIVE, cacheObject.getTTL());

        // Add object to Cache
        long addTime = System.currentTimeMillis();
        globalCache.addObject(cacheKey, cacheObject);

View Full Code Here

Examples of org.apache.turbine.services.cache.RefreshableCachedObject

     */
    public void testRefreshableObject() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;

        GlobalCacheService globalCache = (GlobalCacheService)TurbineServices
        .getInstance()
        .getService( GlobalCacheService.SERVICE_NAME );

        // Create and add Object that expires in TEST_EXPIRETIME millis.
        cacheObject = new RefreshableCachedObject(new RefreshableObject(), TEST_EXPIRETIME);
        assertNotNull( "Failed to create a cachable object", cacheObject);
        long addTime = System.currentTimeMillis();
        globalCache.addObject(cacheKey, cacheObject);

        // Try to get un-expired object
View Full Code Here

Examples of org.apache.turbine.services.cache.RefreshableCachedObject

     */
    public void testRefreshableTimeToLive() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;

        GlobalCacheService globalCache = (GlobalCacheService)TurbineServices
        .getInstance()
        .getService( GlobalCacheService.SERVICE_NAME );

        // Create and add Object that expires in TEST_EXPIRETIME millis.
        cacheObject = new RefreshableCachedObject(new RefreshableObject(), TEST_EXPIRETIME);
        assertNotNull( "Failed to create a cachable object", cacheObject);
        cacheObject.setTTL(TEST_TIMETOLIVE);

        // Verify TimeToLive was set
        assertEquals( "Returned TimeToLive", TEST_TIMETOLIVE, cacheObject.getTTL());

        // Add object to Cache
        long addTime = System.currentTimeMillis();
        globalCache.addObject(cacheKey, cacheObject);

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.