OpcUaClient interface/inheritance & SessionInitializer #1523
Replies: 3 comments 14 replies
-
SessionInitializers receive a So it doesn't receive an I think they're of limited use to user application code because you have to be very careful about what you do in the implementation. |
Beta Was this translation helpful? Give feedback.
-
@peterfranciscook perhaps something like this: interface ClientLifecycleListener {
/**
* Called when {@link OpcUaClient#connect()} has been called, but the connection has not yet been
* established.
*
* @param client the client that is connecting.
*/
void onConnectBegin(OpcUaClient client);
/**
* Called after the Client has successfully connected to the Server and activated a Session.
*
* @param client the client that has connected successfully.
*/
void onConnectSuccess(OpcUaClient client);
/**
* Called if the Client failed to connect to the Server or activate a Session.
*
* @param client the client that failed to connect.
* @param failure the {@link Throwable} that caused the failure.
*/
void onConnectFailure(OpcUaClient client, Throwable failure);
/**
* Called when {@link OpcUaClient#disconnect()} has been called, but the disconnection has not yet
* completed.
*
* @param client the client that is disconnecting.
*/
void onDisconnectBegin(OpcUaClient client);
/**
* Called after the Client has successfully disconnected from the Server.
*
* @param client the client that has disconnected successfully.
*/
void onDisconnectSuccess(OpcUaClient client);
/**
* Called if the Client failed to disconnect cleanly from the Server.
*
* @param client the client that failed to disconnect.
* @param failure a {@link Throwable} describing the cause of the failure.
*/
void onDisconnectFailure(OpcUaClient client, Throwable failure);
/**
* Called when the Client is attempting to reconnect to the Server after a disconnection.
*
* <p>"Reconnecting" covers a broad range of actions, including re-establishing the secure
* channel, re-activating the existing Session or creating a new Session, transferring
* Subscriptions if necessary, etc...
*
* @param client the client that is attempting to reconnect.
*/
void onReconnectBegin(OpcUaClient client);
/**
* Called after the Client has successfully reconnected to the Server and either re-activated or
* created a new Session.
*
* @param client the client that has reconnected successfully.
*/
void onReconnectSuccess(OpcUaClient client);
/**
* Called if the Client failed to reconnect to the Server or reactivate a Session.
*
* @param client the client that failed to reconnect.
* @param failure a {@link Throwable} describing the cause of the failure.
*/
void onReconnectFailure(OpcUaClient client, Throwable failure);
/**
* Called when the Client has lost its connection to the Server.
*
* <p>This may be due to a network failure, server shutdown, or other reasons.
*
* @param client the client that has lost its connection.
* @param cause a {@link Throwable} describing the cause of the connection loss.
*/
void onConnectionLost(OpcUaClient client, Throwable cause);
} Though, I'm guessing what would be the most useful callbacks ( |
Beta Was this translation helpful? Give feedback.
-
My feedback on writing an implementation of The Since my (short-lived / one-shot) initializer classes/services need an **well, basically a factory method, it's a guice Provider |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a few classes in my OpcUa module that spin up a thread pool and do a some work when my app bootstraps (tree grokking, codec registration, node subscription, etc) and nothing after that.
I originally wrote these as guava idle services (
... extends AbstractIdleService
) but have begun refactoring them to implement the miloSessionInitializer
interface instead.Observation: the
SessionInitializer::initialize
method uses theUaStackClient
interface rather than theUaClient
interface.UaStackClient::getDynamicDataTypeManager
in one of my SessionInitializer impl classes returns the same object as callingOpcUaClient::getDynamicDataTypeManager
elsewhere in the code, I was inclined to think yes...OpcUaClient
class more or less answers the question by revealing that it contains aUaStackClient
delegate/member.Apart from general curiosity, the reason I'd like to know more about it is I am currently hung up refactoring one of my
AbstractIdleService
asSessionInitializer
becauseUaStackClient
doesn't have thegetAddressSpace
method, which the service uses to grok the OpcUa tree (uses only 2 methods fromAddressSpace
-getNodeAsync(NodeId nodeId)
andbrowseAsync(NodeId nodeId)
.One route I haven't gone down is using Guice to fetch the
@Singleton OpcUaClient
instance from the injector because this will create a circular dependency as I add theSessionInitializer
s to theOpcUaClient
in my module's@Provides
(akin to a factory method if you're not familiar with Guice) methods forUaClient
. Slightly better than that could be to inject aProvider<AddressSpace>
into theSessionInitializer
to delay initialization and break the circular dependency (the provider would have theUaClient
injected, and returnUaClient::getAddressSpace()
from itsget()
method).Before I get into the weeds with DI hacks, I'd like to know if there's some alternative API for browsing the tree with the
UaStackClient
instance passed toSessionInitializer::initialize
Beta Was this translation helpful? Give feedback.
All reactions