Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.

Commit

Permalink
#41: disable calling DomainHandler.createTable()
Browse files Browse the repository at this point in the history
  • Loading branch information
kovax committed Dec 30, 2018
1 parent 04af641 commit 1cb92d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
*/
package org.cristalise.storage.jooqdb;

import static org.cristalise.storage.jooqdb.JooqHandler.JOOQ_DOMAIN_HANDLERS;
import static org.cristalise.storage.jooqdb.JooqHandler.JOOQ_AUTOCOMMIT;
import static org.cristalise.storage.jooqdb.JooqHandler.JOOQ_DISABLE_DOMAIN_CREATE;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -62,7 +66,7 @@ public class JooqClusterStorage extends TransactionalClusterStorage {
public void open(Authenticator auth) throws PersistencyException {
context = JooqHandler.connect();

autoCommit = Gateway.getProperties().getBoolean(JooqHandler.JOOQ_AUTOCOMMIT, false);
autoCommit = Gateway.getProperties().getBoolean(JOOQ_AUTOCOMMIT, false);

initialiseHandlers();
}
Expand All @@ -87,7 +91,7 @@ public void initialiseHandlers() throws PersistencyException {
for (JooqHandler handler: jooqHandlers.values()) handler.createTables(context);

try {
String handlers = Gateway.getProperties().getString(JooqHandler.JOOQ_DOMAIN_HANDLERS, "");
String handlers = Gateway.getProperties().getString(JOOQ_DOMAIN_HANDLERS, "");

for(String handlerClass: StringUtils.split(handlers, ",")) {
if (!handlerClass.contains(".")) handlerClass = "org.cristalise.storage."+handlerClass;
Expand All @@ -103,7 +107,9 @@ public void initialiseHandlers() throws PersistencyException {
throw new PersistencyException("JooqClusterStorage could not instantiate domain handler:"+ex.getMessage());
}

for (JooqDomainHandler handler: domainHandlers) handler.createTables(context);
if (! Gateway.getProperties().getBoolean(JOOQ_DISABLE_DOMAIN_CREATE, false)) {
for (JooqDomainHandler handler: domainHandlers) handler.createTables(context);
}
}

@Override
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/cristalise/storage/jooqdb/JooqHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.jooq.impl.DSL.select;
import static org.jooq.impl.DSL.using;

import java.sql.Blob;
import java.sql.DriverManager;
import java.sql.Timestamp;
import java.util.Arrays;
Expand Down Expand Up @@ -74,6 +73,11 @@ public abstract class JooqHandler {
* fully qualified class names implementing the {@link JooqDomainHandler} interface.
*/
public static final String JOOQ_DOMAIN_HANDLERS = "JOOQ.domainHandlers";
/**
* Defines the key (value:{@value}) to retrieve the boolean value to disable the invocation of
* {@link JooqDomainHandler#createTables(DSLContext)}. Default is 'false'
*/
public static final String JOOQ_DISABLE_DOMAIN_CREATE = "JOOQ.disableDomainCreateTables";

public static final DataType<UUID> UUID_TYPE = SQLDataType.UUID;
public static final DataType<String> NAME_TYPE = SQLDataType.VARCHAR.length(64);
Expand Down

0 comments on commit 1cb92d7

Please sign in to comment.