throw new IllegalArgumentException("Invocation context: " + invocationContext + " cannot be processed because it's not applicable for a method invocation");
}
// get the Lock applicable for this method
Lock lock = getLock(lockableComponent, invokedMethod);
// the default access timeout (will be used in the absence of any explicit access timeout value for the invoked method)
AccessTimeout defaultAccessTimeout = lockableComponent.getDefaultAccessTimeout();
// set to the default values
long time = defaultAccessTimeout.value();
TimeUnit unit = defaultAccessTimeout.unit();
AccessTimeout accessTimeoutOnMethod = lockableComponent.getAccessTimeout(invokedMethod);
if (accessTimeoutOnMethod != null)
{
if (accessTimeoutOnMethod.value() < 0)
{
// for any negative value of timeout, we just default to max timeout val and max timeout unit.
// violation of spec! But we don't want to wait indefinitely.
logger.debug("Ignoring a negative @AccessTimeout value: " + accessTimeoutOnMethod.value() + " and timeout unit: "
+ accessTimeoutOnMethod.unit().name() + ". Will default to timeout value: " + defaultAccessTimeout.value()
+ " and timeout unit: " + defaultAccessTimeout.unit().name());
}
else
{
// use the explicit access timeout values specified on the method
time = accessTimeoutOnMethod.value();
unit = accessTimeoutOnMethod.unit();
}
}
// try getting the lock
boolean success = lock.tryLock(time, unit);
if (!success)