From 31bd1363478cb1c618f406e3eb493f9922dfd91d Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Tue, 5 Feb 2013 09:28:34 +0100
Subject: [PATCH] OO-538: remove unused code, unused listeners and update
 readme

---
 .../cluster/PLockSyncCoordinator.java         | 150 -------------
 .../cluster/lock/ClusterLockManager.java      |  27 ++-
 .../org/olat/core/commons/persistence/DB.java |  22 +-
 .../olat/core/commons/persistence/DBImpl.java | 129 -----------
 .../commons/persistence/DatabaseSetup.java    | 205 ------------------
 .../persistence/ITransactionListener.java     |  41 ----
 src/main/resources/database/readme.txt        |   5 +-
 7 files changed, 17 insertions(+), 562 deletions(-)
 delete mode 100644 src/main/java/org/olat/commons/coordinate/cluster/PLockSyncCoordinator.java
 delete mode 100644 src/main/java/org/olat/core/commons/persistence/DatabaseSetup.java
 delete mode 100644 src/main/java/org/olat/core/commons/persistence/ITransactionListener.java

diff --git a/src/main/java/org/olat/commons/coordinate/cluster/PLockSyncCoordinator.java b/src/main/java/org/olat/commons/coordinate/cluster/PLockSyncCoordinator.java
deleted file mode 100644
index 812b1fd50da..00000000000
--- a/src/main/java/org/olat/commons/coordinate/cluster/PLockSyncCoordinator.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/**
-* OLAT - Online Learning and Training<br>
-* http://www.olat.org
-* <p>
-* Licensed under the Apache License, Version 2.0 (the "License"); <br>
-* you may not use this file except in compliance with the License.<br>
-* You may obtain a copy of the License at
-* <p>
-* http://www.apache.org/licenses/LICENSE-2.0
-* <p>
-* Unless required by applicable law or agreed to in writing,<br>
-* software distributed under the License is distributed on an "AS IS" BASIS, <br>
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
-* See the License for the specific language governing permissions and <br>
-* limitations under the License.
-* <p>
-* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
-* University of Zurich, Switzerland.
-* <hr>
-* <a href="http://www.openolat.org">
-* OpenOLAT - Online Learning and Training</a><br>
-* This file has been modified by the OpenOLAT community. Changes are licensed
-* under the Apache 2.0 license as the original file.
-*/
-package org.olat.commons.coordinate.cluster;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.olat.core.commons.persistence.DB;
-import org.olat.core.commons.persistence.DBFactory;
-import org.olat.core.commons.persistence.ITransactionListener;
-
-/**
- * ThreadLock - Object 
- * responsible for the coordination of synchronized(syncObj),
- * findOrPersistPLock and DB.commit/DB.rollback.
- * <p>
- * Main raison d'etre of this class is the following problem:
- * <ul>
- *  <li>Thread A enters the doInSync block</li>
- *  <li>Thread A aquires plock of OLATResourceable-1</li>
- *  <li>Thread A leaves the doInSync block</li>
- *  <li>Thread B enters the doInSync block</li>
- *  <li>Thread B wants to aquire plock of OLATResourceable-1 but needs to wait since Thread A hasn't committed or rolled back yet</li>
- *  <li>Thread A (still uncommitted) enters the doInSync block again (what a nasty boy) but cannot enter the synchronized block since Thread B owns it</li>
- *  <li>hence we have a deadlock between a VM-Object-monitor and the Database</li>
- * </ul>
- * There are multiple ways of fixing this including the following:
- * <ul>
- *  <li>Introduced the long discussed ManagedBlock which would at the highest possible level manage
- *      transactions - i.e. only if a thread is inside a ManagedBlock (which can be assured via a ThreadLocal flag
- *      which the ManagedBlock can set) can any Database access be done - all other Database access would
- *      throw an AssertionError. The ManagedBlock would also do the actual commit - thus releasing any
- *      PLocks. The ManagedBlock could then take notice of the fact that a thread acquired the PLock
- *		and hasn't released it yet (also known as 'VM-side-plock-hashmap'). When another thread in 
- *      another ManagedBlock would want to acquire a PLock, the ManagedBlock could make sure that it
- *      doesn't hold the synchronization objct while waiting for the PLock - instead it could wait
- *      on a ManagedBlock side synchronization object or any other suitable thing.<br>
- *      The downside of the ManagedBlock is that its introduction into OLAT would require changes in 
- *      many places and is hence not the cheapest solution. Also, if the plock-synchronization coordination
- *      is the only reason for the ManagedBlock then it might be overkill.</li>
- *  <li>Make sure that the monitor on the DerivedStringSyncer's syncobj is not held while waiting for
- *      the plock - at least not if the plock is held by the same VM. This requires additional knowledge
- *      of which plocks are currently held in the VM. And that's exactly the job of this new PLockSyncCoordinator</li>
- * </ul>
- * The PLockSyncCoordinator keeps track of each plock that is acquired - by being informed by the 
- * ClusterSyncer about acquisition and by being informed by the DBImpl (via the newly introduced
- * ITransactionListener) about commit or rollbacks. As it 
- * <P>
- * Initial Date:  19.08.2008 <br>
- * @author Stefan
- */
-public class PLockSyncCoordinator implements ITransactionListener {
-
-	private static final Map<String,PLockSyncCoordinator> plocks_ = new HashMap<String, PLockSyncCoordinator>();
-	
-	private final Set<String> acquiredPLocks_ = new HashSet<String>();
-	
-	private final Thread th_;
-	
-	public PLockSyncCoordinator() {
-		th_ = Thread.currentThread();
-	}
-	
-	public void plockAcquiring(String asset) {
-		org.olat.core.logging.Tracing.logWarn("plockAcquiring("+asset+") check... ", this.getClass());
-		// look in the vm-wide plocks_ map first - as this is more common
-		synchronized(plocks_) {
-			while(true) {
-				PLockSyncCoordinator coordinator = plocks_.get(asset);
-				if (coordinator==this) {
-					// then we already acquired the plock. nothing more to do
-					return;
-				} else if (coordinator==null) {
-					// great, you're the only one in this VM to grab this plock - go ahead!
-					org.olat.core.logging.Tracing.logWarn("plockAcquiring("+asset+") OK ", this.getClass());
-					acquiredPLocks_.add(asset);
-					plocks_.put(asset, this);
-					DBFactory.getInstance(false).addTransactionListener(this);
-					return;
-				} else {
-					org.olat.core.logging.Tracing.logWarn("waitForAssetReleased("+asset+")", this.getClass());
-					try {
-						plocks_.wait(250);
-					} catch (InterruptedException e) {
-						// ignore
-					}
-				}
-			}
-		}
-	}
-
-	private void clearAllPLocks(DB db) {
-		org.olat.core.logging.Tracing.logWarn("clearAllPLocks()", this.getClass());
-		db.removeTransactionListener(this);
-		synchronized(plocks_) {
-			for (Iterator<String> it = acquiredPLocks_.iterator(); it.hasNext();) {
-				String asset = it.next();
-				org.olat.core.logging.Tracing.logWarn("clearAllPLocks: "+asset+" ...", this.getClass());
-
-				PLockSyncCoordinator coordinator = plocks_.remove(asset);
-				if (coordinator!=this) {
-					// then houston we have a problem
-					org.olat.core.logging.Tracing.logError("clearAllPLocks: "+asset+" HAD WRONG COORDINATOR!!!!! wanted "+this+" had "+coordinator, this.getClass());
-				}
-			}
-			acquiredPLocks_.clear();
-			plocks_.notifyAll();
-		}
-	}
-	
-	public void handleCommit(DB db) {
-		if (th_!=Thread.currentThread()) {
-			org.olat.core.logging.Tracing.logError("handleCommit: WRONG THREAD...!!!!! wanted "+th_+" had "+Thread.currentThread(), this.getClass());
-		}
-		clearAllPLocks(db);
-	}
-
-	public void handleRollback(DB db) {
-		if (th_!=Thread.currentThread()) {
-			org.olat.core.logging.Tracing.logError("handleCommit: WRONG THREAD...!!!!! wanted "+th_+" had "+Thread.currentThread(), this.getClass());
-		}
-		clearAllPLocks(db);
-	}
-
-}
diff --git a/src/main/java/org/olat/commons/coordinate/cluster/lock/ClusterLockManager.java b/src/main/java/org/olat/commons/coordinate/cluster/lock/ClusterLockManager.java
index 3ff39b28efd..1bd69c58a50 100644
--- a/src/main/java/org/olat/commons/coordinate/cluster/lock/ClusterLockManager.java
+++ b/src/main/java/org/olat/commons/coordinate/cluster/lock/ClusterLockManager.java
@@ -30,6 +30,7 @@ import org.hibernate.type.StandardBasicTypes;
 import org.olat.core.commons.persistence.DBFactory;
 import org.olat.core.commons.persistence.DBQuery;
 import org.olat.core.id.Identity;
