From bf8e41d70ef383b8018d74c9d3161eb0fa626792 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 24 Dec 2013 00:18:00 +0100 Subject: [PATCH] [New] Implemented CACHED mode for Strolch --- .../postgresql/PostgreSqlPersistenceHandler.java | 11 ++++++----- .../postgresql/dao/test/AbstractDaoImplTest.java | 6 +++--- .../resources/runtime/config/StrolchConfiguration.xml | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/li/strolch/persistence/postgresql/PostgreSqlPersistenceHandler.java b/src/main/java/li/strolch/persistence/postgresql/PostgreSqlPersistenceHandler.java index 1f282c61d..bf318aba7 100644 --- a/src/main/java/li/strolch/persistence/postgresql/PostgreSqlPersistenceHandler.java +++ b/src/main/java/li/strolch/persistence/postgresql/PostgreSqlPersistenceHandler.java @@ -27,8 +27,9 @@ import li.strolch.persistence.api.DbConnectionInfo; import li.strolch.persistence.api.OrderDao; import li.strolch.persistence.api.ResourceDao; import li.strolch.persistence.api.StrolchPersistenceException; -import li.strolch.persistence.api.StrolchPersistenceHandler; +import li.strolch.persistence.api.PersistenceHandler; import li.strolch.persistence.api.StrolchTransaction; +import li.strolch.runtime.StrolchConstants; import li.strolch.runtime.agent.ComponentContainerImpl; import li.strolch.runtime.agent.StrolchComponent; import li.strolch.runtime.configuration.ComponentConfiguration; @@ -38,7 +39,7 @@ import li.strolch.runtime.observer.ObserverHandler; /** * @author Robert von Burg */ -public class PostgreSqlPersistenceHandler extends StrolchComponent implements StrolchPersistenceHandler { +public class PostgreSqlPersistenceHandler extends StrolchComponent implements PersistenceHandler { private static final String PROP_DB_URL = "db.url"; //$NON-NLS-1$ private static final String PROP_DB_USERNAME = "db.username"; //$NON-NLS-1$ @@ -70,10 +71,10 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements St throw new StrolchConfigurationException(msg, e); } - DbConnectionInfo connectionInfo = new DbConnectionInfo(StrolchTransaction.DEFAULT_REALM, dbUrl); + DbConnectionInfo connectionInfo = new DbConnectionInfo(StrolchConstants.DEFAULT_REALM, dbUrl); connectionInfo.setUsername(username); connectionInfo.setPassword(password); - this.connetionInfoMap.put(StrolchTransaction.DEFAULT_REALM, connectionInfo); + this.connetionInfoMap.put(StrolchConstants.DEFAULT_REALM, connectionInfo); String compliant = driver.jdbcCompliant() ? "" : "non"; //$NON-NLS-1$ //$NON-NLS-2$ String msg = "Using {0} JDBC compliant Driver {1}.{2}"; //$NON-NLS-1$ @@ -98,7 +99,7 @@ public class PostgreSqlPersistenceHandler extends StrolchComponent implements St } public StrolchTransaction openTx() { - return openTx(StrolchTransaction.DEFAULT_REALM); + return openTx(StrolchConstants.DEFAULT_REALM); } public StrolchTransaction openTx(String realm) { diff --git a/src/test/java/li/strolch/persistence/postgresql/dao/test/AbstractDaoImplTest.java b/src/test/java/li/strolch/persistence/postgresql/dao/test/AbstractDaoImplTest.java index 3a2d5c7d5..5dd287cfb 100644 --- a/src/test/java/li/strolch/persistence/postgresql/dao/test/AbstractDaoImplTest.java +++ b/src/test/java/li/strolch/persistence/postgresql/dao/test/AbstractDaoImplTest.java @@ -20,7 +20,7 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; -import li.strolch.persistence.api.StrolchPersistenceHandler; +import li.strolch.persistence.api.PersistenceHandler; import li.strolch.persistence.postgresql.DbSchemaVersionCheck; import li.strolch.testbase.runtime.RuntimeMock; @@ -39,7 +39,7 @@ public abstract class AbstractDaoImplTest extends RuntimeMock { private static final String RUNTIME_PATH = "target/strolchRuntime/"; //$NON-NLS-1$ private static final String DB_STORE_PATH_DIR = "dbStore"; //$NON-NLS-1$ private static final String CONFIG_SRC = "src/test/resources/runtime/config"; //$NON-NLS-1$ - protected static StrolchPersistenceHandler persistenceHandler; + protected static PersistenceHandler persistenceHandler; @BeforeClass public static void beforeClass() throws SQLException { @@ -53,7 +53,7 @@ public abstract class AbstractDaoImplTest extends RuntimeMock { RuntimeMock.startContainer(rootPath); // initialize the component configuration - persistenceHandler = getContainer().getComponent(StrolchPersistenceHandler.class); + persistenceHandler = getContainer().getComponent(PersistenceHandler.class); } private static void dropSchema() throws SQLException { diff --git a/src/test/resources/runtime/config/StrolchConfiguration.xml b/src/test/resources/runtime/config/StrolchConfiguration.xml index 26f7d59b0..71989f732 100644 --- a/src/test/resources/runtime/config/StrolchConfiguration.xml +++ b/src/test/resources/runtime/config/StrolchConfiguration.xml @@ -3,13 +3,13 @@ StrolchPersistenceTest - EMPTY + CACHED true PersistenceHandler - li.strolch.persistence.api.StrolchPersistenceHandler + li.strolch.persistence.api.PersistenceHandler li.strolch.persistence.postgresql.PostgreSqlPersistenceHandler true