aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-10-25 16:20:07 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-10-25 16:20:15 +0200
commit3c07047ac56b549b0d5fe6543db0666c176ec23c (patch)
tree8a6523f91e8054533a81d1bc6676b9baaf52a00c /sonar-batch
parent44535b310d471e67ce33b02668f6f09d031d15f1 (diff)
downloadsonarqube-3c07047ac56b549b0d5fe6543db0666c176ec23c.tar.gz
sonarqube-3c07047ac56b549b0d5fe6543db0666c176ec23c.zip
SONAR-2642 first step to integration mybatis
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabase.java43
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java9
2 files changed, 49 insertions, 3 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabase.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabase.java
new file mode 100644
index 00000000000..55871f76d0d
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabase.java
@@ -0,0 +1,43 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.batch.bootstrap;
+
+import org.sonar.api.config.Settings;
+import org.sonar.persistence.DefaultDatabase;
+
+import java.util.Properties;
+
+/**
+ * @since 2.12
+ */
+public class BatchDatabase extends DefaultDatabase {
+
+ public BatchDatabase(Settings settings) {
+ super(settings);
+ }
+
+ @Override
+ protected void doCompleteProperties(Properties properties) {
+ // two connections are required : one for Hibernate and one for MyBatis
+ // Note that Hibernate will be remove soon
+ properties.setProperty("sonar.jdbc.initialSize", "2");
+ properties.setProperty("sonar.jdbc.maxActive", "2");
+ }
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
index 28cb581735b..f6e60a928ca 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
@@ -21,7 +21,6 @@ package org.sonar.batch.bootstrap;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.batch.FakeMavenPluginExecutor;
import org.sonar.batch.MavenPluginExecutor;
@@ -29,8 +28,10 @@ import org.sonar.batch.ServerMetadata;
import org.sonar.batch.config.BatchSettings;
import org.sonar.batch.config.BatchSettingsEnhancer;
import org.sonar.jpa.session.DatabaseSessionProvider;
-import org.sonar.jpa.session.DriverDatabaseConnector;
+import org.sonar.jpa.session.DefaultDatabaseConnector;
import org.sonar.jpa.session.ThreadLocalDatabaseSessionFactory;
+import org.sonar.persistence.DefaultDatabase;
+import org.sonar.persistence.MyBatis;
import java.net.URLClassLoader;
@@ -63,7 +64,9 @@ public class BootstrapModule extends Module {
// set as the current context classloader for hibernate, else it does not find the JDBC driver.
Thread.currentThread().setContextClassLoader(bootstrapClassLoader);
- addCoreSingleton(new DriverDatabaseConnector(getComponentByType(Settings.class), bootstrapClassLoader));
+ addCoreSingleton(BatchDatabase.class);
+ addCoreSingleton(MyBatis.class);
+ addCoreSingleton(DefaultDatabaseConnector.class);
addCoreSingleton(ThreadLocalDatabaseSessionFactory.class);
addAdapter(new DatabaseSessionProvider());
for (Object component : boostrapperComponents) {