Created
May 2, 2011 11:24
-
-
Save chregu/951467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java | |
index 7ba58ab..2bdbc92 100644 | |
--- jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java | |
+++ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java | |
@@ -125,12 +125,24 @@ public class DatabaseJournal extends AbstractJournal implements DatabaseAware { | |
*/ | |
private String dataSourceName; | |
+ | |
/** | |
+ * DataSource logical name, bean property. | |
+ */ | |
+ private String dataSourceNameJournalRead; | |
+ | |
+ | |
+ /** | |
* The connection helper | |
*/ | |
ConnectionHelper conHelper; | |
/** | |
+ * The connection helper | |
+ */ | |
+ ConnectionHelper conHelperJournalRead; | |
+ | |
+ /** | |
* Auto commit level. | |
*/ | |
private int lockLevel; | |
@@ -257,6 +269,7 @@ public class DatabaseJournal extends AbstractJournal implements DatabaseAware { | |
try { | |
conHelper = createConnectionHelper(getDataSource()); | |
+ conHelperJournalRead = createConnectionHelper(getDataSourceJournalRead()); | |
// make sure schemaObjectPrefix consists of legal name characters only | |
schemaObjectPrefix = conHelper.prepareDbIdentifier(schemaObjectPrefix); | |
@@ -287,6 +300,14 @@ public class DatabaseJournal extends AbstractJournal implements DatabaseAware { | |
return connectionFactory.getDataSource(dataSourceName); | |
} | |
} | |
+ | |
+ private DataSource getDataSourceJournalRead() throws Exception { | |
+ if (getDataSourceNameJournalRead() == null || "".equals(getDataSourceNameJournalRead())) { | |
+ return getDataSource(); | |
+ } else { | |
+ return connectionFactory.getDataSource(dataSourceNameJournalRead); | |
+ } | |
+ } | |
/** | |
* This method is called from the {@link #init(String, NamespaceResolver)} method of this class and | |
@@ -416,7 +437,8 @@ public class DatabaseJournal extends AbstractJournal implements DatabaseAware { | |
*/ | |
public RecordIterator getRecords(long startRevision) throws JournalException { | |
try { | |
- return new DatabaseRecordIterator(conHelper.exec(selectRevisionsStmtSQL, new Object[]{new Long( | |
+// log.info("selectRevisionsStmtSQL " + selectRevisionsStmtSQL); | |
+ return new DatabaseRecordIterator(conHelperJournalRead.exec(selectRevisionsStmtSQL, new Object[]{new Long( | |
startRevision)}, false, 0), getResolver(), getNamePathResolver()); | |
} catch (SQLException e) { | |
throw new JournalException("Unable to return record iterator.", e); | |
@@ -428,7 +450,7 @@ public class DatabaseJournal extends AbstractJournal implements DatabaseAware { | |
*/ | |
public RecordIterator getRecords() throws JournalException { | |
try { | |
- return new DatabaseRecordIterator(conHelper.exec(selectRevisionsStmtSQL, new Object[]{new Long( | |
+ return new DatabaseRecordIterator(conHelperJournalRead.exec(selectRevisionsStmtSQL, new Object[]{new Long( | |
Long.MIN_VALUE)}, false, 0), getResolver(), getNamePathResolver()); | |
} catch (SQLException e) { | |
throw new JournalException("Unable to return record iterator.", e); | |
@@ -738,10 +760,19 @@ public class DatabaseJournal extends AbstractJournal implements DatabaseAware { | |
return dataSourceName; | |
} | |
+ public String getDataSourceNameJournalRead() { | |
+ return dataSourceNameJournalRead; | |
+ } | |
+ | |
public void setDataSourceName(String dataSourceName) { | |
this.dataSourceName = dataSourceName; | |
} | |
+ public void setDataSourceNameJournalRead(String dataSourceName) { | |
+ this.dataSourceNameJournalRead = dataSourceName; | |
+ } | |
+ | |
+ | |
/** | |
* @return whether the schema check is enabled | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment