public abstract class EventManager extends ServiceManagerBase implements CallableListener
The base implementation simply dispatches the calls to the registered listener.
| Modifier and Type | Field and Description |
|---|---|
protected AtomicReference<EventManagerListener> |
listener |
protected static org.slf4j.Logger |
logger |
protected static EventFilterResult |
RESULT_OK |
| Constructor and Description |
|---|
EventManager(NodeManager nodeManager)
The constructor used to create a new EventManager.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterCreateMonitoredEventItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredEventItem item) |
protected void |
afterDeleteMonitoredEventItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredEventItem item) |
protected void |
afterModifyMonitoredEventItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredEventItem item) |
static ByteString |
createEventId(long value)
Deprecated.
use
ByteString.fromLong(long) instead (this method delegates to it). |
static ByteString |
createFullEventId(ByteString userEventId)
Creates a new eventId using a user specific ID.
|
protected void |
createMonitoredEventItem(ServiceContext serviceContext,
Subscription subscription,
NodeId nodeId,
EventFilter filter,
EventFilterResult eventFilterResult) |
protected void |
deleteMonitoredEventItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredEventItem monitoredItem) |
static ByteString |
extractUserEventId(ByteString fullEventId)
Extract the custom part from the event ID by removing the first 16 bytes (returns null if given
less than 16 bytes
ByteString.getLength(). |
protected void |
fireConditionRefresh(ServiceContext serviceContext,
Subscription subscription) |
protected void |
fireConditionRefresh2(ServiceContext serviceContext,
MonitoredEventItem item) |
EventManagerListener |
getListener()
The listener implementation that gets notified about event manager related actions.
|
NodeManager |
getNodeManager()
The NodeManager that the event manager is serving.
|
protected boolean |
methodEqualsIdOrName(UaMethod method,
NodeId methodId,
String methodName) |
protected void |
modifyMonitoredEventItem(ServiceContext serviceContext,
Subscription subscription,
MonitoredEventItem item,
EventFilter eventFilter,
EventFilterResult eventFilterResult) |
boolean |
onCall(ServiceContext serviceContext,
NodeId objectId,
UaNode object,
NodeId methodId,
UaMethod method,
Variant[] inputArguments,
StatusCode[] inputArgumentResults,
DiagnosticInfo[] inputArgumentDiagnosticInfos,
Variant[] output)
A method call notification.
|
protected abstract void |
refreshItem(MonitoredEventItem item)
Handle refreshing the item in the context of a ConditionRefresh or ConditionRefresh2 Method
Call.
|
protected void |
refreshItems(ServiceContext serviceContext,
Subscription subscription)
Handles condition refresh for a subscription.
|
void |
setListener(EventManagerListener l)
Define a listener to the Event Manager to get notifications about client actions.
|
arrayDimensionsMatch, checkIsMethod, checkIsValueNode, checkIsVariable, checkIsVariableOrVariableType, dataTypeEquals, getNode, getNode, getNode, getNode, getNodeManagerTable, getServer, getSubscriptionManager, invalidatePreviousNodeCache, isValueNode, isVariable, listenerError, requireUaNodeprotected static final org.slf4j.Logger logger
protected static final EventFilterResult RESULT_OK
protected final AtomicReference<EventManagerListener> listener
public EventManager(NodeManager nodeManager)
The event manager is automatically connected to the node manager.
nodeManager - the node manager that the event manager is serving. Must not be null.@Deprecated public static ByteString createEventId(long value)
ByteString.fromLong(long) instead (this method delegates to it).ByteString.public static ByteString createFullEventId(ByteString userEventId)
UUID.randomUUID()
converted via ByteString.fromUUID(UUID). The given userEventId is
ByteString.append(ByteString) to this. Returns just the base ID if given null/empty
userEventId.
The method is used from triggerEvent methods of the Event types and and you do not normally need to use it.
You can use createEventId(long) to create the user specific part which you can provide
to this method or to triggerEvent.
Use #extractUserEventId(byte[]) to get the userEventId out of a full event ID.
public static ByteString extractUserEventId(ByteString fullEventId)
ByteString.getLength().public EventManagerListener getListener()
public NodeManager getNodeManager()
public boolean onCall(ServiceContext serviceContext, NodeId objectId, UaNode object, NodeId methodId, UaMethod method, Variant[] inputArguments, StatusCode[] inputArgumentResults, DiagnosticInfo[] inputArgumentDiagnosticInfos, Variant[] output) throws StatusException
CallableListenerUse onCall to check whether the called method is the one that you handle. If so, return true, and set the outputs. Do not create a new array for the outputs, just assign your values in there - it is already created for the length defined by the OutputArguments of the UaMethod.
If you find errors in the inputArguments, fill in the inputArgumentResults and inputArgumentDiagnosticInfos respectively. They are also preallocated.
onCall in interface CallableListenerobjectId - the ID of the node whose method is being calledobject - the object node whose method is being called, if availablemethodId - the ID of the method being calledmethod - the method node being called, if availableinputArguments - input argument valuesinputArgumentResults - room for argument errors. Fill in the array if you encounter errors
in the values.inputArgumentDiagnosticInfos - room for diagnostic info, in case of errors.output - room for output values. The array is pre-created, so just fill in the values.StatusException - if there are errors in the method handling. For example, if you set
inputArgumentResults, you should throw a StatusException with
StatusCodes.Bad_InvalidArgumentpublic void setListener(EventManagerListener l)
The listener gives you a simple mechanism to react to actions in any node manager. The alternative is to implement your own event manager, but the listener is typically a simpler way to do the same.
l - your EventManagerListener implementation. Use null to clear the setting (it will
change the listener to an internal NULL_LISTENER).EventManagerListenerprotected void afterCreateMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, MonitoredEventItem item)
serviceContext - subscription - item - protected void afterDeleteMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, MonitoredEventItem item)
serviceContext - subscription - item - protected void afterModifyMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, MonitoredEventItem item)
serviceContext - subscription - item - protected void createMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, NodeId nodeId, EventFilter filter, EventFilterResult eventFilterResult) throws StatusException
StatusExceptionprotected void deleteMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, MonitoredEventItem monitoredItem)
protected void fireConditionRefresh(ServiceContext serviceContext, Subscription subscription) throws StatusException
StatusExceptionprotected void fireConditionRefresh2(ServiceContext serviceContext, MonitoredEventItem item) throws StatusException
StatusExceptionprotected boolean methodEqualsIdOrName(UaMethod method, NodeId methodId, String methodName)
method - methodId - methodName - protected void modifyMonitoredEventItem(ServiceContext serviceContext, Subscription subscription, MonitoredEventItem item, EventFilter eventFilter, EventFilterResult eventFilterResult) throws StatusException
StatusExceptionprotected abstract void refreshItem(MonitoredEventItem item)
protected void refreshItems(ServiceContext serviceContext, Subscription subscription) throws StatusException
serviceContext - the client calling context.subscription - must not be nullStatusException - if refresh is not allowed or cannot be doneCopyright © 2026. All rights reserved.