diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2018-06-28 17:07:25 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-28 17:07:25 +1200 |
commit | e849d3a56f55c83dc0ebed02165a124e30e22dbd (patch) | |
tree | 730e542145652ca1d06c64a6944dfa70e0b31b6b /src/org/traccar/Context.java | |
parent | 4d6229c7daa4a7b8f28337c5eca9a422876c98b1 (diff) | |
parent | 14840af2abd9976b8f5634af8e77f4a7126dfac1 (diff) | |
download | trackermap-server-e849d3a56f55c83dc0ebed02165a124e30e22dbd.tar.gz trackermap-server-e849d3a56f55c83dc0ebed02165a124e30e22dbd.tar.bz2 trackermap-server-e849d3a56f55c83dc0ebed02165a124e30e22dbd.zip |
Merge pull request #3950 from Abyss777/notification_refactor
Notification refactor to allow custom "notificators"
Diffstat (limited to 'src/org/traccar/Context.java')
-rw-r--r-- | src/org/traccar/Context.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index 7224fd742..2afdde3b9 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -77,8 +77,9 @@ import org.traccar.geolocation.MozillaGeolocationProvider; import org.traccar.geolocation.OpenCellIdGeolocationProvider; import org.traccar.notification.EventForwarder; import org.traccar.notification.JsonTypeEventForwarder; +import org.traccar.notification.NotificatorManager; import org.traccar.reports.model.TripsConfig; -import org.traccar.smpp.SmppClient; +import org.traccar.sms.SmsManager; import org.traccar.web.WebServer; import javax.ws.rs.client.Client; @@ -206,6 +207,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() { @@ -254,10 +261,10 @@ public final class Context { return statisticsManager; } - private static SmppClient smppClient; + private static SmsManager smsManager; - public static SmppClient getSmppManager() { - return smppClient; + public static SmsManager getSmsManager() { + return smsManager; } private static MotionEventHandler motionEventHandler; @@ -389,6 +396,15 @@ public final class Context { tripsConfig = initTripsConfig(); + if (config.getBoolean("sms.enable")) { + final String smsManagerClass = config.getString("sms.manager.class", "org.traccar.smpp.SmppClient"); + try { + smsManager = (SmsManager) Class.forName(smsManagerClass).newInstance(); + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { + Log.warning("Error loading SMS Manager class : " + smsManagerClass, e); + } + } + if (config.getBoolean("event.enable")) { initEventsModule(); } @@ -407,10 +423,6 @@ public final class Context { statisticsManager = new StatisticsManager(); - if (config.getBoolean("sms.smpp.enable")) { - smppClient = new SmppClient(); - } - } private static void initGeolocationModule() { @@ -441,6 +453,7 @@ public final class Context { calendarManager = new CalendarManager(dataManager); maintenancesManager = new MaintenancesManager(dataManager); notificationManager = new NotificationManager(dataManager); + notificatorManager = new NotificatorManager(); Properties velocityProperties = new Properties(); velocityProperties.setProperty("file.resource.loader.path", Context.getConfig().getString("templates.rootPath", "templates") + "/"); |