Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.persist.core

File JtaDynamicClass.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
25% of files have more coverage

Code metrics

0
7
2
1
40
22
2
0.29
3.5
2
1

Classes

Class Line # Actions
JtaDynamicClass 8 7 2
0.666666766.7%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    package io.sunshower.persist.core;
2   
3    import com.arjuna.ats.internal.jdbc.DynamicClass;
4    import java.sql.SQLException;
5    import javax.sql.XADataSource;
6    import org.h2.jdbcx.JdbcDataSource;
7   
 
8    public class JtaDynamicClass implements DynamicClass {
9   
10    static final Object lock = new Object();
11    static volatile XADataSource datasource;
12   
 
13  0 toggle public static void clear() {
14  0 synchronized (lock) {
15  0 datasource = null;
16    }
17    }
18   
 
19  4 toggle @Override
20    public XADataSource getDataSource(String dbName) throws SQLException {
21    // if (datasource == null) {
22    // synchronized (lock) {
23    // if (datasource == null) {
24    // final JdbcDataSource dataSource = new JdbcDataSource();
25    // dataSource.setUser("sa");
26    // dataSource.setPassword("");
27    // dataSource.setURL("jdbc:" + dbName);
28    // return (datasource = dataSource);
29    // }
30    // }
31    // }
32    // return datasource;
33   
34  4 final JdbcDataSource dataSource = new JdbcDataSource();
35  4 dataSource.setUser("sa");
36  4 dataSource.setPassword("");
37  4 dataSource.setURL("jdbc:" + dbName);
38  4 return dataSource;
39    }
40    }