protected abstract LockableComponent getLockableComponent();
@AroundInvoke
public Object invoke(InvocationContext invocationContext) throws Exception
{
LockableComponent lockableComponent = this.getLockableComponent();
// get the invoked method
Method invokedMethod = invocationContext.getMethod();
if (invokedMethod == null)
{
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.