@Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    if (!emProvider.isWorking()) {
      emProvider.begin();
      didWeStartWork.set(true);

      try {
        return invocation.proceed();
      } finally {
        if (null != didWeStartWork.get()) {
          didWeStartWork.remove();
          emProvider.end();
        }
      }

    } else {
      //if session was in progress just proceed without additional checks
      return invocation.proceed();
    }




  }
AOP interceptor to provide session borders
ambari-server/src/main/java/org/apache/ambari/server/orm/AmbariLocalSessionInterceptor.java