package de.fernunihagen.dna.jkn.scalephant.storage;

import java.util.HashMap;
import java.util.Map;

public class StorageInterface {

	private static Map<String, StorageManager> instances;
	
	/**
	 * Get the storage manager for a given table. If the storage manager does not 
	 * exist, it will be created
	 * 
	 * @return
	 */
	public static synchronized StorageManager getStorageManager(final String table) {
		
		if(instances == null) {
			instances = new HashMap<String, StorageManager>();
		}
		
		if(instances.containsKey(table)) {
			return instances.get(table);
		}
		
		final StorageConfiguration storageConfiguration = new StorageConfiguration();
		final StorageManager storageManager = new StorageManager(table, storageConfiguration);
		storageManager.init();
		
		instances.put(table, storageManager);
		
		return storageManager;
	}
	
	@Override
	protected void finalize() throws Throwable {
		super.finalize();
		
		if(instances != null) {
			for(final String table : instances.keySet()) {
				final StorageManager storageManager = instances.get(table);
				storageManager.shutdown();
			}
		}
	}
}

@@ -133,61 +133,294 @@
 %7B%0A%0A%09
-private static Map%3CString, StorageManager%3E instances;
+/**%0A%09 * A map with all created storage instances%0A%09 */%0A%09protected static Map%3CString, StorageManager%3E instances;%0A%09%0A%09/**%0A%09 * The used storage configuration%0A%09 */%0A%09protected static StorageConfiguration storageConfiguration;%0A%09%0A%09static %7B%0A%09%09storageConfiguration = new StorageConfiguration();%0A%09%7D
 %0A%09%0A%09
@@ -808,88 +808,8 @@
 %0A%09%09%0A
-%09%09final StorageConfiguration storageConfiguration = new StorageConfiguration();%0A
 %09%09fi
@@ -1254,13 +1254,415 @@
 %09%09%7D%0A
-
 %09%09%7D%0A%09%7D
+%0A%0A%09/**%0A%09 * Get the current storage configuration%0A%09 * @return%0A%09 */%0A%09public static StorageConfiguration getStorageConfiguration() %7B%0A%09%09return storageConfiguration;%0A%09%7D%0A%0A%09/**%0A%09 * Set a new storage configuration%0A%09 * @param storageConfiguration%0A%09 */%0A%09public static void setStorageConfiguration(%0A%09%09%09StorageConfiguration storageConfiguration) %7B%0A%09%09StorageInterface.storageConfiguration = storageConfiguration;%0A%09%7D
 %0A%7D%0A

Allow to change the default storage configuration