ALF-9258: Bootstrapping of schema now done in seperate (disposable) engine, using a bare connection instead of one from the datasource + jobexecutor startup delayed untill SchemaAvailableEvent

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29865 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Frederik Heremans
2011-08-18 11:41:19 +00:00
parent 27dfd5ab17
commit b5d8e12577
3 changed files with 394 additions and 4 deletions

View File

@@ -26,12 +26,23 @@ import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Writer;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
@@ -791,8 +802,8 @@ public class SchemaBootstrap extends AbstractLifecycleBean
checkSchemaPatchScripts(cfg, connection, postUpdateScriptPatches, true);
}
// initialise Activiti
// initialiseActivitiDBSchema(connection);
// Initialise Activiti DB, using an unclosable connection
initialiseActivitiDBSchema(new UnclosableConnection(connection));
return create;
}
@@ -813,6 +824,8 @@ public class SchemaBootstrap extends AbstractLifecycleBean
// build the engine
engine = engineConfig.setDataSource(dataSource).
setDatabaseSchemaUpdate("none").
setProcessEngineName("activitiBootstrapEngine").
setHistory("full").
setJobExecutorActivate(false).
buildProcessEngine();
@@ -1677,4 +1690,323 @@ public class SchemaBootstrap extends AbstractLifecycleBean
return false;
}
}
/**
* A {@link Connection} wrapper that delegates all calls to the wrapped class
* except for the close methods, which are ignored.
*
* @author Frederik Heremans
*/
public class UnclosableConnection implements Connection {
private Connection wrapped;
public UnclosableConnection(Connection wrappedConnection)
{
this.wrapped = wrappedConnection;
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException
{
return wrapped.isWrapperFor(iface);
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException
{
return wrapped.unwrap(iface);
}
@Override
public void clearWarnings() throws SQLException
{
wrapped.clearWarnings();
}
@Override
public void close() throws SQLException
{
// Ignore this call
}
@Override
public void commit() throws SQLException
{
wrapped.commit();
}
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
{
return wrapped.createArrayOf(typeName, elements);
}
@Override
public Blob createBlob() throws SQLException
{
return wrapped.createBlob();
}
@Override
public Clob createClob() throws SQLException
{
return wrapped.createClob();
}
@Override
public NClob createNClob() throws SQLException
{
return wrapped.createNClob();
}
@Override
public SQLXML createSQLXML() throws SQLException
{
return wrapped.createSQLXML();
}
@Override
public Statement createStatement() throws SQLException
{
return wrapped.createStatement();
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency)
throws SQLException
{
return wrapped.createStatement(resultSetType, resultSetConcurrency);
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency,
int resultSetHoldability) throws SQLException
{
return wrapped.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
}
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
{
return wrapped.createStruct(typeName, attributes);
}
@Override
public boolean getAutoCommit() throws SQLException
{
return wrapped.getAutoCommit();
}
@Override
public String getCatalog() throws SQLException
{
return wrapped.getCatalog();
}
@Override
public Properties getClientInfo() throws SQLException
{
return wrapped.getClientInfo();
}
@Override
public String getClientInfo(String name) throws SQLException
{
return wrapped.getClientInfo(name);
}
@Override
public int getHoldability() throws SQLException
{
return wrapped.getHoldability();
}
@Override
public DatabaseMetaData getMetaData() throws SQLException
{
return wrapped.getMetaData();
}
@Override
public int getTransactionIsolation() throws SQLException
{
return wrapped.getTransactionIsolation();
}
@Override
public Map<String, Class<?>> getTypeMap() throws SQLException
{
return wrapped.getTypeMap();
}
@Override
public SQLWarning getWarnings() throws SQLException
{
return wrapped.getWarnings();
}
@Override
public boolean isClosed() throws SQLException
{
return wrapped.isClosed();
}
@Override
public boolean isReadOnly() throws SQLException
{
return wrapped.isReadOnly();
}
@Override
public boolean isValid(int timeout) throws SQLException
{
return wrapped.isValid(timeout);
}
@Override
public String nativeSQL(String sql) throws SQLException
{
return wrapped.nativeSQL(sql);
}
@Override
public CallableStatement prepareCall(String sql) throws SQLException
{
return wrapped.prepareCall(sql);
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
throws SQLException
{
return wrapped.prepareCall(sql, resultSetType, resultSetConcurrency);
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType,
int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return wrapped.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
}
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException
{
return wrapped.prepareStatement(sql);
}
@Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException
{
return wrapped.prepareStatement(sql, autoGeneratedKeys);
}
@Override
public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
throws SQLException
{
return wrapped.prepareStatement(sql, columnIndexes);
}
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames)
throws SQLException
{
return wrapped.prepareStatement(sql, columnNames);
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency) throws SQLException
{
return wrapped.prepareStatement(sql, resultSetType, resultSetConcurrency);
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
return wrapped.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
}
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException
{
wrapped.releaseSavepoint(savepoint);
}
@Override
public void rollback() throws SQLException
{
wrapped.rollback();
}
@Override
public void rollback(Savepoint savepoint) throws SQLException
{
wrapped.rollback(savepoint);
}
@Override
public void setAutoCommit(boolean autoCommit) throws SQLException
{
wrapped.setAutoCommit(autoCommit);
}
@Override
public void setCatalog(String catalog) throws SQLException
{
wrapped.setCatalog(catalog);
}
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException
{
wrapped.setClientInfo(properties);
}
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException
{
wrapped.setClientInfo(name, value);
}
@Override
public void setHoldability(int holdability) throws SQLException
{
wrapped.setHoldability(holdability);
}
@Override
public void setReadOnly(boolean readOnly) throws SQLException
{
wrapped.setReadOnly(readOnly);
}
@Override
public Savepoint setSavepoint() throws SQLException
{
return wrapped.setSavepoint();
}
@Override
public Savepoint setSavepoint(String name) throws SQLException
{
return wrapped.setSavepoint(name);
}
@Override
public void setTransactionIsolation(int level) throws SQLException
{
wrapped.setTransactionIsolation(level);
}
@Override
public void setTypeMap(Map<String, Class<?>> map) throws SQLException
{
wrapped.setTypeMap(map);
}
}
}