private void lockTransaction(MethodInvocation methodInvocation) {
    TransactionalLock annotation = methodInvocation.getMethod().getAnnotation(
        TransactionalLock.class);

    // no work to do if the annotation is not present
    if (null == annotation) {
      return;
    }

    // no need to lock again
    if (s_transactionalLocks.get().contains(annotation)) {
      return;
    }

    // there is a lock area, so acquire the lock
    LockArea lockArea = annotation.lockArea();
    LockType lockType = annotation.lockType();

    ReadWriteLock rwLock = transactionLocks.getLock(lockArea);
    Lock lock = lockType == LockType.READ ? rwLock.readLock() : rwLock.writeLock();

    lock.lock();

    // ensure that we add this lock area, otherwise it will never be released
    // when the outer most transaction is committed
    s_transactionalLocks.get().add(annotation);
  }
Locks the {@link LockArea} specified on the {@link TransactionalLock}
annotation if it exists. If the annotation does not exist, then no work is
done.
<p/>
If a lock is acquired, then {@link #s_transactionalLocks} is updated with
the lock so that the outer-most interceptor can release all locks when the
transaction has completed.

@param methodInvocation
ambari-server/src/main/java/org/apache/ambari/server/orm/AmbariJpaLocalTxnInterceptor.java