sruehl commented on a change in pull request #40: Alias registry for opm
URL: https://github.com/apache/incubator-plc4x/pull/40#discussion_r235886286
##########
File path:
plc4j/utils/opm/src/main/java/org/apache/plc4x/java/opm/PlcEntityInterceptor.java
##########
@@ -154,19 +163,25 @@ static void refetchAllFields(Object proxy,
PlcDriverManager driverManager, Strin
Arrays.stream(entityClass.getDeclaredFields())
.filter(field -> field.isAnnotationPresent(PlcField.class))
+ .filter(field -> needsToBeFetched(lastFetched, field))
.forEach(field ->
requestBuilder.addItem(
- field.getDeclaringClass().getName() + "." +
field.getName(),
- field.getAnnotation(PlcField.class).value()
+ getFqn(field),
+ OpmUtils.getOrResolveAddress(registry,
field.getAnnotation(PlcField.class).value())
)
);
PlcReadRequest request = requestBuilder.build();
+ LOGGER.trace("Request for refetch of " + entityClass + " was build
and is " + request.toString());
+
PlcReadResponse response = getPlcReadResponse(request);
// Fill all requested fields
for (String fieldName : response.getFieldNames()) {
+ // Fill into Cache
+ lastFetched.put(fieldName, Instant.now());
Review comment:
Maybe we need a cleaner Thread that cleans up this map after 5 minutes or
something? Otherwise this could grow but usually this wouldn't be that bad as
the fields are finite on an environment. So might not even worth the effort.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services