Examples of CachedObject


Examples of net.sourceforge.processdash.net.cache.CachedObject

            int slashPos = taskListName.indexOf('/');
            if (slashPos < 7) return false;
            int objectID =
                Integer.parseInt(taskListName.substring(6, slashPos));
            CachedObject object = cache.getCachedObject(objectID, -1);
            return (object != null &&
                    CACHED_OBJECT_TYPE.equals(object.getType()));
        } catch (Exception e) { }
        return false;
    }
View Full Code Here

Examples of net.sourceforge.processdash.net.cache.CachedObject

        // fetch the specified schedule.
        if (passwordStr != null) {
            passwordStr = passwordStr.trim();
            if (passwordStr.length() == 0) passwordStr = null;
        }
        CachedObject importedSchedule =
            new CachedURLObject(dash.getCache(),
                                EVTaskListCached.CACHED_OBJECT_TYPE,
                                u,
                                passwordStr == null ? null : "EV",
                                passwordStr);


        // check to see if there was an error in fetching the schedule.
        errorMessage = importedSchedule.getErrorMessage();
        String remoteName = null;
        if (errorMessage == null) {
            // if we were able to successfully fetch the schedule, try
            // to interpret its contents as an XML schedule.
            remoteName = EVTaskListCached.getNameFromXML
                (importedSchedule.getString("UTF-8"));

            // if we weren't able to interpret the fetched schedule,
            // record an error message.
            if (remoteName == null)
                errorMessage =
                    resources.getString("Import_Schedule.Invalid_Schedule");
        }

        // if there was any error, ask the user if they want to continue.
        if (errorMessage != null) {
            errorMessage = CachedURLObject.translateMessage
                (resources, "Import_Schedule.", errorMessage);
            Object message = new Object[] {
                resources.getString("Import_Schedule.Error.Header"),
                "    " + errorMessage,
                resources.getString("Import_Schedule.Error.Footer") };
            if (JOptionPane.showConfirmDialog
                (frame, message,
                 resources.getString("Import_Schedule.Error.Title"),
                 JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE)
                != JOptionPane.YES_OPTION)
                return null;
        }

        // get a local name to use for this schedule.
        String localName = remoteName;
        String owner = (String) importedSchedule.getLocalAttr
            (CachedURLObject.OWNER_ATTR);
        if (owner != null)
            localName = resources.format
                ("Import_Schedule.Default_Name_FMT", localName, owner);

        do {
            localName = (String) JOptionPane.showInputDialog
                (frame,
                 resources.getStrings("Import_Schedule.Name_Dialog.Prompt"),
                 resources.getString("Import_Schedule.Name_Dialog.Title"),
                 JOptionPane.PLAIN_MESSAGE, null, null, localName);
            if (localName != null)
                localName = localName.replace('/', ' ').trim();
        } while (localName == null || localName.length() == 0);
        importedSchedule.setLocalAttr(EVTaskListCached.LOCAL_NAME_ATTR,
                                      localName);

        // return the name of the cached schedule object
        return EVTaskListCached.buildTaskListName(importedSchedule.getID(),
                                                  localName);
    }
View Full Code Here

