Added a workaround for Spring 2.0-rc1 for AMQ-825 where we avoid using File objects on the default persistence adapter and use Strings instead. Its unfortunate (I tried patching xbean-spring to get around this but I'm afraid it doesn't seem possible). So folks using Java to configure the dataDirectory will need to change foo.setDataDirectory(file) to foo.setDataDirectoryFile(file) or switch to using a String

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@421936 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-07-14 16:25:29 +00:00
parent 3fcd7ca39c
commit fd3c5104df
5 changed files with 20 additions and 11 deletions

View File

@ -988,7 +988,7 @@ public class BrokerService implements Service, Serializable {
protected DefaultPersistenceAdapterFactory createPersistenceFactory() { protected DefaultPersistenceAdapterFactory createPersistenceFactory() {
DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory(); DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory();
factory.setDataDirectory(getDataDirectory()); factory.setDataDirectoryFile(getDataDirectory());
factory.setTaskRunnerFactory(getTaskRunnerFactory()); factory.setTaskRunnerFactory(getTaskRunnerFactory());
return factory; return factory;
} }

View File

@ -125,7 +125,7 @@ public class DefaultPersistenceAdapterFactory extends DataSourceSupport implemen
public File getJournalArchiveDirectory() { public File getJournalArchiveDirectory() {
if( journalArchiveDirectory == null && useQuickJournal ) { if( journalArchiveDirectory == null && useQuickJournal ) {
journalArchiveDirectory = new File(getDataDirectory(), "journal"); journalArchiveDirectory = new File(getDataDirectoryFile(), "journal");
} }
return journalArchiveDirectory; return journalArchiveDirectory;
} }
@ -162,7 +162,7 @@ public class DefaultPersistenceAdapterFactory extends DataSourceSupport implemen
* @throws IOException * @throws IOException
*/ */
protected void createJournal() throws IOException { protected void createJournal() throws IOException {
File journalDir = new File(getDataDirectory(), "journal").getCanonicalFile(); File journalDir = new File(getDataDirectoryFile(), "journal").getCanonicalFile();
if( failIfJournalIsLocked ) { if( failIfJournalIsLocked ) {
journal = new JournalImpl(journalDir, journalLogFiles, journalLogFileSize, getJournalArchiveDirectory()); journal = new JournalImpl(journalDir, journalLogFiles, journalLogFileSize, getJournalArchiveDirectory());
} else { } else {

View File

@ -31,7 +31,8 @@ import java.io.IOException;
*/ */
public class DataSourceSupport { public class DataSourceSupport {
private File dataDirectory; private String dataDirectory = "activemq-data";
private File dataDirectoryFile;
private DataSource dataSource; private DataSource dataSource;
public DataSourceSupport() { public DataSourceSupport() {
@ -41,14 +42,22 @@ public class DataSourceSupport {
this.dataSource = dataSource; this.dataSource = dataSource;
} }
public File getDataDirectory() { public File getDataDirectoryFile() {
if (dataDirectory == null) { if (dataDirectoryFile == null) {
dataDirectory = new File("activemq-data"); dataDirectoryFile = new File(getDataDirectory());
} }
return dataDirectoryFile;
}
public void setDataDirectoryFile(File dataDirectory) {
this.dataDirectoryFile = dataDirectory;
}
public String getDataDirectory() {
return dataDirectory; return dataDirectory;
} }
public void setDataDirectory(File dataDirectory) { public void setDataDirectory(String dataDirectory) {
this.dataDirectory = dataDirectory; this.dataDirectory = dataDirectory;
} }
@ -69,7 +78,7 @@ public class DataSourceSupport {
protected DataSource createDataSource() throws IOException { protected DataSource createDataSource() throws IOException {
// Setup the Derby datasource. // Setup the Derby datasource.
System.setProperty("derby.system.home", getDataDirectory().getCanonicalPath()); System.setProperty("derby.system.home", getDataDirectoryFile().getCanonicalPath());
System.setProperty("derby.storage.fileSyncTransactionLog", "true"); System.setProperty("derby.storage.fileSyncTransactionLog", "true");
System.setProperty("derby.storage.pageCacheSize", "100"); System.setProperty("derby.storage.pageCacheSize", "100");

View File

@ -30,7 +30,7 @@ public class JDBCDurableSubscriptionTest extends DurableSubscriptionTestSupport
protected PersistenceAdapter createPersistenceAdapter() throws IOException { protected PersistenceAdapter createPersistenceAdapter() throws IOException {
File dataDir = new File("target/test-data/durableJDBC"); File dataDir = new File("target/test-data/durableJDBC");
DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory(); DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory();
factory.setDataDirectory(dataDir); factory.setDataDirectoryFile(dataDir);
factory.setUseJournal(false); factory.setUseJournal(false);
return factory.createPersistenceAdapter(); return factory.createPersistenceAdapter();
} }

View File

@ -30,7 +30,7 @@ public class JournalDurableSubscriptionTest extends DurableSubscriptionTestSuppo
protected PersistenceAdapter createPersistenceAdapter() throws IOException { protected PersistenceAdapter createPersistenceAdapter() throws IOException {
File dataDir = new File("target/test-data/durableJournal"); File dataDir = new File("target/test-data/durableJournal");
DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory(); DefaultPersistenceAdapterFactory factory = new DefaultPersistenceAdapterFactory();
factory.setDataDirectory(dataDir); factory.setDataDirectoryFile(dataDir);
factory.setUseJournal(true); factory.setUseJournal(true);
factory.setJournalLogFileSize(1024*64); factory.setJournalLogFileSize(1024*64);
return factory.createPersistenceAdapter(); return factory.createPersistenceAdapter();