+import org.olat.core.logging.OLog;
 import org.olat.core.logging.Tracing;
 import org.olat.core.manager.BasicManager;
 
@@ -45,6 +46,8 @@ import org.olat.core.manager.BasicManager;
 public class ClusterLockManager extends BasicManager {
 	private static ClusterLockManager INSTANCE;
 	
+	private static final OLog log = Tracing.createLoggerFor(ClusterLockManager.class);
+	
 	/**
 	 * [spring]
 	 */
@@ -61,44 +64,44 @@ public class ClusterLockManager extends BasicManager {
 	}
 	
 	LockImpl findLock(String asset) {
-		Tracing.logInfo("findLock: "+asset+" START", getClass());
+		log.info("findLock: "+asset+" START");
 		DBQuery q = DBFactory.getInstance().createQuery(
 				"select alock from org.olat.commons.coordinate.cluster.lock.LockImpl as alock inner join fetch alock.owner where alock.asset = :asset");
 		q.setParameter("asset", asset);
 		List res = q.list();
 		if (res.size() == 0) {
-			Tracing.logInfo("findLock: null END", getClass());
+			log.info("findLock: null END");
 			return null; 
 		} else {
-			Tracing.logInfo("findLock: "+res.get(0)+" END", getClass());
+			log.info("findLock: "+res.get(0)+" END");
 			return (LockImpl) res.get(0);
 		}
 	}
 		
 	LockImpl createLockImpl(String asset, Identity owner) {
-		Tracing.logInfo("createLockImpl: "+asset+" by "+ owner, getClass());
+		log.info("createLockImpl: "+asset+" by "+ owner);
 		return new LockImpl(asset, owner);
 	}
 	
 	void saveLock(LockImpl alock) {
-		Tracing.logInfo("saveLock: "+alock+" START", getClass());
+		log.info("saveLock: "+alock+" START");
 		DBFactory.getInstance().saveObject(alock);
-		Tracing.logInfo("saveLock: "+alock+" END", getClass());
+		log.info("saveLock: "+alock+" END");
 	}
 
 	void deleteLock(LockImpl li) {
-		Tracing.logInfo("deleteLock: "+li+" START", getClass());
+		log.info("deleteLock: "+li+" START");
 		DBFactory.getInstance().deleteObject(li);		
-		Tracing.logInfo("deleteLock: "+li+" END", getClass());
+		log.info("deleteLock: "+li+" END");
 	}
 	
 	@SuppressWarnings("unchecked")
 	List<LockImpl> getAllLocks() {
-		Tracing.logInfo("getAllLocks START", getClass());
+		log.info("getAllLocks START");
 		DBQuery q = DBFactory.getInstance().createQuery(
 				"select alock from org.olat.commons.coordinate.cluster.lock.LockImpl as alock inner join fetch alock.owner");
 		List<LockImpl> res = q.list();
-		Tracing.logInfo("getAllLocks END. res.length:"+ (res==null ? "null" : res.size()), getClass());
+		log.info("getAllLocks END. res.length:"+ (res==null ? "null" : res.size()));
 		return res;
 	}
 
@@ -106,12 +109,12 @@ public class ClusterLockManager extends BasicManager {
 	 * @param identName the name of the identity to release all locks for (only the non-persistent locks in cluster mode, -not- the persistent locks!)
 	 */
 	public void releaseAllLocksFor(Long identityKey) {
-		Tracing.logInfo("releaseAllLocksFor: " + identityKey + " START", getClass());	
+		log.info("releaseAllLocksFor: " + identityKey + " START");	
 		DBFactory.getInstance().delete("from org.olat.commons.coordinate.cluster.lock.LockImpl as alock inner join fetch " +
 				"alock.owner as owner where owner.key = ?", identityKey, StandardBasicTypes.LONG);
 		// cluster:: can we save a query (and is it appropriate considering encapsulation) 
 		// here by saying: alock.owner as owner where owner.name = ? (using identName parameter)
-		Tracing.logInfo("releaseAllLocksFor: "+identityKey+" END", getClass());
+		log.info("releaseAllLocksFor: "+identityKey+" END");
 	}
 
 }
diff --git a/src/main/java/org/olat/core/commons/persistence/DB.java b/src/main/java/org/olat/core/commons/persistence/DB.java
index 0798c848fb0..8e029be40dd 100644
--- a/src/main/java/org/olat/core/commons/persistence/DB.java
+++ b/src/main/java/org/olat/core/commons/persistence/DB.java
@@ -37,27 +37,7 @@ import org.olat.core.id.Persistable;
 public interface DB {
 
 	/** temp debug only **/
-	public void forceSetDebugLogLevel(boolean enabled);
-	
-	/**
-	 * Add an ITransactionListener to this DB instance.
-	 * <p>
-	 * The ITransactionListener will be informed about commit and rollbacks.
-	 * <p>
-	 * Adding the same listener twice has no effect.
-	 * <p>
-	 * @param listener the listener to be added
-	 */
-	public void addTransactionListener(ITransactionListener listener);
-
-	/**
-	 * Removes an ITransactionListener from this DB instance.
-	 * <p>
-	 * If the ITransactionListener is currently not registered, this call
-	 * has no effect.
-	 * @param listener
-	 */
-	public void removeTransactionListener(ITransactionListener listener);
+	//public void forceSetDebugLogLevel(boolean enabled);
 	
 	/**
 	 * Close the database session.
diff --git a/src/main/java/org/olat/core/commons/persistence/DBImpl.java b/src/main/java/org/olat/core/commons/persistence/DBImpl.java
index ea55dcd7936..b8c356d4c56 100644
--- a/src/main/java/org/olat/core/commons/persistence/DBImpl.java
+++ b/src/main/java/org/olat/core/commons/persistence/DBImpl.java
@@ -30,11 +30,8 @@ import java.sql.Driver;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Enumeration;
-import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.MBeanRegistrationException;
@@ -58,7 +55,6 @@ import org.olat.core.id.Persistable;
 import org.olat.core.logging.AssertException;
 import org.olat.core.logging.DBRuntimeException;
 import org.olat.core.logging.LogDelegator;
-import org.olat.core.logging.OLog;
 import org.olat.core.logging.Tracing;
 import org.olat.testutils.codepoints.server.Codepoint;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -78,7 +74,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 	private EntityManagerFactory emf = null;
 
 	private final ThreadLocal<ThreadLocalData> data = new ThreadLocal<ThreadLocalData>();
-	private OLog forcedLogger;
 	// Max value for commit-counter, values over this limit will be logged.
 	private static int maxCommitCounter = 10;
 
@@ -103,9 +98,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 		private int accessCounter = 0;
 		// count number of commit in db-session, used to log warn 'Call more than one commit in a db-session'
 		private int commitCounter = 0;
-
-		// transaction listeners
-		private Set<ITransactionListener> transactionListeners_ = null;
 		
 		private ThreadLocalData() {
 		// don't let any other class instantiate ThreadLocalData.
@@ -152,51 +144,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 
 		protected void resetCommitCounter() {
 			this.commitCounter = 0;
-		}	
-		
-		protected void addTransactionListener(ITransactionListener txListener) {
-			if (transactionListeners_==null) {
-				transactionListeners_ = new HashSet<ITransactionListener>();
-			}
-			transactionListeners_.add(txListener);
-		}
-		
-		protected void removeTransactionListener(ITransactionListener txListener) {
-			if (transactionListeners_==null) {
-				// can't remove then - never mind
-				return;
-			}
-			transactionListeners_.remove(txListener);
-		}
-		
-		protected void handleCommit(DB db) {
-			if (transactionListeners_==null) {
-				//  nobody to be notified
-				return;
-			}
-			for (Iterator<ITransactionListener> it = transactionListeners_.iterator(); it.hasNext();) {
-				ITransactionListener listener = it.next();
-				try{
-					listener.handleCommit(db);
-				} catch(Exception e) {
-					logWarn("ITransactionListener threw exception in handleCommit:", e);
-				}
-			}
-		}
-
-		protected void handleRollback(DB db) {
-			if (transactionListeners_==null) {
-				//  nobody to be notified
-				return;
-			}
-			for (Iterator<ITransactionListener> it = transactionListeners_.iterator(); it.hasNext();) {
-				ITransactionListener listener = it.next();
-				try{
-					listener.handleRollback(db);
-				} catch(Exception e) {
-					logWarn("ITransactionListener threw exception in hanldeRollback:", e);
-				}
-			}
 		}
 	}
 
@@ -301,7 +248,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 			if (Settings.isJUnitTest()) {
 				if (isLogDebugEnabled()) logDebug("Call commit", null);
 				getTransaction().commit(); 
-				getData().handleCommit(this);
 			} else {
 				if (isLogDebugEnabled()) logDebug("Call commit", null);
 				throw new AssertException("Close db-session with un-committed transaction");
@@ -692,7 +638,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 					}
 				}
 				getTransaction().commit();
-				getData().handleCommit(this);
 				if (isLogDebugEnabled()) logDebug("Commit DONE hasTransaction()=" + hasTransaction(), null);
 			} else {
 				if (isLogDebugEnabled()) logDebug("Call commit without starting transaction", null );
@@ -709,7 +654,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 			try {
 				if (hasTransaction() && !getTransaction().isRolledBack()) {
 					getTransaction().rollback();
-					getData().handleRollback(this);
 				}
 			} catch (Error er) {
 				logError("Uncaught Error in DBImpl.commit.catch(Exception).", er);
@@ -733,7 +677,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 			if (isConnectionOpen() && hasTransaction() && getTransaction().isInTransaction() ) {
 				if (isLogDebugEnabled()) logDebug("Call rollback", null);
 				getTransaction().rollback();
-				getData().handleRollback(this);
 			}
 		} catch (Exception ex) {
 			logWarn("Could not rollback transaction!",ex);
@@ -787,17 +730,8 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 	 */
 	public void intermediateCommit() {
 		this.commit();
-		getData().handleCommit(this);
 		this.closeSession();
 	}
-	
-	public void addTransactionListener(ITransactionListener listener) {
-		getData().addTransactionListener(listener);
-	}
-	
-	public void removeTransactionListener(ITransactionListener listener) {
-		getData().removeTransactionListener(listener);
-	}
 
 	/**
 	 * @see org.olat.core.commons.persistence.DB#needsCommit()
@@ -807,69 +741,6 @@ public class DBImpl extends LogDelegator implements DB, Destroyable {
 		// we check if the connection is open at this stage at all
 		return isConnectionOpen() && hasTransaction() && !getTransaction().isRolledBack() && getTransaction().isInTransaction();
 	}
-
-	/** temp debug only **/
-	public void forceSetDebugLogLevel(boolean enabled) {
-		if (!enabled) {
-			forcedLogger = null;
-			return;
-		}
-		forcedLogger = new OLog() {
-
-			public void audit(String logMsg) {
-				Tracing.logAudit(logMsg, DBImpl.class);
-			}
-
-			public void audit(String logMsg, String userObj) {
-				Tracing.logAudit(logMsg, userObj, DBImpl.class);
-			}
-
-			public void debug(String logMsg, String userObj) {
-				Tracing.logInfo(logMsg, userObj, DBImpl.class);
-			}
-
-			public void debug(String logMsg) {
-				Tracing.logInfo(logMsg, DBImpl.class);
-			}
-
-			public void error(String logMsg, Throwable cause) {
-				Tracing.logError(logMsg, cause, DBImpl.class);
-			}
-
-			public void error(String logMsg) {
-				Tracing.logError(logMsg, DBImpl.class);
-			}
-
-			public void info(String logMsg, String userObject) {
-				Tracing.logInfo(logMsg, userObject, DBImpl.class);
-			}
-
-			public void info(String logMsg) {
-				Tracing.logInfo(logMsg, DBImpl.class);
-			}
-
-			public boolean isDebug() {
-				return true;
-			}
-
-			public void warn(String logMsg, Throwable cause) {
-				Tracing.logWarn(logMsg, cause, DBImpl.class);
-			}
-
-			public void warn(String logMsg) {
-				Tracing.logWarn(logMsg, DBImpl.class);
-			}
-			
-		};
-	}
-	
-	protected OLog getLogger() {
-		if (forcedLogger==null) {
-			return super.getLogger();
-		} else {
-			return forcedLogger;
-		}
-	}
 	
 	/**
 	 * [used by spring]
diff --git a/src/main/java/org/olat/core/commons/persistence/DatabaseSetup.java b/src/main/java/org/olat/core/commons/persistence/DatabaseSetup.java
deleted file mode 100644
index 64de522614d..00000000000
--- a/src/main/java/org/olat/core/commons/persistence/DatabaseSetup.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/**
-* OLAT - Online Learning and Training<br>
-* http://www.olat.org
-* <p>
-* Licensed under the Apache License, Version 2.0 (the "License"); <br>
-* you may not use this file except in compliance with the License.<br>
-* You may obtain a copy of the License at
-* <p>
-* http://www.apache.org/licenses/LICENSE-2.0
-* <p>
-* Unless required by applicable law or agreed to in writing,<br>
-* software distributed under the License is distributed on an "AS IS" BASIS, <br>
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
-* See the License for the specific language governing permissions and <br>
-* limitations under the License.
-* <p>
-* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
-* University of Zurich, Switzerland.
-* <hr>
-* <a href="http://www.openolat.org">
-* OpenOLAT - Online Learning and Training</a><br>
-* This file has been modified by the OpenOLAT community. Changes are licensed
-* under the Apache 2.0 license as the original file.  
-* <p>
-*/ 
-
-package org.olat.core.commons.persistence;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hibernate.MappingException;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
-import org.hibernate.tool.hbm2ddl.SchemaUpdate;
-import org.olat.core.CoreSpringFactory;
-import org.olat.core.logging.AssertException;
-import org.olat.core.logging.OLog;
-import org.olat.core.logging.Tracing;
-import org.springframework.core.io.Resource;
-
-/**
- * Initial Date:  25.10.2002
- * @author Florian Gnaegi
- *
- * Comment: Use this class to create the initial OLAT database
- *
- */
-public class DatabaseSetup {
-	private static final OLog log = Tracing.createLoggerFor(DatabaseSetup.class);
-
-	private static Configuration cf;	
-	/**
-	 * Method datastoreConfiguration is the central mapping definition of all OLAT
-	 * objects and their mapping to a relational database. 
-	 * 
-	 * When a new mapping is accomplished, it has to be added here.
-	 * 
-	 * @return Datastore
-	 * 
-	 * @throws MappingException
-	 */
-	public static Configuration datastoreConfiguration() throws MappingException {
-		cf = new Configuration();
-		List<String> filesAlreadyAdded = new ArrayList<String>();
-		List<String> ignoredFiles = new ArrayList<String>();
-		
-		//TODO
-		//loading hbm files out of a jar needs an start root directory. So change it to:
-		//CoreSpringFactory.getResources("classpath*:org/**/*.hbm.xml");
-		//If you do the fix above you also need to ensure that no *hbm.xml files are
-		//present both in .jars and in WEB-INF/classes, otherwise the startup process
-		//will fail.
-		
-		ignoredFiles.add("LoggingObject.hbm.xml");
-		ignoredFiles.add("UserCommentImpl.hbm.xml");
-		ignoredFiles.add("UserRatingImpl.hbm.xml");
-		addHibernateFilesMatching("classpath*:**/*.hbm.xml", filesAlreadyAdded, ignoredFiles);
-		
-		//OLAT-4109 : the LoggingAction.hbm.xml file is in the core jar and is not found
-		//            since it's not in the classes directory but in the jar.
-		//            as documented above, when you want to have hbm.xml files
-		//            found by the CoreSpringFactory.getResources() method
-		//            you can't just specify "classpath*:**/*.hbm.xml"
-		//            but need to specify at least the first path segment,
-		//            i.e. it will work when you do this: "classpath*:org/**/*.hbm.xml"
-		//            Now the problem with this is that it will find too
-		//            many - i.e. it will find duplicates if you have some in a jar
-		//            and some in the classpath
-		//            To fix this we now just restrict it to loggingObject -
-		//            plus adding the ignoredFiles "trick"
-		//TODO
-		//            Might be an idea to generalize this whole way we deal with this
-		//            i.e. we have the core jar which can contain any htm.xml or spring.xml files
-		//            so for production we want to add load them here - but for
-		//            development we have the core java directory mounted so we have
-		//            under classes as well - hence the whole problem
-		addHibernateFilesMatching("classpath*:org/**/LoggingObject.hbm.xml", filesAlreadyAdded, new ArrayList<String>());
-		addHibernateFilesMatching("classpath*:org/**/UserCommentImpl.hbm.xml", filesAlreadyAdded, new ArrayList<String>());
-		addHibernateFilesMatching("classpath*:org/**/UserRatingImpl.hbm.xml", filesAlreadyAdded, new ArrayList<String>());
-		
-		return cf;
-	}
-
-
-	private static void addHibernateFilesMatching(final String resourcePath, List<String> filesAlreadyAdded, List<String> ignoredFiles) {
-		Resource[] ress = CoreSpringFactory.getResources(resourcePath);
-		for (int i = 0; i < ress.length; i++) {
-			Resource res = ress[i];
-			InputStream is;
-			String fileName = res.getFilename();
-			if (ignoredFiles.contains(fileName)) {
-				// then ignore it - dont log either
-				continue;
-			}
-			if (!filesAlreadyAdded.contains(fileName)) {
-				filesAlreadyAdded.add(fileName);
-				try {
-					log.info("Start adding hibernate mapping (xml mapping stream): "+ res.getDescription());
-					is = res.getInputStream();
-					cf.addInputStream(is);
-					log.info("Loaded hibernate mapping (xml mapping stream): "+ res.getDescription());
-				} catch (IOException e) {
-					throw new AssertException("i/o error while getting inputstream of resource:"+ res.getDescription());
-				}
-			} else {
-				log.warn("Douplicate hibernate mapping file::" + fileName+ " found on classpath, skipping " + res.toString());
-			}
-		}
-	}
-
-
-	/**
-	 * Execute commands from the command line:
-	 * 'setup' or 'drop' currently available 
-	 * @param args One of createTables, dropTables, toFile, updateDDL
-	 * @throws Exception
-	 * e.g. DatabaseSetup org.hibernate.dialect.MySQLDialect createScript
-	 */
-	public static void main( String[] args ) throws Exception {
-		if (args.length == 2) {
-			cf = datastoreConfiguration();
-			cf.setProperty("hibernate.dialect", args[0]);
-			if (args[1].equals("createTables"))	createTables();
-			else if (args[1].equals("dropTables")) dropTables();
-			else if (args[1].equals("createScript")) exportDDLtoFile();
-			else if (args[1].equals("updateDDL")) updateDatabaseDDL();
-		}	else { // write to file as default see database/setupDatabase.sql
-			System.out.println("Usage: DatabaseSetup DIALECT ACTION\nwhere ACTION is one of: createTables | dropTables | createScript | updateDLL");
-		}
-	}
-
-	/**
-	 * Setup OLAT database. This will drop all tables first if available.
-	 * @throws Exception
-	 */
-	public static void createTables() throws Exception {
-		log.info("Creating tables");
-		new SchemaExport(cf).create(false, true); // set first bolean to true for debugging.
-	}
-
-	/**
-	 * Drop all OLAT tables
-	 * @throws Exception
-	 */
-	public static void dropTables() throws Exception {
-		log.info("Dropping tables");
-		new SchemaExport(cf).drop(false, true);
-	}
-
-	/**
-	 * Generates alter database DDL and EXECUTES it.
-	 */
-	private static void updateDatabaseDDL() {
-		boolean printToOut = true;  // write to System.out 
-		boolean updateDatabase = false;
-		try {
-			new SchemaUpdate(cf).execute(printToOut, updateDatabase);
-		} catch (Exception e) {
-			log.error("DDL export to file failed: Reason: ", e);
-		}		
-	}
-
-	/**
-	 * Write database configuration to file.
-	 * Includes differences to existing database.
-	 * Filename: "database/setupDatabase.sql"
-	 */
-	private static void exportDDLtoFile() {
-		String outputFile = "database/setupDatabase.sql";
-
-		boolean script = true;  // write DDL 
-		boolean export = false; // don't update databse		
-		try {
-			SchemaExport se = new SchemaExport(cf);
-			se.setOutputFile(outputFile);
-			se.setDelimiter(";");
-			se.create(script, export);
-		} catch (Exception e) {
-			log.error("DDL export to file failed: Reason: ", e);
-		}
-	}
-}
diff --git a/src/main/java/org/olat/core/commons/persistence/ITransactionListener.java b/src/main/java/org/olat/core/commons/persistence/ITransactionListener.java
deleted file mode 100644
index 733b100b85c..00000000000
--- a/src/main/java/org/olat/core/commons/persistence/ITransactionListener.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
-* OLAT - Online Learning and Training<br>
-* http://www.olat.org
-* <p>
-* Licensed under the Apache License, Version 2.0 (the "License"); <br>
-* you may not use this file except in compliance with the License.<br>
-* You may obtain a copy of the License at
-* <p>
-* http://www.apache.org/licenses/LICENSE-2.0
-* <p>
-* Unless required by applicable law or agreed to in writing,<br>
-* software distributed under the License is distributed on an "AS IS" BASIS, <br>
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
-* See the License for the specific language governing permissions and <br>
-* limitations under the License.
-* <p>
-* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
-* University of Zurich, Switzerland.
-* <hr>
-* <a href="http://www.openolat.org">
-* OpenOLAT - Online Learning and Training</a><br>
-* This file has been modified by the OpenOLAT community. Changes are licensed
-* under the Apache 2.0 license as the original file.
-*/
-package org.olat.core.commons.persistence;
-
-/**
- * This Listener can be added to a DB instance in order to be
- * notified about commit/rollbacks
- * 
- * <P>
- * Initial Date:  19.08.2008 <br>
- * @author Stefan
- */
-public interface ITransactionListener {
-
-	public void handleCommit(DB db);
-	
-	public void handleRollback(DB db);
-	
-}
diff --git a/src/main/resources/database/readme.txt b/src/main/resources/database/readme.txt
index 67e1da9a167..a5e6f82d452 100644
--- a/src/main/resources/database/readme.txt
+++ b/src/main/resources/database/readme.txt
@@ -12,11 +12,8 @@ in the Java part of OLAT.
 
 The database directory contains ready to use SQL scripts for MySQL and PostgreSQL
 in the corresponding subdirectories.
-You can also run org.olat.persistence.DatabaseSetup.main() to generate the olat 
-database script for your hibernate dialect. The generated sql commands saved
-to database/setupDatabase.sql.
 
-See our docu for more information: http://www.olat.org/docu/
+See our docu for more information: http://www.openolat.org/documentation.html
 
 
 my.cnf InnoDB Sample Config 
-- 
GitLab