aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/handler
diff options
context:
space:
mode:
authormemesaregood1 <sifepe4679@yandex.ru>2023-02-22 22:46:50 +0300
committermemesaregood1 <sifepe4679@yandex.ru>2023-02-22 22:46:50 +0300
commit0fe0344a64b142ef4492ff6ad3c1f8590d336ab0 (patch)
tree6d78812cd1339daa02dbfe6dd51d8b21be9cc57d /src/main/java/org/traccar/handler
parent9deca13ced10ef8a6df164831dd60ed4089a25a6 (diff)
downloadtrackermap-server-0fe0344a64b142ef4492ff6ad3c1f8590d336ab0.tar.gz
trackermap-server-0fe0344a64b142ef4492ff6ad3c1f8590d336ab0.tar.bz2
trackermap-server-0fe0344a64b142ef4492ff6ad3c1f8590d336ab0.zip
Alternative features activation way
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r--src/main/java/org/traccar/handler/ComputedAttributesHandler.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
index 73b549195..2964d81d7 100644
--- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
+++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java
@@ -55,6 +55,8 @@ public class ComputedAttributesHandler extends BaseDataHandler {
private final JexlEngine engine;
+ private final JexlFeatures features;
+
private final boolean includeDeviceAttributes;
@Inject
@@ -62,7 +64,7 @@ public class ComputedAttributesHandler extends BaseDataHandler {
this.cacheManager = cacheManager;
JexlSandbox sandbox = new JexlSandbox(false);
sandbox.allow("com.safe.Functions");
- JexlFeatures features = new JexlFeatures()
+ features = new JexlFeatures()
.localVar(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOCAL_VARIABLES))
.loops(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_LOOPS))
.newInstance(config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_NEW_INSTANCE_CREATION))
@@ -71,7 +73,6 @@ public class ComputedAttributesHandler extends BaseDataHandler {
.strict(true)
.namespaces(Collections.singletonMap("math", Math.class))
.sandbox(sandbox)
- .features(features)
.create();
includeDeviceAttributes = config.getBoolean(Keys.PROCESSING_COMPUTED_ATTRIBUTES_DEVICE_ATTRIBUTES);
}
@@ -113,7 +114,7 @@ public class ComputedAttributesHandler extends BaseDataHandler {
*/
@Deprecated
public Object computeAttribute(Attribute attribute, Position position) throws JexlException {
- return engine.createExpression(attribute.getExpression()).evaluate(prepareContext(position));
+ return engine.createScript(features, engine.createInfo(), attribute.getExpression()).execute(prepareContext(position));
}
@Override