Search in sources :

Example 1 with DistributedLockType

use of fish.payara.cluster.DistributedLockType in project Payara by payara.

the class SafeProperties method setConcurrencyInvInfo.

private void setConcurrencyInvInfo(Method invInfoMethod, String methodIntf, InvocationInfo invInfo) {
    MethodLockInfo lockInfo = null;
    // Set READ/WRITE lock info.  Only applies to singleton beans.
    if (isSingleton) {
        EjbSessionDescriptor singletonDesc = (EjbSessionDescriptor) ejbDescriptor;
        List<MethodDescriptor> readLockMethods = singletonDesc.getReadLockMethods();
        List<MethodDescriptor> writeLockMethods = singletonDesc.getWriteLockMethods();
        DistributedLockType distLockType = singletonDesc.isClustered() ? singletonDesc.getClusteredLockType() : DistributedLockType.LOCK_NONE;
        for (MethodDescriptor readLockMethodDesc : readLockMethods) {
            Method readLockMethod = readLockMethodDesc.getMethod(singletonDesc);
            if (implMethodMatchesInvInfoMethod(invInfoMethod, methodIntf, readLockMethod)) {
                lockInfo = new MethodLockInfo();
                switch(distLockType) {
                    case INHERIT:
                        {
                            _logger.log(Level.WARNING, "Distributed Read Lock for Method {0} Upgraded to Read/Write", readLockMethod.getName());
                            lockInfo.setLockType(LockType.WRITE, true);
                            break;
                        }
                    case LOCK_NONE:
                        {
                            lockInfo.setLockType(LockType.READ, false);
                        }
                }
                break;
            }
        }
        if (lockInfo == null) {
            for (MethodDescriptor writeLockMethodDesc : writeLockMethods) {
                Method writeLockMethod = writeLockMethodDesc.getMethod(singletonDesc);
                if (implMethodMatchesInvInfoMethod(invInfoMethod, methodIntf, writeLockMethod)) {
                    lockInfo = new MethodLockInfo();
                    lockInfo.setLockType(LockType.WRITE, distLockType != DistributedLockType.LOCK_NONE);
                    break;
                }
            }
        }
    }
    // Set AccessTimeout info
    if (isSingleton || isStatefulSession) {
        EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejbDescriptor;
        List<EjbSessionDescriptor.AccessTimeoutHolder> accessTimeoutInfo = sessionDesc.getAccessTimeoutInfo();
        for (EjbSessionDescriptor.AccessTimeoutHolder accessTimeoutHolder : accessTimeoutInfo) {
            MethodDescriptor accessTimeoutMethodDesc = accessTimeoutHolder.method;
            Method accessTimeoutMethod = accessTimeoutMethodDesc.getMethod(sessionDesc);
            if (implMethodMatchesInvInfoMethod(invInfoMethod, methodIntf, accessTimeoutMethod)) {
                if (lockInfo == null) {
                    lockInfo = new MethodLockInfo();
                }
                lockInfo.setTimeout(accessTimeoutHolder.value, accessTimeoutHolder.unit);
                break;
            }
        }
    }
    if (lockInfo != null) {
        invInfo.methodLockInfo = lockInfo;
    }
}
Also used : DistributedLockType(fish.payara.cluster.DistributedLockType) Method(java.lang.reflect.Method) EjbSessionDescriptor(org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor) MethodDescriptor(com.sun.enterprise.deployment.MethodDescriptor) MethodLockInfo(com.sun.ejb.MethodLockInfo)

Aggregations

MethodLockInfo (com.sun.ejb.MethodLockInfo)1 MethodDescriptor (com.sun.enterprise.deployment.MethodDescriptor)1 DistributedLockType (fish.payara.cluster.DistributedLockType)1 Method (java.lang.reflect.Method)1 EjbSessionDescriptor (org.glassfish.ejb.deployment.descriptor.EjbSessionDescriptor)1