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;
}
}
Aggregations