// Path: tcc-transaction-core/src/main/java/org/pankai/tcctransaction/support/BeanFactoryAdapter.java
// public class BeanFactoryAdapter {
// 
//     private static BeanFactory beanFactory;
// 
//     public static Object getBean(Class<?> clazz) {
//         return beanFactory.getBean(clazz);
//     }
// 
//     public static void setBeanFactory(BeanFactory beanFactory) {
//         BeanFactoryAdapter.beanFactory = beanFactory;
//     }
// }
// 
// Path: tcc-transaction-core/src/main/java/org/pankai/tcctransaction/utils/StringUtils.java
// public class StringUtils {
// 
//     public static boolean isNotEmpty(String value) {
//         if (value == null) {
//             return false;
//         }
//         if (value.equals("")) {
//             return false;
//         }
//         return true;
//     }
// }


import org.pankai.tcctransaction.support.BeanFactoryAdapter;
import org.pankai.tcctransaction.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.lang.reflect.Method;
package org.pankai.tcctransaction;



/**
 * Created by pankai on 2016/11/13.
 */
public class Terminator implements Serializable {

    private static final Logger logger = LoggerFactory.getLogger(Terminator.class);

    private InvocationContext confirmInvocationContext;
    private InvocationContext cancelInvocationContext;

    public Terminator() {

    }

    public Terminator(InvocationContext confirmInvocationContextm, InvocationContext cancelInvocationContext) {
        this.confirmInvocationContext = confirmInvocationContextm;
        this.cancelInvocationContext = cancelInvocationContext;
    }

    public void commit() {
        logger.debug("Transaction participant commit operation.");
        invoke(confirmInvocationContext);
    }

    public void rollback() {
        logger.debug("Transaction participant rollback operation.");
        invoke(cancelInvocationContext);
    }

    private Object invoke(InvocationContext invocationContext) {
// Path: tcc-transaction-core/src/main/java/org/pankai/tcctransaction/support/BeanFactoryAdapter.java
// public class BeanFactoryAdapter {
// 
//     private static BeanFactory beanFactory;
// 
//     public static Object getBean(Class<?> clazz) {
//         return beanFactory.getBean(clazz);
//     }
// 
//     public static void setBeanFactory(BeanFactory beanFactory) {
//         BeanFactoryAdapter.beanFactory = beanFactory;
//     }
// }
// 
// Path: tcc-transaction-core/src/main/java/org/pankai/tcctransaction/utils/StringUtils.java
// public class StringUtils {
// 
//     public static boolean isNotEmpty(String value) {
//         if (value == null) {
//             return false;
//         }
//         if (value.equals("")) {
//             return false;
//         }
//         return true;
//     }
// }


// Path: tcc-transaction-core/src/main/java/org/pankai/tcctransaction/Terminator.java
import org.pankai.tcctransaction.support.BeanFactoryAdapter;
import org.pankai.tcctransaction.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
import java.lang.reflect.Method;

package org.pankai.tcctransaction;



/**
 * Created by pankai on 2016/11/13.
 */
public class Terminator implements Serializable {

    private static final Logger logger = LoggerFactory.getLogger(Terminator.class);

    private InvocationContext confirmInvocationContext;
    private InvocationContext cancelInvocationContext;

    public Terminator() {

    }

    public Terminator(InvocationContext confirmInvocationContextm, InvocationContext cancelInvocationContext) {
        this.confirmInvocationContext = confirmInvocationContextm;
        this.cancelInvocationContext = cancelInvocationContext;
    }

    public void commit() {
        logger.debug("Transaction participant commit operation.");
        invoke(confirmInvocationContext);
    }

    public void rollback() {
        logger.debug("Transaction participant rollback operation.");
        invoke(cancelInvocationContext);
    }

    private Object invoke(InvocationContext invocationContext) {
        if (StringUtils.isNotEmpty(invocationContext.getMethodName())) {