Class LazyClientDataTypeManager
- All Implemented Interfaces:
org.eclipse.milo.opcua.stack.core.types.DataTypeManager
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:
- Uses the
DataTypeTreeto resolve the type (which triggers lazy browsing if usingLazyClientDataTypeTree) - Creates a codec using
DynamicCodecFactory - 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
ConstructorsConstructorDescriptionLazyClientDataTypeManager(OpcUaClient client, org.eclipse.milo.opcua.stack.core.NamespaceTable namespaceTable, org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree dataTypeTree) Create a newLazyClientDataTypeManager.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 newLazyClientDataTypeManagerwith a custom codec factory. -
Method Summary
Modifier and TypeMethodDescriptionvoidClear failed resolution attempts, allowing retry.@Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeIdgetBinaryEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId) @Nullable org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodecgetCodec(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId id) @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeIdgetJsonEncodingId(org.eclipse.milo.opcua.stack.core.types.builtin.NodeId dataTypeId) @Nullable org.eclipse.milo.opcua.stack.core.types.builtin.NodeIdgetXmlEncodingId(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
-
Constructor Details
-
LazyClientDataTypeManager
public LazyClientDataTypeManager(OpcUaClient client, org.eclipse.milo.opcua.stack.core.NamespaceTable namespaceTable, org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree dataTypeTree) Create a newLazyClientDataTypeManager.- Parameters:
client- a connectedOpcUaClient.namespaceTable- the server'sNamespaceTable.dataTypeTree- theDataTypeTreeto use for type resolution. This is typically aLazyClientDataTypeTreefor 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 newLazyClientDataTypeManagerwith a custom codec factory.- Parameters:
client- a connectedOpcUaClient.namespaceTable- the server'sNamespaceTable.dataTypeTree- theDataTypeTreeto use for type resolution.codecFactory- a factory function that createsDataTypeCodecs fromDataTypeandDataTypeTree.
-
-
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:
getCodecin interfaceorg.eclipse.milo.opcua.stack.core.types.DataTypeManager- Overrides:
getCodecin classorg.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:
getBinaryEncodingIdin interfaceorg.eclipse.milo.opcua.stack.core.types.DataTypeManager- Overrides:
getBinaryEncodingIdin classorg.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:
getXmlEncodingIdin interfaceorg.eclipse.milo.opcua.stack.core.types.DataTypeManager- Overrides:
getXmlEncodingIdin classorg.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:
getJsonEncodingIdin interfaceorg.eclipse.milo.opcua.stack.core.types.DataTypeManager- Overrides:
getJsonEncodingIdin classorg.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager
-