Code example for ReentrantReadWriteLock

Methods: readLock, writeLock

0
 
	public static final String DEBUG_OPTION = BeansCorePlugin.PLUGIN_ID + "/model/metadata/debug";
 
	public static final boolean DEBUG = SpringCore.isDebug(DEBUG_OPTION);
 
	private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
 
	private final Lock r = rwl.readLock();
 
	private final Lock w = rwl.writeLock();
 
	private Map<String, BeanMetadataHolder> beanMetadata = new ConcurrentHashMap<String, BeanMetadataHolder>();
 
	private Map<String, BeanPropertyDataHolder> beanPropertyData = new ConcurrentHashMap<String, BeanPropertyDataHolder>();
 
	public Set<IBeanMetadata> getBeanMetadata(IBean bean) {
		try { 
			r.lock();
			if (beanMetadata.containsKey(bean.getElementID())) {
				return beanMetadata.get(bean.getElementID()).getBeanMetaData();
			}