Skip to content

Commit 958f93b

Browse files
author
Robin Duda
committed
StorageLoader: generate plugin string if plugin class is set.
1 parent 8f1245c commit 958f93b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

core/main/java/com/codingchili/core/storage/StorageLoader.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private void load(Handler<AsyncResult<AsyncStorage<Value>>> handler) {
4646
promise.future().onComplete(handler);
4747

4848
prepare();
49+
4950
StorageContext<Value> storage = new StorageContext<Value>(context)
5051
.setDatabase(database)
5152
.setCollection(collection)
@@ -58,7 +59,7 @@ private void load(Handler<AsyncResult<AsyncStorage<Value>>> handler) {
5859
blocking.complete();
5960

6061
} catch (Throwable e) {
61-
logger.log(CoreStrings.getStorageLoaderError(plugin, database, collection), Level.ERROR);
62+
logger.log(CoreStrings.getStorageLoaderError(pluginString, database, collection), Level.ERROR);
6263
logger.onError(e);
6364
blocking.fail(e);
6465
}
@@ -71,12 +72,11 @@ private void load(Handler<AsyncResult<AsyncStorage<Value>>> handler) {
7172

7273
@SuppressWarnings("unchecked")
7374
private void prepare() throws ClassNotFoundException {
74-
checkIsSet(context, ID_CONTEXT);
75-
checkIsSet(valueClass, ID_CLASS);
76-
77-
if (pluginString != null)
75+
if (plugin == null) {
7876
this.plugin = (Class<? extends AsyncStorage>) Class.forName(pluginString);
79-
77+
} else if (pluginString == null) {
78+
this.pluginString = plugin.getSimpleName();
79+
}
8080

8181
if (collection == null) {
8282
this.collection = valueClass.getSimpleName();
@@ -85,6 +85,9 @@ private void prepare() throws ClassNotFoundException {
8585
if (database == null) {
8686
database = Configurations.storage().getSettingsForPlugin(plugin).getDatabase();
8787
}
88+
89+
checkIsSet(context, ID_CONTEXT);
90+
checkIsSet(valueClass, ID_CLASS);
8891
checkIsSet(plugin, ID_PLUGIN);
8992
}
9093

0 commit comments

Comments
 (0)