Examples of ReadLock


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

     * @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

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

     * 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

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

    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

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

    /**
     * {@inheritDoc}
     */
    public InternalVersionHistory getVersionHistoryOfNode(NodeId id)
            throws RepositoryException {
        ReadLock lock = acquireReadLock();
        try {
            String uuid = id.getUUID().toString();
            Name name = getName(uuid);

            NodeStateEx parent = getParentNode(historyRoot, uuid, null);
            if (parent != null && parent.hasNode(name)) {
                NodeStateEx history = parent.getNode(name, 1);
                return getVersionHistory(history.getNodeId());
            } else {
                throw new ItemNotFoundException("Version history of node " + id + " not found.");
            }
        } finally {
            lock.release();
        }
    }
View Full Code Here

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

    public VersionHistoryInfo getVersionHistory(Session session, NodeState node,
                                                NodeId copiedFrom)
            throws RepositoryException {
        VersionHistoryInfo info = null;

        ReadLock lock = acquireReadLock();
        try {
            String uuid = node.getNodeId().getUUID().toString();
            Name name = getName(uuid);

            NodeStateEx parent = getParentNode(historyRoot, uuid, null);
            if (parent != null && parent.hasNode(name)) {
                NodeStateEx history = parent.getNode(name, 1);
                Name root = NameConstants.JCR_ROOTVERSION;
                info = new VersionHistoryInfo(
                        history.getNodeId(),
                        history.getState().getChildNodeEntry(root, 1).getId());
            }
        } finally {
            lock.release();
        }

        if (info == null) {
            info = createVersionHistory(session, node, copiedFrom);
        }
View Full Code Here

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

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

            return null;
        }
        if (id.equals(activitiesId)) {
            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

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

     * 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

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

    /**
     * {@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

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

     * <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
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.