/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package io.shardingsphere.transaction.xa;

import com.atomikos.icatch.jta.UserTransactionManager;

/**
 * Hold singleton atomikos userTransaction.
 *
 * @author zhaojun
 */
public final class AtomikosUserTransaction {
    
    // TODO why not new here?
    private static volatile UserTransactionManager transactionManager;
    
    /**
     * Get singleton {@code UserTransactionManager} lazily.
     *
     * @return {@code UserTransactionManager}
     */
    public static UserTransactionManager getInstance() {
        if (null == transactionManager) {
            synchronized (AtomikosUserTransaction.class) {
                if (null == transactionManager) {
                    transactionManager = new UserTransactionManager();
                }
            }
        }
        return transactionManager;
    }
}

@@ -710,16 +710,76 @@
 Manager;
+%0Aimport lombok.AccessLevel;%0Aimport lombok.NoArgsConstructor;
 %0A%0A/**%0A *
@@ -846,16 +846,65 @@
 jun%0A */%0A
+@NoArgsConstructor(access = AccessLevel.PRIVATE)%0A
 public f
@@ -949,38 +949,8 @@
    %0A
-    // TODO why not new here?%0A
     
@@ -968,16 +968,13 @@
 tic 
-volatile
+final
  Use
@@ -993,17 +993,47 @@
 Manager 
-t
+TRANSACTION_MANAGER = new UserT
 ransacti
@@ -1037,24 +1037,26 @@
 ctionManager
+()
 ;%0A    %0A    /
@@ -1079,16 +1079,19 @@
 ngleton 
+of 
 %7B@code U
@@ -1116,15 +1116,8 @@
 ger%7D
- lazily
 .%0A  
@@ -1244,297 +1244,34 @@
     
-if (null == transactionManager) %7B%0A            synchronized (AtomikosUserTransaction.class) %7B%0A                if (null == transactionManager) %7B%0A                    transactionManager = new UserTransactionManager();%0A                %7D%0A            %7D%0A        %7D%0A        return transactionManager
+return TRANSACTION_MANAGER
 ;%0A  

refactor AtomikosUserTransaction to hungry mode.