Examples of org.apache.fulcrum.cache.CachedObject

     *                when either the object is not in the cache or it has
     *                expired.
     */
    public CachedObject getObject(String id) throws ObjectExpiredException
    {
        CachedObject obj = null;
        obj = (CachedObject) this.cache.get(id);
        if (obj == null)
        {
            // Not in the cache.
            throw new ObjectExpiredException();
        }
        if (obj.isStale())
        {
            if (obj instanceof RefreshableCachedObject)
            {
                RefreshableCachedObject rco = (RefreshableCachedObject) obj;
                if (rco.isUntouched())
View Full Code Here

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

     */
    public void testSimpleAddGetCacheObject() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        CachedObject cacheObject1 = null;

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

        // Create object
        cacheObject1 = new CachedObject(testString);
        assertNotNull( "Failed to create a cachable object 1", cacheObject1);

        // Add object to cache
        globalCache.addObject(cacheKey, cacheObject1);

View Full Code Here

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

     */
    public void test2ObjectAddGetCachedObject() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        CachedObject cacheObject1 = null;
        CachedObject cacheObject2 = null;

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

        // Create and add Object #1
        cacheObject1 = new CachedObject(testString);
        assertNotNull( "Failed to create a cachable object 1", cacheObject1);
        globalCache.addObject(cacheKey, cacheObject1);
        retrievedObject = globalCache.getObject(cacheKey);
        assertNotNull( "Did not retrieved a cached object 1", retrievedObject);
        assertEquals( "Did not retrieved correct cached object", cacheObject1, retrievedObject);

        // Create and add Object #2
        cacheObject2 = new CachedObject(testString);
        assertNotNull( "Failed to create a cachable object 2", cacheObject2);
        globalCache.addObject(cacheKey_2, cacheObject2);
        retrievedObject = globalCache.getObject(cacheKey_2);
        assertNotNull( "Did not retrieved a cached object 2", retrievedObject);
        assertEquals( "Did not retrieved correct cached object 2", cacheObject2, retrievedObject);
View Full Code Here

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

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

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

        // Create and add Object that expires in 1000 millis (1 second)
        cacheObject = new CachedObject(testString, 1000);
        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.CachedObject

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

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

        // Create and add Object that expires in 1 turbine Refresh + 1 millis
        cacheObject = new CachedObject(testString, (TURBINE_CACHE_REFRESH*5) + 1);
        assertNotNull( "Failed to create a cachable object", cacheObject);
        long addTime = System.currentTimeMillis();
        globalCache.addObject(cacheKey, cacheObject);

        // 1 Refresh
View Full Code Here

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

        .getService( GlobalCacheService.SERVICE_NAME );
        assertNotNull("Could not retrive cache service.", globalCache);

        // Create and add Object that expires in 1.5 turbine Refresh
        long expireTime = TURBINE_CACHE_REFRESH + TURBINE_CACHE_REFRESH/2;
        CachedObject cacheObject = new CachedObject("This is a test", expireTime);
        assertNotNull( "Failed to create a cachable object", cacheObject);

        globalCache.addObject(cacheKey, cacheObject);
        assertEquals("After adding 1 Object", 1, globalCache.getNumberOfObjects());
View Full Code Here

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

     */
    public void testSimpleAddGetCacheObject() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        CachedObject cacheObject1 = null;

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

        // Create object
        cacheObject1 = new CachedObject(testString);
        assertNotNull( "Failed to create a cachable object 1", cacheObject1);

        // Add object to cache
        globalCache.addObject(cacheKey, cacheObject1);

View Full Code Here

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

     */
    public void test2ObjectAddGetCachedObject() throws Exception
    {
        String testString = new String( "This is a test");
        Object retrievedObject = null;
        CachedObject cacheObject1 = null;
        CachedObject cacheObject2 = null;

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

        // Create and add Object #1
        cacheObject1 = new CachedObject(testString);
        assertNotNull( "Failed to create a cachable object 1", cacheObject1);
        globalCache.addObject(cacheKey, cacheObject1);
        retrievedObject = globalCache.getObject(cacheKey);
        assertNotNull( "Did not retrieved a cached object 1", retrievedObject);
        assertEquals( "Did not retrieved correct cached object", cacheObject1, retrievedObject);

        // Create and add Object #2
        cacheObject2 = new CachedObject(testString);
        assertNotNull( "Failed to create a cachable object 2", cacheObject2);
        globalCache.addObject(cacheKey_2, cacheObject2);
        retrievedObject = globalCache.getObject(cacheKey_2);
        assertNotNull( "Did not retrieved a cached object 2", retrievedObject);
        assertEquals( "Did not retrieved correct cached object 2", cacheObject2, retrievedObject);
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.