aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2024-03-30 18:46:37 -0700
committerAnton Tananaev <anton@traccar.org>2024-03-30 18:46:37 -0700
commitf84e2710e05660822633ec9e61cde44c03a42d7e (patch)
tree0d68bee50cc42ed206d270275dfb32b4b69c5186 /src/main/java/org/traccar/handler/ComputedAttributesHandler.java
parentee996425221ca64fdf00777d9035cedc6dccfa43 (diff)
downloadtrackermap-server-f84e2710e05660822633ec9e61cde44c03a42d7e.tar.gz
trackermap-server-f84e2710e05660822633ec9e61cde44c03a42d7e.tar.bz2
trackermap-server-f84e2710e05660822633ec9e61cde44c03a42d7e.zip
Refactor position and event handlers
Diffstat (limited to 'src/main/java/org/traccar/handler/ComputedAttributesHandler.java')
-rw-r--r--src/main/java/org/traccar/handler/ComputedAttributesHandler.java40
1 files changed, 17 insertions, 23 deletions
diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
index 8b010ceae..8d6fb39c3 100644
--- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2023 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2024 Anton Tananaev (anton@traccar.org)
* Copyright 2017 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,26 +16,15 @@
*/
package org.traccar.handler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.List;
-
-import io.netty.channel.ChannelHandler;
-import org.apache.commons.jexl3.JexlFeatures;
-import org.apache.commons.jexl3.JexlEngine;
+import jakarta.inject.Inject;
import org.apache.commons.jexl3.JexlBuilder;
-import org.apache.commons.jexl3.introspection.JexlSandbox;
+import org.apache.commons.jexl3.JexlEngine;
import org.apache.commons.jexl3.JexlException;
+import org.apache.commons.jexl3.JexlFeatures;
import org.apache.commons.jexl3.MapContext;
+import org.apache.commons.jexl3.introspection.JexlSandbox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.traccar.BaseDataHandler;
import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.model.Attribute;
@@ -43,12 +32,17 @@ import org.traccar.model.Device;
import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
-import jakarta.inject.Inject;
-import jakarta.inject.Singleton;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
-@Singleton
-@ChannelHandler.Sharable
-public class ComputedAttributesHandler extends BaseDataHandler {
+public class ComputedAttributesHandler extends BasePositionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ComputedAttributesHandler.class);
@@ -144,7 +138,7 @@ public class ComputedAttributesHandler extends BaseDataHandler {
}
@Override
- protected Position handlePosition(Position position) {
+ public void handlePosition(Position position, Callback callback) {
Collection<Attribute> attributes = cacheManager.getDeviceObjects(position.getDeviceId(), Attribute.class);
for (Attribute attribute : attributes) {
if (attribute.getAttribute() != null) {
@@ -202,7 +196,7 @@ public class ComputedAttributesHandler extends BaseDataHandler {
}
}
}
- return position;
+ callback.processed(position);
}
}