⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cachehelper.java

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        try {            setInvocationOption(cache, option);            cache.put(new Fqn(region, key), ITEM, value);        }        catch (TimeoutException allowed) {            // ignore it        }        catch (Exception e) {            throw new CacheException(e);        }    }    /**     * Builds an {@link Fqn} from <code>region</code> and <code>key</code>     * and performs a JBoss Cache     * <code>putForExternalRead(Object, Object)</code>, wrapping any     * exception in a {@link CacheException}. Ignores any JBoss Cache     * {@link TimeoutException}.     *      * @param cache     *            the cache to invoke on     * @param region     *            base Fqn for the cache region     * @param key     *            specific key to append to the <code>region</code> to form     *            the full Fqn     * @param value     *            data to store in the cache node     */    public static boolean putForExternalRead(Cache cache, Fqn region, Object key, Object value) throws CacheException {        return putForExternalRead(cache, region, key, value, null);    }    /**     * Builds an {@link Fqn} from <code>region</code> and <code>key</code>     * and performs a JBoss Cache     * <code>putForExternalRead(Object, Object)</code>, wrapping any     * exception in a {@link CacheException}. Ignores any JBoss Cache     * {@link TimeoutException}.     *      * @param cache     *            the cache to invoke on     * @param region     *            base Fqn for the cache region     * @param key     *            specific key to append to the <code>region</code> to form     *            the full Fqn     * @param value     *            data to store in the cache node     * @param option     *            invocation Option to set for this invocation. May be     *            <code>null</code>.     */    public static boolean putForExternalRead(Cache cache, Fqn region, Object key, Object value, Option option)            throws CacheException {        try {            setInvocationOption(cache, option);            cache.putForExternalRead(new Fqn(region, key), ITEM, value);            return true;        } catch (TimeoutException te) {            // ignore!            log.debug("ignoring write lock acquisition failure");            return false;        } catch (Throwable t) {            throw new CacheException(t);        }    }    /**     * Builds an {@link Fqn} from <code>region</code> and <code>key</code>     * and performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any     * exception in a {@link CacheException}.     *      * @param cache     *            the cache to invoke on     * @param region     *            base Fqn for the cache region     * @param key     *            specific key to append to the <code>region</code> to form     *            the full Fqn     */    public static void remove(Cache cache, Fqn region, Object key) throws CacheException {        remove(cache, region, key, null);    }    /**     * Builds an {@link Fqn} from <code>region</code> and <code>key</code>     * and performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any     * exception in a {@link CacheException}.     *      * @param cache     *            the cache to invoke on     * @param region     *            base Fqn for the cache region     * @param key     *            specific key to append to the <code>region</code> to form     *            the full Fqn     * @param option     *            invocation Option to set for this invocation. May be     *            <code>null</code>.     */    public static void remove(Cache cache, Fqn region, Object key, Option option) throws CacheException {        try {            setInvocationOption(cache, option);            cache.removeNode(new Fqn(region, key));        } catch (Exception e) {            throw new CacheException(e);        }    }    /**     * Performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any     * exception in a {@link CacheException}.     *      * @param cache     *            the cache to invoke on     * @param region     *            base Fqn for the cache region     */    public static void removeAll(Cache cache, Fqn region) throws CacheException {        removeAll(cache, region, null);    }    /**     * Performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any     * exception in a {@link CacheException}.     *      * @param cache     *            the cache to invoke on     * @param region     *            base Fqn for the cache region     * @param option     *            invocation Option to set for this invocation. May be     *            <code>null</code>.     */    public static void removeAll(Cache cache, Fqn region, Option option) throws CacheException {        try {            setInvocationOption(cache, option);            cache.removeNode(region);        } catch (Exception e) {            throw new CacheException(e);        }    }    /**     * Performs a JBoss Cache <code>removeNode(Fqn)</code>, wrapping any     * exception in a {@link CacheException}.     *      * @param cache     *            the cache to invoke on     * @param region     *            base Fqn for the cache region     * @param option     *            invocation Option to set for this invocation. May be     *            <code>null</code>.     */    public static void removeNode(Cache cache, Fqn region, Object key, Option option) throws CacheException {        try {            setInvocationOption(cache, option);            cache.removeNode(new Fqn(region, key));        } catch (Exception e) {            throw new CacheException(e);        }    }        public static Node addNode(Cache cache, Fqn fqn, boolean localOnly, boolean resident, DataVersion version)            throws CacheException {        try {            Option option = null;            if (localOnly || version != null) {                option = new Option();                option.setCacheModeLocal(localOnly);                option.setDataVersion(version);            }                        Node root = cache.getRoot();            setInvocationOption(cache, option);            // FIXME hack to work around fact that calling            // Node added = root.addChild( fqn ); doesn't             // properly set the version on the node            Node added = null;            if (version == null) {                added = root.addChild( fqn );            }            else {                cache.put(fqn, DUMMY, DUMMY);                added = root.getChild(fqn);            }            if (resident)                added.setResident(true);            return added;        }        catch (Exception e) {            throw new CacheException(e);        }    }        /**     * Assigns the given Option to the cache's {@link InvocationContext}. Does     * nothing if <code>option</code> is <code>null</code>.     *      * @param cache     *            the cache. Cannot be <code>null</code>.     * @param option     *            the option. May be <code>null</code>.     *      * @see {@link Cache#getInvocationContext()}     * @see {@link InvocationContext#setOptionOverrides(Option)}     */    public static void setInvocationOption(Cache cache, Option option) {        if (option != null) {            cache.getInvocationContext().setOptionOverrides(option);        }    }    /**     * Creates an {@link Option} using the given {@link DataVersion} and passes     * it to {@link #setInvocationOption(Cache, Option)}.     *      * @param cache     *            the cache to set the Option on. Cannot be <code>null</code>.     * @param version     *            the DataVersion to set. Cannot be <code>null</code>.     */    public static void setDataVersionOption(Cache cache, DataVersion version) {        Option option = new Option();        option.setDataVersion(version);        setInvocationOption(cache, option);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -