aboutsummaryrefslogtreecommitdiff
path: root/src/org
diff options
context:
space:
mode:
authorIvan Martinez <ivanfmartinez@users.noreply.github.com>2018-06-01 09:48:07 -0300
committerIvan Martinez <ivanfmartinez@users.noreply.github.com>2018-06-01 09:48:07 -0300
commit4fc750b585dd6b2953b16408dd57a8ef93fdeee9 (patch)
tree8697ae3559ad7b5e4e9b667a6d2faef568769b1a /src/org
parent8ca7b2d0d9b5e18dd7e96a2cf5b1b8d8d751051a (diff)
downloadtrackermap-server-4fc750b585dd6b2953b16408dd57a8ef93fdeee9.tar.gz
trackermap-server-4fc750b585dd6b2953b16408dd57a8ef93fdeee9.tar.bz2
trackermap-server-4fc750b585dd6b2953b16408dd57a8ef93fdeee9.zip
move NotificatorManager instance to Context
Diffstat (limited to 'src/org')
-rw-r--r--src/org/traccar/Context.java8
-rw-r--r--src/org/traccar/api/resource/NotificationResource.java5
-rw-r--r--src/org/traccar/database/NotificationManager.java3
-rw-r--r--src/org/traccar/notification/NotificatorManager.java12
4 files changed, 16 insertions, 12 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java
index c9ac4ec12..a7c1817cf 100644
--- a/src/org/traccar/Context.java
+++ b/src/org/traccar/Context.java
@@ -73,6 +73,7 @@ import org.traccar.geolocation.OpenCellIdGeolocationProvider;
import org.traccar.notification.EventForwarder;
import org.traccar.notification.JsonTypeEventForwarder;
import org.traccar.notification.MultiPartEventForwarder;
+import org.traccar.notification.NotificatorManager;
import org.traccar.reports.model.TripsConfig;
import org.traccar.sms.SMSManager;
import org.traccar.web.WebServer;
@@ -196,6 +197,12 @@ public final class Context {
return notificationManager;
}
+ private static NotificatorManager notificatorManager;
+
+ public static NotificatorManager getNotificatorManager() {
+ return notificatorManager;
+ }
+
private static VelocityEngine velocityEngine;
public static VelocityEngine getVelocityEngine() {
@@ -425,6 +432,7 @@ public final class Context {
geofenceManager = new GeofenceManager(dataManager);
calendarManager = new CalendarManager(dataManager);
notificationManager = new NotificationManager(dataManager);
+ notificatorManager = new NotificatorManager();
Properties velocityProperties = new Properties();
velocityProperties.setProperty("file.resource.loader.path",
Context.getConfig().getString("templates.rootPath", "templates") + "/");
diff --git a/src/org/traccar/api/resource/NotificationResource.java b/src/org/traccar/api/resource/NotificationResource.java
index 2a398f40d..830e34fc0 100644
--- a/src/org/traccar/api/resource/NotificationResource.java
+++ b/src/org/traccar/api/resource/NotificationResource.java
@@ -31,7 +31,6 @@ import org.traccar.model.Event;
import org.traccar.model.Notification;
import org.traccar.model.Typed;
import org.traccar.notification.NotificationException;
-import org.traccar.notification.NotificatorManager;
@Path("notifications")
@@ -52,8 +51,8 @@ public class NotificationResource extends ExtendedObjectResource<Notification> {
@POST
@Path("test")
public Response testMessage() throws NotificationException, InterruptedException {
- NotificatorManager.getMail().sendSync(getUserId(), new Event("test", 0), null);
- NotificatorManager.getSms().sendSync(getUserId(), new Event("test", 0), null);
+ Context.getNotificatorManager().getMail().sendSync(getUserId(), new Event("test", 0), null);
+ Context.getNotificatorManager().getSms().sendSync(getUserId(), new Event("test", 0), null);
return Response.noContent().build();
}
diff --git a/src/org/traccar/database/NotificationManager.java b/src/org/traccar/database/NotificationManager.java
index 10c76181a..a10fbf69a 100644
--- a/src/org/traccar/database/NotificationManager.java
+++ b/src/org/traccar/database/NotificationManager.java
@@ -32,7 +32,6 @@ import org.traccar.model.Event;
import org.traccar.model.Notification;
import org.traccar.model.Position;
import org.traccar.model.Typed;
-import org.traccar.notification.NotificatorManager;
public class NotificationManager extends ExtendedObjectManager<Notification> {
@@ -90,7 +89,7 @@ public class NotificationManager extends ExtendedObjectManager<Notification> {
}
}
for (String nm : notificationMethods) {
- NotificatorManager.getNotificator(nm).sendAsync(userId, event, position);
+ Context.getNotificatorManager().getNotificator(nm).sendAsync(userId, event, position);
}
}
}
diff --git a/src/org/traccar/notification/NotificatorManager.java b/src/org/traccar/notification/NotificatorManager.java
index 0ffef5d05..c58149847 100644
--- a/src/org/traccar/notification/NotificatorManager.java
+++ b/src/org/traccar/notification/NotificatorManager.java
@@ -26,9 +26,7 @@ import org.traccar.helper.Log;
public final class NotificatorManager {
- private static final NotificatorManager INSTANCE = new NotificatorManager();
-
- private NotificatorManager() {
+ public NotificatorManager() {
final String[] types = Context.getConfig().getString("notificator.types", "").split(",");
for (String type : types) {
final String className = Context.getConfig().getString("notificator." + type + ".class", "");
@@ -53,8 +51,8 @@ public final class NotificatorManager {
private final Map<String, Notificator> notificators = new HashMap<>();
private static final Notificator NULL_NOTIFICATOR = new NotificationNull();
- public static Notificator getNotificator(String type) {
- final Notificator n = INSTANCE.notificators.get(type);
+ public Notificator getNotificator(String type) {
+ final Notificator n = notificators.get(type);
if (n == null) {
Log.error("No notificator configured for type : " + type);
return NULL_NOTIFICATOR;
@@ -62,11 +60,11 @@ public final class NotificatorManager {
return n;
}
- public static Notificator getSms() {
+ public Notificator getSms() {
return getNotificator("sms");
}
- public static Notificator getMail() {
+ public Notificator getMail() {
return getNotificator("mail");
}