Commit 62e7640e authored by terrymanu's avatar terrymanu
Browse files

refactor TransactionType

parent 74aecad8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ public enum ShardingPropertiesConstant {
     */
    CONNECTION_MODE("connection.mode", ConnectionMode.MEMORY_STRICTLY.name(), String.class),
    
    PROXY_TRANSACTION_MODE("proxy.transaction.mode", TransactionType.NONE.name(), String.class),
    PROXY_TRANSACTION_MODE("proxy.transaction.mode", TransactionType.LOCAL.name(), String.class),
    
    PROXY_BACKEND_USE_NIO("proxy.backend.use.nio", Boolean.FALSE.toString(), boolean.class),
    
+2 −42
Original line number Diff line number Diff line
@@ -17,52 +17,12 @@

package io.shardingsphere.core.constant;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * TransactionType Enum.
 * Transaction type.
 *
 * @author zhaojun
 */
@RequiredArgsConstructor
@Getter
public enum TransactionType {
    
    /**
     * Default local transaction.
     */
    NONE(""),
    
    /**
     * XA distribute transaction provided by RDBMS vendor.
     */
    XA("XA"),
    
    /**
     * B.A.S.E distribute transaction.
     */
    BASE("BASE"),
    
    /**
     * TCC (Try-Confirm-Cancel) distribute transaction mode.
     */
    TCC("TCC");
    
    private final String type;
    
    /**
     * Find enum by type value.
     *
     * @param type property type
     * @return value enum, return {@code NONE} if not found
     */
    public static TransactionType findByValue(final String type) {
        for (TransactionType each : TransactionType.values()) {
            if (each.getType().equals(type)) {
                return each;
            }
        }
        return NONE;
    }
    LOCAL, XA, BASE
}