Package org.fjank.jcache

Examples of org.fjank.jcache.CacheObject


     */
    public Object remove(Object key) {
      if (key==null) {
      throw new NullPointerException("This Map does not permit null keys.");
      }
        CacheObject obj = (CacheObject) acc.getRegion().get(key);
        if(obj==null) {
            return null;
        }
        obj.invalidate();
        return obj.get();
    }
View Full Code Here


        CacheRegion region = acc.getRegion();
        CacheGroup group2 = region.getGroup(group);
        if (group2 == null) {
            return null;
        }
        CacheObject object = (CacheObject) group2.get(key);
        if(object==null) {
            return null;
        }
        object.invalidate();
        return object.get();
    }
View Full Code Here

     * @return
     */
    public boolean contains(Object o) {
        //naive implementation, but it works.
        for (Iterator iter = coll.iterator(); iter.hasNext();) {
            CacheObject obj = (CacheObject) iter.next();
            if(obj.get()==o) return true;
        }
        return false;
    }
View Full Code Here

    public boolean remove(Object o) {
    if(!set.contains(o)) return false;
        if(o instanceof Map.Entry) {
          Map.Entry entry = (Entry) o;
          CacheObject obj = (CacheObject) entry.getValue();
          obj.invalidate();
          return true;
        }
    CacheObject obj = (CacheObject) group.get(o);
    if(obj==null) return false;
    obj.invalidate();
    return true;
    }
View Full Code Here

        CacheFileAdapter dataFileTemp =
            new CacheFileAdapter(new File(rafDir, fileName + "Temp.data"));
        Iterator itr = keyHash.keySet().iterator();
        while (itr.hasNext()) {
            Serializable key = (Serializable) itr.next();
            CacheObject tempDe = readElement(key);
            DiskElementDescriptor de = dataFileTemp.appendObject(tempDe);
            keyHashTemp.put(key, de);
        }
        dataFileTemp.close();
        dataFile.close();
View Full Code Here

     *
     * @throws CacheException if an error occurs.
     */
    public final void setAttributes(final Object handle,
        final Attributes attributes) throws CacheException {
        CacheObject cacheObj = convertHandle(handle);
        if (attributes == null) {
            cacheObj.setAttributes(CacheAccessFactory.getInstance().getDefaultAttributes());
        } else {
            cacheObj.setAttributes(attributes);
        }
    }
View Full Code Here

        }
        if (!(handle instanceof CacheObject)) {
            throw new InvalidArgumentException(
                "The handle was not a valid CacheObject.");
        }
        CacheObject cacheObj = ((CacheObject) handle);
        return cacheObj;
    }
View Full Code Here

     * @throws NullObjectException if an object is discovered with required
     *         variables which is null.
     */
    protected final String getRegion(final Object handle)
        throws CacheException {
        final CacheObject cacheObj = convertHandle(handle);
        final CacheRegion region = cacheObj.getRegion();
        if (region == null) {
            throw new NullObjectException("The object " + cacheObj
                + " is not attached to a region.");
        }
        final Object name = region.getName();
View Full Code Here

     * @throws InvalidArgumentException if some of the arguments are not valid
     *         in this context
     */
    public final OutputStream createStream(final Object handle)
        throws ObjectExistsException, InvalidArgumentException {
        CacheObject co = convertHandle(handle);
        try {
            StreamCacheObject str =
                new StreamCacheObject(co.getKey(), null, co.getGroup(),
                    co.getRegion(), CacheImpl.getCache(true).getReferenceQueue());
            return str.getOutputStream();
        } catch (CacheNotAvailableException e) {
            throw new InvalidArgumentException("The cache is not available.");
        } catch (CacheException e) {
            throw new InvalidArgumentException(
View Full Code Here

     *         another cache is in the progress of loading, or any other
     *         strange exceptions occurs.
     */
    public final File createDiskObject(final Object handle,
        final String extension) throws CacheException {
        CacheObject cacheObj = convertHandle(handle);
        CacheAttributes att = getCacheAttributes();
        String rootPath = att.getDiskPath();
        String ext;
        if (extension == null) {
            ext = "";
        } else {
            ext = '.' + extension;
        }
        return new File(rootPath + File.separatorChar + cacheObj.getKey() + ext);
    }
View Full Code Here

TOP

Related Classes of org.fjank.jcache.CacheObject

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.