Package org.apache.jackrabbit.core.state.ISMLocking

Examples of org.apache.jackrabbit.core.state.ISMLocking.ReadLock


    /**
     * {@inheritDoc}
     */
    public boolean hasItem(NodeId id) {
        ReadLock lock = acquireReadLock();
        try {
            return stateMgr.hasItemState(id);
        } finally {
            lock.release();
        }
    }
View Full Code Here


            throws RepositoryException {

        if (id.equals(getHistoryRootId())) {
            return null;
        }
        ReadLock lock = acquireReadLock();
        try {
            synchronized (versionItems) {
                InternalVersionItem item = versionItems.get(id);
                if (item == null) {
                    item = createInternalVersionItem(id);
                    if (item != null) {
                        versionItems.put(id, item);
                    } else {
                        return null;
                    }
                }
                return item;
            }
        } finally {
            lock.release();
        }
    }
View Full Code Here

     * Matching items are removed from the cache.
     *
     * @param items items updated
     */
    public void itemsUpdated(Collection<InternalVersionItem> items) {
        ReadLock lock = acquireReadLock();
        try {
            synchronized (versionItems) {
                for (InternalVersionItem item : items) {
                    InternalVersionItem cached = versionItems.remove(item.getId());
                    if (cached != null) {
                        if (cached instanceof InternalVersionHistoryImpl) {
                            InternalVersionHistoryImpl vh = (InternalVersionHistoryImpl) cached;
                            try {
                                vh.reload();
                                versionItems.put(vh.getId(), vh);
                            } catch (RepositoryException e) {
                                log.warn("Unable to update version history: " + e.toString());
                            }
                        }
                    }
                }
            }
        } finally {
            lock.release();
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    protected void itemDiscarded(InternalVersionItem item) {
        // evict removed item from cache
        ReadLock lock = acquireReadLock();
        try {
            versionItems.remove(item.getId());
        } finally {
            lock.release();
        }
    }
View Full Code Here

     * <p/>
     * Remove item from cache on removal.
     */
    public void stateDestroyed(ItemState destroyed) {
        // evict removed item from cache
        ReadLock lock = acquireReadLock();
        try {
            versionItems.remove(destroyed.getId());
        } finally {
            lock.release();
        }
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public InternalVersion[] getSuccessors() {
        ReadLock lock = vMgr.acquireReadLock();
        try {
            InternalValue[] values = node.getPropertyValues(NameConstants.JCR_SUCCESSORS);
            if (values != null) {
                InternalVersion[] versions = new InternalVersion[values.length];
                for (int i = 0; i < values.length; i++) {
                    versions[i] = versionHistory.getVersion(values[i].getNodeId());
                }
                return versions;
            } else {
                return new InternalVersion[0];
            }
        } finally {
            lock.release();
        }
    }
View Full Code Here

     * @return the new copy
     * @throws RepositoryException if an error occurs
     */
    private InternalVersionHistoryImpl makeLocalCopy(InternalVersionHistoryImpl history)
            throws RepositoryException {
        ReadLock lock = acquireReadLock();
        try {
            NodeState state = (NodeState) stateMgr.getItemState(history.getId());
            NodeStateEx stateEx = new NodeStateEx(stateMgr, ntReg, state, null);
            return new InternalVersionHistoryImpl(this, stateEx);
        } catch (ItemStateException e) {
            throw new RepositoryException("Unable to make local copy", e);
        } finally {
            lock.release();
        }
    }
View Full Code Here

     * @return the new copy
     * @throws RepositoryException if an error occurs
     */
    private InternalActivityImpl makeLocalCopy(InternalActivityImpl act)
            throws RepositoryException {
        ReadLock lock = acquireReadLock();
        try {
            NodeState state = (NodeState) stateMgr.getItemState(act.getId());
            NodeStateEx stateEx = new NodeStateEx(stateMgr, ntReg, state, null);
            return new InternalActivityImpl(this, stateEx);
        } catch (ItemStateException e) {
            throw new RepositoryException("Unable to make local copy", e);
        } finally {
            lock.release();
        }
    }
View Full Code Here

     * contains a reference to an item with id <code>I</code>. </i>
     *
     * @throws InterruptedException on interruption; this will err the test
     */
    public void testReadBlocksWrite() throws InterruptedException {
        ReadLock rLock = locking.acquireReadLock(state.getId());
        for (Iterator it = logs.iterator(); it.hasNext();) {
            ChangeLog changeLog = (ChangeLog) it.next();
            verifyBlocked(startWriterThread(locking, changeLog));
        }
        rLock.release();
    }
View Full Code Here

    public void testDowngrade() throws InterruptedException {
        for (Iterator it = logs.iterator(); it.hasNext();) {
            ChangeLog changeLog = (ChangeLog) it.next();
            WriteLock wLock = locking.acquireWriteLock(changeLog);
            verifyBlocked(startReaderThread(locking, state.getId()));
            ReadLock rLock = wLock.downgrade();
            verifyNotBlocked(startReaderThread(locking, state.getId()));
            rLock.release();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.state.ISMLocking.ReadLock

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.