mirror of
https://github.com/gmbrax/MediaManager-core.git
synced 2026-11-09 14:00:17 +00:00
Add SQLite support with SqliteDatabaseManager and application mode handling:
- Created `SqliteDatabaseManager` for SQLite database initialization and management. - Refactored `DatabaseManager` into an abstract class to support different database implementations. - Introduced `ApplicationMode` enum to switch between `local` and `server` modes. - Updated `MediaManagerApplication` to handle `runtype` configuration and initialize SQLite in `local` mode. - Updated `config.properties.example` with new `runtype` property. - Added SQLite JDBC dependency to `pom.xml`.
This commit is contained in:
parent
77259308c6
commit
dc4b6cbdfa
@@ -1,5 +1,6 @@
|
||||
package com.mediamanager;
|
||||
|
||||
import com.mediamanager.service.database.DatabaseManager;
|
||||
import com.mediamanager.service.delegate.DelegateActionManager;
|
||||
import com.mediamanager.service.ipc.IPCManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -9,7 +10,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.mediamanager.service.database.DatabaseManager;
|
||||
import com.mediamanager.service.database.SqliteDatabaseManager;
|
||||
|
||||
public class MediaManagerApplication {
|
||||
private static final Logger logger = LogManager.getLogger(MediaManagerApplication.class);
|
||||
@@ -18,13 +19,46 @@ public class MediaManagerApplication {
|
||||
private static DelegateActionManager actionManager;
|
||||
private static IPCManager ipcManager;
|
||||
|
||||
public enum ApplicationMode {
|
||||
LOCAL("local"),
|
||||
SERVER("server");
|
||||
|
||||
private final String value;
|
||||
|
||||
ApplicationMode(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
logger.info("Starting MediaManager Core Application...");
|
||||
|
||||
try {
|
||||
// Load configuration
|
||||
loadConfiguration();
|
||||
databaseManager = new DatabaseManager(config);
|
||||
String runTypeString = config.getProperty("runtype","local");
|
||||
ApplicationMode mode = null;
|
||||
|
||||
for (ApplicationMode am : ApplicationMode.values()) {
|
||||
if (am.value.equalsIgnoreCase(runTypeString)) {
|
||||
mode = am;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (mode == null) {
|
||||
logger.error("Invalid run type: {}", runTypeString);
|
||||
throw new Exception("Invalid run type: " + runTypeString);
|
||||
}
|
||||
logger.info("Run type: {}", mode);
|
||||
switch (mode) {
|
||||
case LOCAL:
|
||||
logger.info("Starting local database...");
|
||||
databaseManager = new SqliteDatabaseManager(config);
|
||||
break;
|
||||
case SERVER:
|
||||
throw new Exception("Server mode not yet implemented");
|
||||
default:
|
||||
}
|
||||
databaseManager.init();
|
||||
actionManager = new DelegateActionManager();
|
||||
actionManager.start();
|
||||
@@ -102,4 +136,4 @@ public class MediaManagerApplication {
|
||||
public static Properties getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user