Examples of IEntityLock


Examples of org.jasig.portal.concurrency.IEntityLock

    boolean valid = false;
    IEntityLockService service = getService();

    msg = "Attempting to renew an old lock";
    print(msg);
    IEntityLock badLock = testLocks[2];
    msg = "Checking if lock was renewed.";
    print(msg);
    try { service.renew(badLock); } catch (Exception ex) {print("Caught Exception: " + ex.getMessage()); }
    assertTrue(msg, ! service.isValid(badLock));

    msg = "Attempting to renew a valid lock";
    print(msg);
    IEntityLock goodLock = testLocks[0];
    msg = "Checking if lock was renewed.";
    print(msg);
    try { service.renew(goodLock); } catch (Exception ex) {print("Caught Exception: " + ex.getMessage()); }
    assertTrue(msg, service.isValid(goodLock));
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

    String msg = null;
    boolean valid = false;

    print("Creating new lock");
    IEntityLockService service = getService();
    IEntityLock newLock = service.newLock(GROUP_CLASS, testKeys[3], IEntityLockService.WRITE_LOCK, testIds[0]);
    msg = "Testing if new lock is valid";
    valid = getService().existsInStore(newLock);
    print(msg);
    assertTrue(msg, valid);
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

    java.util.Date newExpiration = new java.util.Date(now + fiveMinutes);
    int newType = IEntityLockService.WRITE_LOCK;

    // Copy testLocks[1] to lock1.
    IEntityLock lock1 = new EntityLockImpl
        (testLocks[1].getEntityType(), testLocks[1].getEntityKey(),
         testLocks[1].getLockType(), testLocks[1].getExpirationTime(), testLocks[1].getLockOwner());

    // Update testLocks[1].
    getLockStore().update(testLocks[1], newExpiration, new Integer(newType));
    ((EntityLockImpl)testLocks[1]).setExpirationTime(newExpiration);
    ((EntityLockImpl)testLocks[1]).setLockType(newType);

    msg = "Check if the old version (lock1) still exists in store.";
    print(msg);
    assertTrue(msg, ! getService().existsInStore(lock1) );

    msg = "Check if new version exists in store.";
    print(msg);
    IEntityLock lock2 = new EntityLockImpl
        (lock1.getEntityType(), lock1.getEntityKey(), newType, newExpiration, lock1.getLockOwner());
    assertTrue( msg, getService().existsInStore(lock2) );

    print("Update only expiration on (updated) lock.");
    newExpiration = new java.util.Date(now + tenMinutes);
    getLockStore().update(lock2, newExpiration, null);
    ((EntityLockImpl)lock2).setExpirationTime(newExpiration);

    msg = "Check if un-updated lock still exists in store.";
    print(msg);
    assertTrue( msg, ! getService().existsInStore(testLocks[1]) );

    msg = "Check if the doubly-updated lock exists in store.";
    print(msg);
    IEntityLock lock3 = new EntityLockImpl
        (lock2.getEntityType(), lock2.getEntityKey(), lock2.getLockType(), newExpiration, lock2.getLockOwner());
    assertTrue( msg, getService().existsInStore(lock3) );

    testLocks[0] = lock3;
}
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

