data sources update and tests
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / database / types / IDatabaseType.java
1 /**
2 * Copyright (C) 2007 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
10 package eu.etaxonomy.cdm.database.types;
11
12 import org.springframework.jdbc.datasource.DriverManagerDataSource;
13
14 import eu.etaxonomy.cdm.database.ICdmDataSource;
15
16 /**
17 * @author a.mueller
18 * @created 17.12.2008
19 * @version 1.0
20 */
21 public interface IDatabaseType {
22 /**
23 * @return
24 */
25 public String getName();
26 /**
27 * @return
28 */
29 public String getClassString();
30 /**
31 * @return
32 */
33 public String getUrlString();
34 /**
35 * @return
36 */
37 public int getDefaultPort();
38
39 /**
40 * @return
41 */
42 public String getHibernateDialect();
43
44 /**
45 * Returns the connection String for the given parameters, using default port
46 * @param cdmDataSource represents a datasource
47 * @return the connection String
48 */
49 public String getConnectionString(ICdmDataSource cdmDataSource);
50
51
52 /**
53 * Returns the DriverManagerDataSource class that that the datasource needs to create a spring bean
54 * @return the DriverManagerDataSource class
55 */
56 public Class<? extends DriverManagerDataSource> getDriverManagerDataSourceClass();
57
58
59 /**
60 * Returns the Name of the initialization method to be used when a hibernate datasource is created for this database
61 * @return String name of the init method
62 */
63 public String getInitMethod();
64
65 /**
66 * Returns the Name of the destroying method to be used when a hibernate datasource representing this database is destroyed
67 * @return String name of the destroy method
68 */
69 public String getDestroyMethod();
70
71 /**
72 * Returns the server name for a given connection string. Null or empty string is returned if the
73 * connection string is invalid
74 * @param connectionString the connection string
75 * @return string representing the server
76 */
77 public String getServerNameByConnectionString(String connectionString);
78
79
80 /**
81 * Returns the port for a given connection string. If no port is defined the default port is returned.
82 * If connection string is <code>null</code> or unvalid -1 is returned
83 * @param connectionString the connection string
84 * @return int representing the port number
85 */
86 public int getPortByConnectionString(String connectionString);
87
88
89 /**
90 * Returns the database name for a given connection string. Null or empty string is returned if the
91 * connection string is invalid
92 * @param connectionString the connection string
93 * @return string representing the database
94 */
95 public abstract String getDatabaseNameByConnectionString(String connectionString);
96 }