aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/notification/NotificatorManager.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2018-06-26 12:05:16 +0500
committerAbyss777 <abyss@fox5.ru>2018-06-26 12:05:16 +0500
commit825ee0d178a24620f075cb4ffb8d49c75b046484 (patch)
tree2bc60aaea8d4c1eff707ae6e0b8ff558d45d15dc /src/org/traccar/notification/NotificatorManager.java
parentaba402226403f8b3eb58cc01e8f536eb4104d35a (diff)
downloadtrackermap-server-825ee0d178a24620f075cb4ffb8d49c75b046484.tar.gz
trackermap-server-825ee0d178a24620f075cb4ffb8d49c75b046484.tar.bz2
trackermap-server-825ee0d178a24620f075cb4ffb8d49c75b046484.zip
Cleanup and some adjustments
Diffstat (limited to 'src/org/traccar/notification/NotificatorManager.java')
-rw-r--r--src/org/traccar/notification/NotificatorManager.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java
index 20c7749d2..87a294345 100644
--- a/src/org/traccar/notification/NotificatorManager.java
+++ b/src/org/traccar/notification/NotificatorManager.java
@@ -1,6 +1,6 @@
/*
- * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org)
- * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
+ * Copyright 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,11 +19,13 @@ package org.traccar.notification;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.traccar.Context;
import org.traccar.helper.Log;
+import org.traccar.model.Typed;
public final class NotificatorManager {
@@ -33,13 +35,13 @@ public final class NotificatorManager {
final String className = Context.getConfig().getString("notificator." + type + ".class", "");
if (className.length() > 0) {
try {
- final Class<Notificator> c = (Class<Notificator>) Class.forName(className);
+ final Class<Notificator> clazz = (Class<Notificator>) Class.forName(className);
try {
- final Constructor<Notificator> constructor = c.getConstructor(new Class[]{String.class});
+ final Constructor<Notificator> constructor = clazz.getConstructor(new Class[]{String.class});
notificators.put(type, constructor.newInstance(type));
} catch (NoSuchMethodException e) {
// No constructor with String argument
- notificators.put(type, c.newInstance());
+ notificators.put(type, clazz.newInstance());
}
} catch (ClassNotFoundException | InstantiationException
| IllegalAccessException | InvocationTargetException e) {
@@ -53,17 +55,21 @@ public final class NotificatorManager {
private static final Notificator NULL_NOTIFICATOR = new NotificationNull();
public Notificator getNotificator(String type) {
- final Notificator n = notificators.get(type);
- if (n == null) {
+ final Notificator notificator = notificators.get(type);
+ if (notificator == null) {
Log.error("No notificator configured for type : " + type);
return NULL_NOTIFICATOR;
}
- return n;
+ return notificator;
}
- public Set<String> getNotificatorTypes() {
- return notificators.keySet();
+ public Set<Typed> getNotificatorTypes() {
+ Set<Typed> result = new HashSet<>();
+ for (String notificator : notificators.keySet()) {
+ result.add(new Typed(notificator));
+ }
+ return result;
}