Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.Lock.lock()



    @Override
    public WebResourceRoot getResources() {
        Lock readLock = resourcesLock.readLock();
        readLock.lock();
        try {
            return resources;
        } finally {
            readLock.unlock();
        }
View Full Code Here


                }
            }
        }

        final Lock readLock = cacheValue.getLock().readLock();
        readLock.lock();
        try {
            factory = cacheValue.getExpressionFactory();
        } finally {
            readLock.unlock();
        }
View Full Code Here

        }

        if (factory == null) {
            final Lock writeLock = cacheValue.getLock().writeLock();
            try {
                writeLock.lock();
                factory = cacheValue.getExpressionFactory();
                if (factory == null) {
                    factory = ExpressionFactory.newInstance();
                    cacheValue.setExpressionFactory(factory);
                }
View Full Code Here

     * Locks a tag file path. Use this before loading it.
     * @param tagFilePath Tag file path
     */
    public void lockTagFileLoading(final String tagFilePath) {
        final Lock lock = getTagFileLoadingLock(tagFilePath);
        lock.lock();
    }

    /**
     * Unlocks a tag file path. Use this after loading it.
     * @param tagFilePath Tag file path
View Full Code Here

   */
  protected Lock acquireReadLock()
  {
    if (null == _readWriteLock) return null;
    Lock readLock = _readWriteLock.readLock();
    readLock.lock();
    return readLock;
  }

  /**
   * Obtains a write lock if required. If the lock is acquired in a relation with another lock,
View Full Code Here

            Dictionary loaded = ( Dictionary ) cache.get( pid );
            if ( loaded == null && !fullyLoaded )
            {
                lock.unlock();
                lock = globalLock.writeLock();
                lock.lock();
                loaded = ( Dictionary ) cache.get( pid );
                if ( loaded == null )
                {
                    loaded = pm.load(pid);
                    cache.put(pid, loaded);
View Full Code Here

     */
    public void store( String pid, Dictionary properties ) throws IOException
    {
        Lock lock = globalLock.writeLock();
        try {
            lock.lock();
            pm.store( pid, properties );
            cache.put( pid, copy( properties ) );
        } finally {
            lock.unlock();
        }
View Full Code Here

     */
    public void delete( String pid ) throws IOException
    {
        Lock lock = globalLock.writeLock();
        try {
            lock.lock();
            cache.remove( pid );
            pm.delete(pid);
        } finally {
            lock.unlock();
        }
View Full Code Here

     */
    public boolean exists( String pid )
    {
        Lock lock = globalLock.readLock();
        try {
            lock.lock();
            return cache.containsKey( pid ) || ( !fullyLoaded && pm.exists( pid ) );
        } finally {
            lock.unlock();
        }
    }
View Full Code Here

     */
    public Enumeration getDictionaries() throws IOException
    {
        Lock lock = globalLock.readLock();
        try {
            lock.lock();
            // if not fully loaded, call back to the underlying persistence
            // manager and cach all dictionaries whose service.pid is set
            if ( !fullyLoaded )
            {
                lock.unlock();
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.