Project

General

Profile

Download (1.62 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2015 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.cdm.cache;
10

    
11
import java.net.URL;
12

    
13
import javax.sql.DataSource;
14

    
15
import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl;
16

    
17
import eu.etaxonomy.cdm.database.CdmDataSource;
18

    
19
/**
20
 * This is a very preliminary class to get the model cache running. Need to better understand how
21
 * the datasource works with hibernate service registry before implementing the correct way.
22

    
23
 * Or use a running source.
24
 *
25
 * When changing this class please also adapt https://dev.e-taxonomy.eu/redmine/projects/edit/wiki/TaxonomicEditorDevelopersGuide#Model-Change-Actions
26
 *
27
 * @author a.mueller
28
 */
29
public class CdmModelCacherConnectionProvider extends DatasourceConnectionProviderImpl{
30

    
31
    private static final long serialVersionUID = 454393966637126346L;
32

    
33
	public CdmModelCacherConnectionProvider() {
34
		setDataSource(getDataSourcePreliminary());
35
	}
36

    
37
	private DataSource getDataSourcePreliminary() {
38
		String database = "modelCacher";
39
		URL location = this.getClass().getProtectionDomain().getCodeSource().getLocation();
40
		String path = location.getFile().replace("classes/", "tmp/h2/"+database);
41
//		String path = "C:\\Users\\a.mueller\\.cdmLibrary\\writableResources\\h2\\LocalH2_" + database;
42
        String username = "sa";
43
        CdmDataSource dataSource = CdmDataSource.NewH2EmbeddedInstance("temp", username, "", path);
44
        return dataSource;
45
	}
46
}
(5-5/12)