Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantReadWriteLock


            if (beanContext.isBeanManagedConcurrency()){
                // Bean-Managed Concurrency
                lock = new BeanManagedLock();
            } else {
                // Container-Managed Concurrency
                lock = new ReentrantReadWriteLock();
            }

            return new Instance(context.getBean(), context.getInterceptors(), context.getCreationalContext(), lock);
        } catch (Throwable e) {
            if (e instanceof java.lang.reflect.InvocationTargetException) {
View Full Code Here


          .log(POILogger.WARN, "The close() method is intended to SAVE a package. This package is open in READ ONLY mode, use the revert() method instead !");
      return;
    }

    // Save the content
    ReentrantReadWriteLock l = new ReentrantReadWriteLock();
    try {
      l.writeLock().lock();
      if (this.originalPackagePath != null
          && !"".equals(this.originalPackagePath.trim())) {
        File targetFile = new File(this.originalPackagePath);
        if (!targetFile.exists()
            || !(this.originalPackagePath
                .equalsIgnoreCase(targetFile.getAbsolutePath()))) {
          // Case of a package created from scratch
          save(targetFile);
        } else {
          closeImpl();
        }
      } else if (this.output != null) {
        save(this.output);
      }
    } finally {
      l.writeLock().unlock();
    }

    // Clear
    this.contentTypeManager.clearAll();
View Full Code Here

    public ProvidersRegistry(LifecycleManagersRegistry factoryRegistry,
                             ApplicationValidator applicationValidator) {
        this.factoryFactoryRegistry = factoryRegistry;
        this.applicationValidator = applicationValidator;
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        readersLock = readWriteLock.readLock();
        writersLock = readWriteLock.writeLock();
    }
View Full Code Here

                            ApplicationValidator applicationValidator) {
        this.applicationValidator = applicationValidator;
        rootResources = new LinkedList<ResourceRecord>();
        dirty = false;
        resourceRecordsFactory = new ResourceRecordFactory(factoryRegistry);
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        readersLock = readWriteLock.readLock();
        writersLock = readWriteLock.writeLock();
    }
View Full Code Here

                if (deploymentInfo.isBeanManagedConcurrency()){
                    // Bean-Managed Concurrency
                    lock = new BeanManagedLock();
                } else {
                    // Container-Managed Concurrency
                    lock = new ReentrantReadWriteLock();
                }

                data.instance = new Instance(bean, interceptorInstances, lock);
            } catch (Throwable e) {
                if (e instanceof java.lang.reflect.InvocationTargetException) {
View Full Code Here

    public ResourceRegistry(LifecycleManagersRegistry factoryRegistry,
                            ApplicationValidator applicationValidator) {
        this.applicationValidator = applicationValidator;
        rootResources = new LinkedList<ResourceRecord>();
        resourceRecordsFactory = new ResourceRecordFactory(factoryRegistry);
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        readersLock = readWriteLock.readLock();
        writersLock = readWriteLock.writeLock();
        uriToResourceCache.put(Boolean.TRUE,
                               new SoftConcurrentMap<String, ArrayList<ResourceRecord>>());
        uriToResourceCache.put(Boolean.FALSE,
                               new SoftConcurrentMap<String, ArrayList<ResourceRecord>>());
    }
View Full Code Here

        if (lifecycleManagerRegistry == null) {
            throw new NullPointerException("lifecycleManagerRegistry");
        }
        this.lifecycleManagerRegistry = lifecycleManagerRegistry;
        this.cacheByClass = new HashMap<Class<?>, ResourceRecord>();
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        readersLock = readWriteLock.readLock();
        writersLock = readWriteLock.writeLock();
    }
View Full Code Here

        else
        {
            if ( rwLock == null )
            {
                // Create a ReadWrite lock from scratch
                rwLock = new ReentrantReadWriteLock();
            }
        }
    }
View Full Code Here

      lockSegmentMask = numLocks - 1;

      sharedLocks = new ReentrantReadWriteLock[numLocks];

      for (int i = 0; i < numLocks; i++) {
        sharedLocks[i] = new ReentrantReadWriteLock();
    }
   }
View Full Code Here

    * Blocks until a lock is acquired.
    *
    * @param exclusive if true, a write (exclusive) lock is attempted, otherwise a read (shared) lock is used.
    */
   public void acquireLock(Object key, boolean exclusive) {
      ReentrantReadWriteLock lock = getLock(key);
      if (exclusive) {
         lock.writeLock().lock();
         if (trace) log.tracef("WL acquired for '%s'", key);
      } else {
         lock.readLock().lock();
         if (trace) log.tracef("RL acquired for '%s'", key);
      }
   }
View Full Code Here

TOP

Related Classes of java.util.concurrent.locks.ReentrantReadWriteLock

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.