Coverage Report - liquibase.executor.ExecutorService
 
Classes in this File Line Coverage Branch Coverage Complexity
ExecutorService
68%
13/19
100%
2/2
1.5
 
 1  
 package liquibase.executor;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.exception.UnexpectedLiquibaseException;
 5  
 import liquibase.servicelocator.ServiceLocator;
 6  
 
 7  
 import java.util.Map;
 8  
 import java.util.concurrent.ConcurrentHashMap;
 9  
 
 10  
 public class ExecutorService {
 11  
 
 12  1
     private static ExecutorService instance = new ExecutorService();
 13  
 
 14  1
     private Map<Database, Executor> executors = new ConcurrentHashMap<Database, Executor>();
 15  
 
 16  1
     private ExecutorService() {
 17  1
     }
 18  
 
 19  
     public static ExecutorService getInstance() {
 20  61
         return instance;
 21  
     }
 22  
 
 23  
     public Executor getExecutor(Database database) {
 24  45
         if (!executors.containsKey(database)) {
 25  
             try {
 26  6
                 Executor executor = (Executor) ServiceLocator.getInstance().newInstance(Executor.class);
 27  6
                 executor.setDatabase(database);
 28  6
                 executors.put(database, executor);
 29  0
             } catch (Exception e) {
 30  0
                 throw new UnexpectedLiquibaseException(e);
 31  6
             }
 32  
         }
 33  45
         return executors.get(database);
 34  
     }
 35  
 
 36  
     public void setExecutor(Database database, Executor executor) {
 37  16
         executors.put(database, executor);
 38  16
     }
 39  
 
 40  
     public void clearExecutor(Database database) {
 41  0
         executors.remove(database);
 42  0
     }
 43  
 
 44  
     public void reset() {
 45  0
         executors.clear();
 46  0
     }
 47  
 }