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

📄 jahialocksregistry.java

📁 java 写的一个新闻发布系统
💻 JAVA
字号:
////                                   ____.//                       __/\ ______|    |__/\.     _______//            __   .____|    |       \   |    +----+       \//    _______|  /--|    |    |    -   \  _    |    :    -   \_________//   \\______: :---|    :    :           |    :    |         \________>//           |__\---\_____________:______:    :____|____:_____\//                                      /_____|////                 . . . i n   j a h i a   w e   t r u s t . . .//package org.jahia.registries.locks;import java.util.Hashtable;import org.jahia.registries.locks.JahiaLock;import org.jahia.utils.JahiaConsole;/** *  .... add comments here .... * * @auhtor  Fulco Houkes * @version 1.0 */public class JahiaLocksRegistry{    private static JahiaLocksRegistry mObject;    /**     * @associates JahiaLock     */    private Hashtable mRegistry;    //-------------------------------------------------------------------------    /** Default constructor     */    protected JahiaLocksRegistry () {        mRegistry = new Hashtable ();        JahiaConsole.println ("JahiaLocksRegistry.constructor",                "=---= Lock registry has been instanciated =---=");    }    //-------------------------------------------------------------------------    /** Return the unique registry instance. If the instance does not exist,     *  a new instance is created.     *     * #return     *      Return the unique registry instance. Return null is the registry     *      could not be instanciated.     */    public static JahiaLocksRegistry getInstance() {        if (mObject == null) {            mObject = new JahiaLocksRegistry();        }        return mObject;    }    //-------------------------------------------------------------------------    /** Set the lock data. The lock is created if the specified lock name is not     *  used. If the lock already exits, the lock's data are updated.     *     * @param   lockName     *      The lock name. This name must be unique among the registry.     * @param   lockData     *      The additional (user-defined) lock data.     *     * @return     *      Return true if the lock could be added to the registry. False if the     *      lock name is already used.     */    public synchronized boolean setLock (String lockName, Hashtable lockData,            int timeout)    {        if (lockName == null) {            return false;        }        JahiaLock lock = (JahiaLock)mRegistry.get (lockName);        if (lock == null) {            lock = new JahiaLock (lockName, lockData, timeout);            mRegistry.put (lockName, lock);        } else {            lock.setLockData (lockData);            lock.resetTimeout();        }        return true;    }    //-------------------------------------------------------------------------    /** Get the specified lock.     *     * @param   lockName     *      The lock name.     *     * @return     *      Return the lock's data hashtable. If the lock could not befound,     *      null will be returned.     */    public synchronized Hashtable getLock (String lockName)    {        if (lockName != null) {            JahiaLock lock = (JahiaLock)mRegistry.get (lockName);            if (lock != null) {                return lock.getLockData();            }        }        return null;    }    //-------------------------------------------------------------------------    /** Remove the specified lock. Does not consider as an error if the lock     *  is not present in the registry.     *     * @param   lockName     *      The lock name.     */    public synchronized void removeLock (String lockName)    {        if (lockName != null) {            mRegistry.remove (lockName);        }    }    //-------------------------------------------------------------------------    /** check if the specified lock name is already in use.     *     * @param   lockName     *      The lock name.     *     * @return     *      Return true if the lock name is already in use, otherwise return     *      false.     */    public final boolean doesLockExist (String lockName)    {        return (getLock (lockName) != null);    }    //-------------------------------------------------------------------------    /**     *     */    public synchronized boolean isLockValid (String lockName)    {        if (lockName == null) {            return false;        }        JahiaLock lock = (JahiaLock)mRegistry.get (lockName);        return lock.isValid();    }    //-------------------------------------------------------------------------    /**     *     */    public synchronized boolean resetLockTimeout (String lockName)    {        if (lockName == null) {            return false;        }        JahiaLock lock = (JahiaLock)mRegistry.get (lockName);        lock.resetTimeout();        return true;    }}

⌨️ 快捷键说明

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