Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[milo-dev] DelegateRegistry.registerEncoder()/registerDecoder() in static initializer block

Hi Kevin,

When milo client and server run in isolation, server output error message below:
---
"no decoder registered for encodingId=446..."

"446" means Identifiers.OpenSecureChannelRequest_Encoding_DefaultBinary.

Client was able to encode OpenSecureChannelRequest message, but server was not able to
decode this message because missing the decoder.

And so I locally wrote two classes(UaEnumerationInitializer.java and UaStructureInitializer.java)
to execute "static initializer block" of all these classes below:
---
   org.eclipse.milo.opcua.stack.core.enumerated/*.java
   org.eclipse.milo.opcua.stack.core.structured/*.java

     static {
         DelegateRegistry.registerEncoder(ApplicationType::encode, ApplicationType.class);
         DelegateRegistry.registerDecoder(ApplicationType::decode, ApplicationType.class);
     }

UaEnumerationInitializer.java)
------------------------------------------------------------------------
package org.eclipse.milo.opcua.stack.core.types;

import org.eclipse.milo.opcua.stack.core.types.enumerated.ApplicationType;
import org.eclipse.milo.opcua.stack.core.types.enumerated.AttributeWriteMask;
.....

public class UaEnumerationInitializer {
	public static void execute() {
		ApplicationType.from(null);
		AttributeWriteMask.from(null);
		AxisScaleEnumeration.from(null);
		.....
------------------------------------------------------------------------

UaStructureInitializer)
------------------------------------------------------------------------
package org.eclipse.milo.opcua.stack.core.types;

import org.eclipse.milo.opcua.stack.core.types.structured.*;

public class UaStructureInitializer {
	public static void execute() {
		new ActivateSessionRequest();
		new ActivateSessionResponse();
		.....
------------------------------------------------------------------------

And I locally added these initializer methods in constructors of UaTcpStackClient.java
and UaTcpStackClient.java.

UaTcpStackClient.java)
------------------------------------------------------------------------
     public UaTcpStackClient(UaTcpStackClientConfig config) {
         this.config = config;

       + UaEnumerationInitializer.execute();
       + UaStructureInitializer.execute();
         .....
------------------------------------------------------------------------

UaTcpStackServer.java)
------------------------------------------------------------------------
     public UaTcpStackServer(UaTcpStackServerConfig config) {
         this.config = config;

       + UaEnumerationInitializer.execute();
       + UaStructureInitializer.execute();
         .....
------------------------------------------------------------------------

Please tell me other good method for that.

Regards,

--Shigeru


Back to the top