change version to 3.3.0-SNAPSHOT in cdm-3.3 branch
[cdmlib.git] / cdmlib-persistence / src / main / java / eu / etaxonomy / cdm / database / UpdatableRoutingDataSource.java
index b7fa4d6d19ab4f9703a91f889305c770f73a6afb..4fe9772808049fc85fa27a6a74988e50daa458a0 100644 (file)
@@ -9,16 +9,15 @@
 \r
 package eu.etaxonomy.cdm.database;\r
 \r
-import java.io.File;\r
 import java.sql.Connection;\r
 import java.sql.SQLException;\r
+import java.sql.SQLFeatureNotSupportedException;\r
 import java.util.HashMap;\r
 import java.util.Map;\r
+import java.util.logging.Logger;\r
 \r
 import javax.sql.DataSource;\r
 \r
-import org.springframework.beans.factory.xml.XmlBeanFactory;\r
-import org.springframework.core.io.FileSystemResource;\r
 import org.springframework.jdbc.datasource.SimpleDriverDataSource;\r
 import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;\r
 \r
@@ -43,15 +42,19 @@ import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
    </pre>\r
  * \r
  * @author a.kohlbecker\r
+ * @deprecated<b>NOTICE:</b> \r
+ * <em>This class is related to the switchable database infrastructure which allows to serve \r
+ * multiple databases with only a single instance of the cdm-remote-webapp. \r
+ * This concept however is deprecated due to several problems of which the most severe is the term loading issue.\r
+ * This class should however not deleted since we once might wish to switch back to this concept when we are \r
+ * able to deal with the implicated issues. \r
+ * \r
+ * See http://dev.e-taxonomy.eu/trac/wiki/CdmServerSwitchableDataSources for more information.</em>\r
  */\r
+@Deprecated\r
 public class UpdatableRoutingDataSource extends AbstractRoutingDataSource {\r
        \r
-       \r
-       private static final String DATASOURCE_BEANDEF_FILE = "datasources.xml";\r
-       private static final String DATASOURCE_BEANDEF_PATH = System.getProperty("user.home")+File.separator+".cdmLibrary"+File.separator;\r
-       \r
-       private static String userdefinedBeanDefinitionFile = null;\r
-       \r
+\r
        private String defaultDatasourceName = "default";\r
 \r
        @Override\r
@@ -70,9 +73,7 @@ public class UpdatableRoutingDataSource extends AbstractRoutingDataSource {
        }\r
        \r
        \r
-       public void setBeanDefinitionFile(String filename){\r
-               userdefinedBeanDefinitionFile = filename;\r
-       }\r
+\r
        \r
        public Map<String, DataSourceInfo> updateDataSources() {\r
                \r
@@ -90,26 +91,11 @@ public class UpdatableRoutingDataSource extends AbstractRoutingDataSource {
                \r
                return dataSourceInfos;\r
        }\r
-\r
-       /**\r
-        * @return\r
-        */\r
-       protected Map<String, SimpleDriverDataSource> loadDataSources() {\r
-\r
-               Map<String, SimpleDriverDataSource> dataSources = new HashMap<String, SimpleDriverDataSource>();\r
-\r
-               String path = DATASOURCE_BEANDEF_PATH + (userdefinedBeanDefinitionFile == null ? DATASOURCE_BEANDEF_FILE : userdefinedBeanDefinitionFile);\r
-               logger.info("    loading bean definition file: " + path);\r
-               FileSystemResource file = new FileSystemResource(path);\r
-               XmlBeanFactory beanFactory  = new XmlBeanFactory(file);\r
-               \r
-               for(String beanName : beanFactory.getBeanDefinitionNames()){\r
-                       SimpleDriverDataSource datasource = (SimpleDriverDataSource)beanFactory.getBean(beanName, SimpleDriverDataSource.class);\r
-                       dataSources.put(beanName, datasource);\r
-               }\r
-               return dataSources;\r
-       }\r
        \r
+       protected Map<String, SimpleDriverDataSource> loadDataSources(){\r
+               return DataSourceBeanLoader.loadDataSources(SimpleDriverDataSource.class);\r
+       }\r
+\r
        /**\r
         * @param dataSources\r
         * @return\r
@@ -140,4 +126,10 @@ public class UpdatableRoutingDataSource extends AbstractRoutingDataSource {
                return dataSourceInfos;\r
        }\r
 \r
+       // added for compatibility with Java 7\r
+       public Logger getParentLogger() /* throws SQLFeatureNotSupportedException (is not compatibel with parent class in Java 6)*/  {\r
+               // TODO Auto-generated method stub\r
+               return null;\r
+       }\r
+\r
 }\r