public IEntityLock newLock(Class entityType, String entityKey, int lockType, String owner, int durationSecs)
throws LockingException
{
    int expirationSecs = durationSecs;
    Date expires = getNewExpiration(expirationSecs);
    IEntityLock newLock = new EntityLockImpl(entityType, entityKey, lockType, expires, owner, this);

    // retrieve potentially conflicting locks:
    IEntityLock[] locks = retrieveLocks(entityType, entityKey, null);

    if ( lockType == WRITE_LOCK )
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

    Map cache = null;
    Collection caches = null;
    Iterator cacheIterator = null;
    Iterator cacheKeyIterator = null;
    Iterator keyIterator = null;
    IEntityLock lock = null;

    if ( entityType == null )
    {
        caches = getLockCache().values();
    }
    else
    {
        caches = new ArrayList(1);
        caches.add(getLockCache(entityType));
    }

    cacheIterator = caches.iterator();
    while ( cacheIterator.hasNext() )
    {
        cache = (Map) cacheIterator.next();
        cacheKeyIterator = cache.keySet().iterator();
        List keys = new ArrayList();

        // Synchronize on the cache only while collecting its keys.  There is some
        // exposure here.
        synchronized (cache) {
        while ( cacheKeyIterator.hasNext() )
            { keys.add(cacheKeyIterator.next()); }
        }

        keyIterator = keys.iterator();
        while ( keyIterator.hasNext() )
        {
            lock = getLockFromCache(keyIterator.next(), cache);
            if ( ( lock != null ) &&
                 ( (entityKey == null|| (entityKey.equals(lock.getEntityKey())) ) &&
                 ( (lockType == null)   || (lockType.intValue() == lock.getLockType()) ) &&
                 ( (lockOwner == null|| (lockOwner.equals(lock.getLockOwner())) ) &&
                 ( (expiration == null) || (expiration.equals(lock.getExpirationTime())) )
               )
                  { locks.add(lock); }
        }
    }
    return ((IEntityLock[])locks.toArray(new IEntityLock[locks.size()]));
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

* @param lock
* @return IEntityLock
*/
public IEntityLock find(IEntityLock lock) throws LockingException
{
    IEntityLock foundLock = null;
    Map m = getLockCache(lock.getEntityType());
    foundLock = getLockFromCache(getCacheKey(lock), m);

    if ( foundLock != null )
    {
        if ( lock.getLockType() != foundLock.getLockType() ||
           ! lock.getExpirationTime().equals(foundLock.getExpirationTime()) )
                { foundLock = null; }
    }

    return foundLock;
}
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

throws GroupsException
{
    Iterator itr;
    IEntityGroup containingGroup = null;
    ILockableEntityGroup lockableGroup = null;
    IEntityLock lock = null;
    List lockableGroups = new ArrayList();
    try
    {
        String lockOwner = group.getLock().getLockOwner();
        for ( itr=group.getContainingGroups(); itr.hasNext(); )
        {
            containingGroup = (IEntityGroup) itr.next();
            lockableGroup=
                GroupService.findLockableGroup(containingGroup.getKey(), lockOwner);
                if ( lockableGroup != null )
                     { lockableGroups.add(lockableGroup); }
        }
        for ( itr = lockableGroups.iterator(); itr.hasNext(); )
        {
            lockableGroup = (ILockableEntityGroup) itr.next();
            lockableGroup.removeMember(group);
            lockableGroup.updateMembers();
        }
    }
    catch (GroupsException ge)
        { throw new GroupsException("Could not remove deleted group " + group.getKey() +
                " from parent", ge); }
    finally
    {
        for ( itr = lockableGroups.iterator(); itr.hasNext(); )
        {
            lock = ((ILockableEntityGroup) itr.next()).getLock();
            try
            {
                if ( lock.isValid() )
                    { lock.release(); }
            }
            catch (LockingException le)
            {
                log.error(
                    "ReferenceIndividualGroupService.removeDeletedGroupFromContainingGroups(): " +
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

    throwExceptionIfNotInternallyManaged();

    Class groupType = org.jasig.portal.EntityTypes.GROUP_ENTITY_TYPE;
    try {
        IEntityLock lock =
            (secs == 0)
                ? EntityLockService.instance().newWriteLock(groupType, key, owner)
                : EntityLockService.instance().newWriteLock(groupType, key, owner, secs);

        ILockableEntityGroup group = groupFactory.findLockable(key);
        if (group == null) {
            lock.release();
        } else {
            group.setLock(lock);
            group.setLocalGroupService(this);
        }
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

throws GroupsException
{
    Class groupType = org.jasig.portal.EntityTypes.GROUP_ENTITY_TYPE;
    try
    {
        IEntityLock lock =  ( secs == 0 )
            ? EntityLockService.instance().newWriteLock(groupType, key, owner)
            : EntityLockService.instance().newWriteLock(groupType, key, owner, secs);

        ILockableEntityGroup group = groupFactory.findLockable(key);
        if ( group == null )
           { lock.release(); }
        else
            { group.setLock(lock); }

        return group;
    }
View Full Code Here

Examples of org.jasig.portal.concurrency.IEntityLock

    if ( obj == this )
        return true;
    if ( ! ( obj instanceof EntityLockImpl))
        return false;

    IEntityLock candidate = (IEntityLock) obj;
    return this.getEntityType().equals(candidate.getEntityType()) &&
           this.getEntityKey().equals(candidate.getEntityKey()) &&
           this.getLockOwner().equals(candidate.getLockOwner()) &&
           this.getLockType() == candidate.getLockType() &&
           this.getExpirationTime().equals(candidate.getExpirationTime());
}
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.