Package org.apache.turbine.services.cache

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


     * @throws Exception
     */   
    public void testRefreshableObject() throws Exception {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;
        long addTime = 0;
       
        boolean turbineCachePatchApplied = false; // FIXME:  Remove when patch applied
       
        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);
        globalCache.addObject(cacheKey, cacheObject);
        addTime = System.currentTimeMillis();
       
        // Try to get un-expired object
View Full Code Here


     * @throws Exception
     */   
    public void testRefreshableTimeToLive() throws Exception {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;
        long addTime = 0;
       
        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
        globalCache.addObject(cacheKey, cacheObject);
        addTime = System.currentTimeMillis();
       
View Full Code Here

                if (System.currentTimeMillis() < expirationMillis.longValue()) {
                    cachedObject.setExpires(expirationMillis.longValue() - cachedObject.getCreated());
                }
            }
            if (item instanceof Refreshable) {
                RefreshableCachedObject rco = new RefreshableCachedObject( (Refreshable) item);
                if (item instanceof AbstractPortlet) {
                    AbstractPortlet portlet = (AbstractPortlet)item;
                    String tempString =  portlet.getPortletConfig().getInitParameter(JetspeedResources.TIME_TO_LIVE);
                    if (tempString != null) {
                        rco.setTTL(Integer.parseInt(tempString));
                        if (logger.isWarnEnabled())
                        {
                            logger.warn("PortletCache: portlet "
                                     + item.getHandle()
                                     + " overrides default time to live with "
                                     + tempString);
                        }
                    } else {
                        rco.setTTL(DefaultTimeToLiveMillis);
                    }
                } else {
                    rco.setTTL(DefaultTimeToLiveMillis);
                }
                cachedObject = rco;
               
            } else {
                cachedObject = new CachedObject(item);
View Full Code Here

     * @throws Exception
     */   
    public void testRefreshableObject() throws Exception {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;
        long addTime = 0;
       
        boolean turbineCachePatchApplied = false; // FIXME:  Remove when patch applied
       
        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);
        globalCache.addObject(cacheKey, cacheObject);
        addTime = System.currentTimeMillis();
       
        // Try to get un-expired object
View Full Code Here

     * @throws Exception
     */   
    public void testRefreshableTimeToLive() throws Exception {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;
        long addTime = 0;
       
        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
        globalCache.addObject(cacheKey, cacheObject);
        addTime = System.currentTimeMillis();
       
View Full Code Here

                if (System.currentTimeMillis() < expirationMillis.longValue()) {
                    cachedObject.setExpires(expirationMillis.longValue() - cachedObject.getCreated());
                }
            }
            if (item instanceof Refreshable) {
                RefreshableCachedObject rco = new RefreshableCachedObject( (Refreshable) item);
                if (item instanceof AbstractPortlet) {
                    AbstractPortlet portlet = (AbstractPortlet)item;
                    String tempString =  portlet.getPortletConfig().getInitParameter(JetspeedResources.TIME_TO_LIVE);
                    if (tempString != null) {
                        rco.setTTL(Integer.parseInt(tempString));
                        if (logger.isWarnEnabled())
                        {
                            logger.warn("PortletCache: portlet "
                                     + item.getHandle()
                                     + " overrides default time to live with "
                                     + tempString);
                        }
                    } else {
                        rco.setTTL(DefaultTimeToLiveMillis);
                    }
                } else {
                    rco.setTTL(DefaultTimeToLiveMillis);
                }
                cachedObject = rco;
               
            } else {
                cachedObject = new CachedObject(item);
View Full Code Here

     * @throws Exception
     */   
    public void testRefreshableObject() throws Exception {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;
        long addTime = 0;
       
        boolean turbineCachePatchApplied = false; // FIXME:  Remove when patch applied
       
        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);
        globalCache.addObject(cacheKey, cacheObject);
        addTime = System.currentTimeMillis();
       
        // Try to get un-expired object
View Full Code Here

     * @throws Exception
     */   
    public void testRefreshableTimeToLive() throws Exception {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        RefreshableCachedObject cacheObject = null;
        long addTime = 0;
       
        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
        globalCache.addObject(cacheKey, cacheObject);
        addTime = System.currentTimeMillis();
       
View Full Code Here

                if (System.currentTimeMillis() < expirationMillis.longValue()) {
                    cachedObject.setExpires(expirationMillis.longValue() - cachedObject.getCreated());
                }
            }
            if (item instanceof Refreshable) {
                RefreshableCachedObject rco = new RefreshableCachedObject( (Refreshable) item);
                if (item instanceof AbstractPortlet) {
                    AbstractPortlet portlet = (AbstractPortlet)item;
                    String tempString =  portlet.getPortletConfig().getInitParameter("_TimeToLive");
                    if (tempString != null) {
                        rco.setTTL(Integer.parseInt(tempString));
                    } else {
                        rco.setTTL(DefaultTimeToLiveMillis);
                    }
                } else {
                    rco.setTTL(DefaultTimeToLiveMillis);
                }
                cachedObject = rco;
               
            } else {
                cachedObject = new CachedObject(item);
View Full Code Here

     */
    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

TOP

Related Classes of org.apache.turbine.services.cache.RefreshableCachedObject

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.