@@ -0,0 +1,2927 @@
+/**%0A * Project Distributed Transactions.%0A * Copyright Micha%C5%82 Szczygie%C5%82, 2013.%0A * Created at Dec 28, 2013.%0A */%0Apackage com.m4gik;%0A%0Aimport java.io.File;%0A%0Aimport javax.sql.DataSource;%0A%0Aimport org.junit.AfterClass;%0Aimport org.junit.BeforeClass;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.beans.factory.annotation.Qualifier;%0Aimport org.springframework.jdbc.core.simple.SimpleJdbcTemplate;%0Aimport org.springframework.test.context.ContextConfiguration;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0A%0A/**%0A * This class sets base data sources for project.%0A * %0A * @author m4gik %3Cmichal.szczygiel@wp.pl%3E%0A * %0A */%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@ContextConfiguration(locations = %22/META-INF/spring/data-source-context.xml%22)%0Apublic class BaseDataSource %7B%0A%0A    /**%0A     * Method for logging.%0A     */%0A    @BeforeClass%0A    @AfterClass%0A    public static void clearLog() %7B%0A%0A        // Ensure that Atomikos logging directory exists%0A        File dir = new File(%22atomikos%22);%0A        if (!dir.exists()) %7B%0A            dir.mkdir();%0A        %7D%0A%0A        // ...and delete any stale locks (this would be a sign of a crash)%0A        File tmlog = new File(%22atomikos/tmlog.lck%22);%0A        if (tmlog.exists()) %7B%0A            tmlog.delete();%0A        %7D%0A    %7D%0A%0A    /**%0A     * JDBC object to the Finance.%0A     */%0A    private SimpleJdbcTemplate jdbcFinance;%0A%0A    /**%0A     * JDBC object to the warehouse in Finland.%0A     */%0A    private SimpleJdbcTemplate jdbcWarehouseFinland;%0A%0A    /**%0A     * JDBC object to the warehouse in Poland.%0A     */%0A    private SimpleJdbcTemplate jdbcWarehousePoland;%0A%0A    /**%0A     * @return the jdbcFinance%0A     */%0A    public SimpleJdbcTemplate getJdbcFinance() %7B%0A        return jdbcFinance;%0A    %7D%0A%0A    /**%0A     * @return the jdbcWarehouseFinland%0A     */%0A    public SimpleJdbcTemplate getJdbcWarehouseFinland() %7B%0A        return jdbcWarehouseFinland;%0A    %7D%0A%0A    /**%0A     * @return the jdbcWarehousePoland%0A     */%0A    public SimpleJdbcTemplate getJdbcWarehousePoland() %7B%0A        return jdbcWarehousePoland;%0A    %7D%0A%0A    /**%0A     * This method set data source for proper source from%0A     * data-source-context.xml.%0A     * %0A     * @param dataSourceWarehousePoland%0A     * @param dataSourceWarehouseFinland%0A     * @param dataSourceFinance%0A     */%0A    @Autowired%0A    public void setDataSources(%0A            @Qualifier(%22dataSourceWarehousePoland%22) DataSource dataSourceWarehousePoland,%0A            @Qualifier(%22dataSourceWarehouseFinland%22) DataSource dataSourceWarehouseFinland,%0A            @Qualifier(%22dataSourceFinance%22) DataSource dataSourceFinance) %7B%0A        this.jdbcWarehousePoland = new SimpleJdbcTemplate(%0A                dataSourceWarehousePoland);%0A        this.jdbcWarehouseFinland = new SimpleJdbcTemplate(%0A                dataSourceWarehouseFinland);%0A        this.jdbcFinance = new SimpleJdbcTemplate(dataSourceFinance);%0A    %7D%0A%7D%0A

Add class to set base data sources