diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2012-05-08 18:05:40 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2012-05-08 18:05:40 +0000 |
| commit | 8f3a8dcf26af5a39411522faa995918714d1c062 (patch) | |
| tree | 4c8372b62b81c3f914d967132cf81d2d1712262a /java/broker | |
| parent | 112449fdbbb559a007907c2f28f569e818ef4a05 (diff) | |
| download | qpid-python-8f3a8dcf26af5a39411522faa995918714d1c062.tar.gz | |
QPID-3989 : [Java Broker] Add ability to run "in-memory" Derby store
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1335667 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/broker')
| -rw-r--r-- | java/broker/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/java/broker/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java b/java/broker/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java index 480da2246c..de1ce1a9db 100644 --- a/java/broker/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java +++ b/java/broker/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStore.java @@ -112,6 +112,7 @@ public class DerbyMessageStore implements MessageStore private static Class<Driver> DRIVER_CLASS; + public static final String MEMORY_STORE_LOCATION = ":memory:"; private final AtomicLong _messageId = new AtomicLong(0); private AtomicBoolean _closed = new AtomicBoolean(false); @@ -302,13 +303,16 @@ public class DerbyMessageStore implements MessageStore final String databasePath = storeConfiguration.getString(MessageStoreConstants.ENVIRONMENT_PATH_PROPERTY, System.getProperty("QPID_WORK") + File.separator + "derbyDB"); - File environmentPath = new File(databasePath); - if (!environmentPath.exists()) + if(!MEMORY_STORE_LOCATION.equals(databasePath)) { - if (!environmentPath.mkdirs()) + File environmentPath = new File(databasePath); + if (!environmentPath.exists()) { - throw new IllegalArgumentException("Environment path " + environmentPath + " could not be read or created. " - + "Ensure the path is correct and that the permissions are correct."); + if (!environmentPath.mkdirs()) + { + throw new IllegalArgumentException("Environment path " + environmentPath + " could not be read or created. " + + "Ensure the path is correct and that the permissions are correct."); + } } } @@ -345,7 +349,7 @@ public class DerbyMessageStore implements MessageStore private void createOrOpenDatabase(String name, final String environmentPath) throws SQLException { //FIXME this the _vhost name should not be added here, but derby wont use an empty directory as was possibly just created. - _connectionURL = "jdbc:derby:" + environmentPath + "/" + name + ";create=true"; + _connectionURL = "jdbc:derby" + (environmentPath.equals(MEMORY_STORE_LOCATION) ? environmentPath : ":" + environmentPath + "/") + name + ";create=true"; Connection conn = newAutoCommitConnection(); |
