In an application that subscribes to MarketPrice instruments using EMA Java, I would like to preserve for a later use the Data I receive via Refresh and Update messages. My current understanding is that the Data I receive for each field is only valid in the context of the onRefresh and onUpdate callback methods. For example if in an onRefresh method I preserve the Data of a FieldEntry by calling fieldData = fieldEntry.load(), I cannot use this fieldData variable later after onRefresh returned.
Based on EMA Java API dev guide section 3.2.3, the Data class and all classes that inherit from it are designed as temporary and short-lived objects. For this reason, do not use them as storage or caching devices.
If the application just needs the content for the business logic use case, the application can store the FieldEntry’s content as string or manual copy content from incoming FieldEntry object (A) to the local FieldEntry object (B).
Based on your "For example if in an onRefresh method I preserve the Data of a FieldEntry by calling fieldData = fieldEntry.load(), I cannot use this fieldData variable later after onRefresh returned." statement, your fieldData is declared under the onRefresh() function scope. You cannot use it outside the onRefresh() function. You need to declare the local FieldEntry object in the class scope, so it can be used in any class's functions.