Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
*
* This file is part of SeedStack, An enterprise-oriented full development stack.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.seedstack.seed.transaction.internal;
import com.google.common.base.Predicate;
import com.google.inject.Injector;
import com.google.inject.Key;
import com.google.inject.name.Names;
import org.seedstack.seed.core.api.SeedException;
import org.seedstack.seed.core.utils.SeedReflectionUtils;
import org.seedstack.seed.transaction.api.Transactional;
import org.seedstack.seed.transaction.spi.ExceptionHandler;
import org.seedstack.seed.transaction.spi.TransactionHandler;
import org.seedstack.seed.transaction.spi.TransactionManager;
import org.seedstack.seed.transaction.spi.TransactionMetadata;
import org.seedstack.seed.transaction.spi.TransactionMetadataResolver;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.reflections.ReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import java.lang.reflect.Method;
import java.util.Set;
/**
* Base class for common transaction manager behavior.
*
* @author [email protected]
*/
public abstract class AbstractTransactionManager implements TransactionManager {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractTransactionManager.class);
private final MethodInterceptorImplementation methodInterceptorImplementation = new MethodInterceptorImplementation();
@Inject
protected Injector injector;
@Inject
private Set transactionMetadataResolvers;
private final class MethodInterceptorImplementation implements MethodInterceptor {
@Override
@SuppressWarnings("unchecked")
public Object invoke(MethodInvocation invocation) throws Throwable {
String logPrefix = String.format("TX[%d]", Thread.currentThread().getId());
LOGGER.debug("{}: intercepting {}#{}", logPrefix, invocation.getMethod().getDeclaringClass().getCanonicalName(), invocation.getMethod().getName());
TransactionMetadata transactionMetadata = readTransactionMetadata(invocation);
LOGGER.debug("{}: {}", logPrefix, transactionMetadata);
TransactionHandler