diff -r 5d7d1adf387f -r f04253b2d6c1 src/org/sonews/storage/impl/HSQLDBProvider.java --- a/src/org/sonews/storage/impl/HSQLDBProvider.java Tue Jun 07 11:55:22 2011 +0200 +++ b/src/org/sonews/storage/impl/HSQLDBProvider.java Sun Oct 30 22:10:43 2011 +0100 @@ -17,6 +17,9 @@ */ package org.sonews.storage.impl; +import java.sql.SQLException; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.sonews.storage.Storage; import org.sonews.storage.StorageBackendException; import org.sonews.storage.StorageProvider; @@ -27,13 +30,28 @@ * @since sonews/1.1 */ public class HSQLDBProvider implements StorageProvider { + protected static final Map instances = + new ConcurrentHashMap(); + @Override public boolean isSupported(String uri) { return uri.startsWith("jdbc:hsqldb"); } + @Override public Storage storage(Thread thread) throws StorageBackendException { - throw new UnsupportedOperationException("Not supported yet."); + try { + if (!instances.containsKey(Thread.currentThread())) { + HSQLDB db = new HSQLDB(); + db.arise(); + instances.put(Thread.currentThread(), db); + return db; + } else { + return instances.get(Thread.currentThread()); + } + } catch (SQLException ex) { + throw new StorageBackendException(ex); + } } }