From 825ee0d178a24620f075cb4ffb8d49c75b046484 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 26 Jun 2018 12:05:16 +0500 Subject: Cleanup and some adjustments --- .../notification/NotificationException.java | 4 ++-- src/org/traccar/notification/NotificationMail.java | 4 ++-- src/org/traccar/notification/NotificationNull.java | 4 ++-- src/org/traccar/notification/NotificationSms.java | 4 ++-- src/org/traccar/notification/NotificationWeb.java | 4 ++-- src/org/traccar/notification/Notificator.java | 4 ++-- .../traccar/notification/NotificatorManager.java | 26 +++++++++++++--------- 7 files changed, 28 insertions(+), 22 deletions(-) (limited to 'src/org/traccar/notification') diff --git a/src/org/traccar/notification/NotificationException.java b/src/org/traccar/notification/NotificationException.java index 34d5a80f7..525e5ee37 100644 --- a/src/org/traccar/notification/NotificationException.java +++ b/src/org/traccar/notification/NotificationException.java @@ -1,6 +1,6 @@ /* - * Copyright 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. diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index fb89bf5bd..76387c73b 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -1,6 +1,6 @@ /* - * Copyright 2016 - 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2016 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 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. diff --git a/src/org/traccar/notification/NotificationNull.java b/src/org/traccar/notification/NotificationNull.java index fd7950a80..3ee954c24 100644 --- a/src/org/traccar/notification/NotificationNull.java +++ b/src/org/traccar/notification/NotificationNull.java @@ -1,6 +1,6 @@ /* - * Copyright 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. diff --git a/src/org/traccar/notification/NotificationSms.java b/src/org/traccar/notification/NotificationSms.java index 63fd57895..dd3304d85 100644 --- a/src/org/traccar/notification/NotificationSms.java +++ b/src/org/traccar/notification/NotificationSms.java @@ -1,6 +1,6 @@ /* - * Copyright 2017 Anton Tananaev (anton@traccar.org) - * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) + * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org) + * Copyright 2017 - 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. diff --git a/src/org/traccar/notification/NotificationWeb.java b/src/org/traccar/notification/NotificationWeb.java index c6a1ae281..8e04fc2c4 100644 --- a/src/org/traccar/notification/NotificationWeb.java +++ b/src/org/traccar/notification/NotificationWeb.java @@ -1,6 +1,6 @@ /* - * Copyright 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. diff --git a/src/org/traccar/notification/Notificator.java b/src/org/traccar/notification/Notificator.java index 7192d25c0..09f98d3ad 100644 --- a/src/org/traccar/notification/Notificator.java +++ b/src/org/traccar/notification/Notificator.java @@ -1,6 +1,6 @@ /* - * Copyright 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. 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 c = (Class) Class.forName(className); + final Class clazz = (Class) Class.forName(className); try { - final Constructor constructor = c.getConstructor(new Class[]{String.class}); + final Constructor 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 getNotificatorTypes() { - return notificators.keySet(); + public Set getNotificatorTypes() { + Set result = new HashSet<>(); + for (String notificator : notificators.keySet()) { + result.add(new Typed(notificator)); + } + return result; } -- cgit v1.2.3