Class LazyClientDataTypeManager

java.lang.Object
org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager
org.eclipse.milo.opcua.sdk.client.typetree.LazyClientDataTypeManager
All Implemented Interfaces:
org.eclipse.milo.opcua.stack.core.types.DataTypeManager

public class LazyClientDataTypeManager extends org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager
A lazy-loading DataTypeManager that resolves codecs on demand.

This implementation works in conjunction with LazyClientDataTypeTree to provide fully lazy resolution of both type information and codecs. When a codec is requested for a type that isn't already registered, this manager:

  1. Uses the DataTypeTree to resolve the type (which triggers lazy browsing if using LazyClientDataTypeTree)
  2. Creates a codec using DynamicCodecFactory
  3. Registers the codec for future use

Namespace 0 Types

Built-in types from namespace 0 are pre-initialized via DataTypeInitializer in the constructor. Lazy resolution is only triggered for non-namespace-0 types.

Thread Safety

This implementation is thread-safe. All read operations first check the parent class under no lock, then acquire a write lock only when resolution is needed. Resolution attempts are tracked to avoid repeated failures.

Resolution Behavior

Resolution errors (e.g., network failures, non-existent types) do not cause exceptions. Instead, null is returned. Once a resolution attempt has failed, it will not be retried unless clearFailedResolutions() is called.

  • Constructor Summary

    Constructors
    Constructor
    Description
    LazyClientDataTypeManager(OpcUaClient client, org.eclipse.milo.opcua.stack.core.NamespaceTable namespaceTable, org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree dataTypeTree)
    LazyClientDataTypeManager(OpcUaClient client, org.eclipse.milo.opcua.stack.core.NamespaceTable namespaceTable, org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree dataTypeTree, BiFunction<org.eclipse.milo.opcua.sdk.core.typetree.DataType,org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree,org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodec> codecFactory)
    Create a new LazyClientDataTypeManager with a custom codec factory.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear failed resolution attempts, allowing retry.
    @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeId
    getBinaryEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId)
     
    @Nullable org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodec
    getCodec(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId id)
     
    @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeId
    getJsonEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId)
     
    @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeId
    getXmlEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId)
     

    Methods inherited from class org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager

    createAndInitialize, getTypeDictionary, registerType, registerTypeDictionary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • LazyClientDataTypeManager

      public LazyClientDataTypeManager(OpcUaClient client, org.eclipse.milo.opcua.stack.core.NamespaceTable namespaceTable, org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree dataTypeTree)
      Parameters:
      client - a connected OpcUaClient.
      namespaceTable - the server's NamespaceTable.
      dataTypeTree - the DataTypeTree to use for type resolution. This is typically a LazyClientDataTypeTree for full lazy behavior.
    • LazyClientDataTypeManager

      public LazyClientDataTypeManager(OpcUaClient client, org.eclipse.milo.opcua.stack.core.NamespaceTable namespaceTable, org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree dataTypeTree, BiFunction<org.eclipse.milo.opcua.sdk.core.typetree.DataType,org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree,org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodec> codecFactory)
      Create a new LazyClientDataTypeManager with a custom codec factory.
      Parameters:
      client - a connected OpcUaClient.
      namespaceTable - the server's NamespaceTable.
      dataTypeTree - the DataTypeTree to use for type resolution.
      codecFactory - a factory function that creates DataTypeCodecs from DataType and DataTypeTree.
  • Method Details

    • clearFailedResolutions

      public void clearFailedResolutions()
      Clear failed resolution attempts, allowing retry.

      When a codec resolution fails (e.g., due to network errors or non-existent types), the failure is recorded to avoid repeated failed attempts. This method clears those records, allowing later queries for those types to attempt resolution again.

      This is useful after transient network issues have been resolved or when the server's type system may have changed.

    • getCodec

      public @Nullable org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodec getCodec(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId id)
      Specified by:
      getCodec in interface org.eclipse.milo.opcua.stack.core.types.DataTypeManager
      Overrides:
      getCodec in class org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager
    • getBinaryEncodingId

      public @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeId getBinaryEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId)
      Specified by:
      getBinaryEncodingId in interface org.eclipse.milo.opcua.stack.core.types.DataTypeManager
      Overrides:
      getBinaryEncodingId in class org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager
    • getXmlEncodingId

      public @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeId getXmlEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId)
      Specified by:
      getXmlEncodingId in interface org.eclipse.milo.opcua.stack.core.types.DataTypeManager
      Overrides:
      getXmlEncodingId in class org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager
    • getJsonEncodingId

      public @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeId getJsonEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId)
      Specified by:
      getJsonEncodingId in interface org.eclipse.milo.opcua.stack.core.types.DataTypeManager
      Overrides:
      getJsonEncodingId in class org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager