@Override public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); CrudMethodMetadata metadata = (CrudMethodMetadata) TransactionSynchronizationManager.getResource(method); if (metadata != null) { return invocation.proceed(); } CrudMethodMetadata methodMetadata = metadataCache.get(method); if (methodMetadata == null) { methodMetadata = new DefaultCrudMethodMetadata(method); CrudMethodMetadata tmp = metadataCache.putIfAbsent(method, methodMetadata); if (tmp != null) { methodMetadata = tmp; } } TransactionSynchronizationManager.bindResource(method, methodMetadata); try { return invocation.proceed(); } finally { TransactionSynchronizationManager.unbindResource(method); } } }
/** * Creates a new {@link DefaultCrudMethodMetadata} for the given {@link Method}. * * @param method must not be {@literal null}. */ DefaultCrudMethodMetadata(Method method) { Assert.notNull(method, "Method must not be null!"); this.lockModeType = findLockModeType(method); this.queryHints = findQueryHints(method); this.entityGraph = findEntityGraph(method); this.method = method; }
public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); CrudMethodMetadata metadata = (CrudMethodMetadata) TransactionSynchronizationManager.getResource(method); if (metadata != null) { return invocation.proceed(); } CrudMethodMetadata methodMetadata = metadataCache.get(method); if (methodMetadata == null) { methodMetadata = new DefaultCrudMethodMetadata(method); CrudMethodMetadata tmp = metadataCache.putIfAbsent(method, methodMetadata); if (tmp != null) { methodMetadata = tmp; } } TransactionSynchronizationManager.bindResource(method, methodMetadata); try { return invocation.proceed(); } finally { TransactionSynchronizationManager.unbindResource(method); } } }
/** * Creates a new {@link DefaultCrudMethodMetadata} for the given {@link Method}. * * @param method must not be {@literal null}. */ DefaultCrudMethodMetadata(Method method) { Assert.notNull(method, "Method must not be null!"); this.lockModeType = findLockModeType(method); this.queryHints = findQueryHints(method); this.entityGraph = findEntityGraph(method); this.method = method; }