Skip to content

Commit

Permalink
~ documentation/warning on internal EventBus
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinherron committed Apr 26, 2022
1 parent 8b8544a commit 776691f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Expand Up @@ -198,14 +198,15 @@ public ServerDiagnosticsSummary getDiagnosticsSummary() {
}

/**
* Get the Server-wide {@link EventBus}.
* Get an internal EventBus used to decouple communication between internal components of the
* Server implementation.
* <p>
* Events posted to the EventBus are delivered synchronously to registered subscribers.
* This EventBus is not intended for use by user implementations.
*
* @return the Server-wide {@link EventBus}.
* @return an internal EventBus used to decouple communication between internal components of
* the Server implementation.
*/
@Deprecated
public EventBus getEventBus() {
public EventBus getInternalEventBus() {
return eventBus;
}

Expand Down
Expand Up @@ -100,7 +100,7 @@ protected void onStartup() {
diagnosticsEnabled.set(diagnosticsNode.getEnabledFlag());

if (diagnosticsEnabled.get()) {
server.getEventBus().register(eventSubscriber = new EventSubscriber());
server.getInternalEventBus().register(eventSubscriber = new EventSubscriber());
}

attributeObserver = (node, attributeId, value) -> {
Expand All @@ -115,11 +115,11 @@ protected void onStartup() {
getSubscriptions().forEach(this::createSubscriptionDiagnosticsNode);

if (eventSubscriber == null) {
server.getEventBus().register(eventSubscriber = new EventSubscriber());
server.getInternalEventBus().register(eventSubscriber = new EventSubscriber());
}
} else if (previous && !current) {
if (eventSubscriber != null) {
server.getEventBus().unregister(eventSubscriber);
server.getInternalEventBus().unregister(eventSubscriber);
eventSubscriber = null;
}

Expand Down Expand Up @@ -159,7 +159,7 @@ protected void onShutdown() {
}

if (eventSubscriber != null) {
server.getEventBus().unregister(eventSubscriber);
server.getInternalEventBus().unregister(eventSubscriber);
eventSubscriber = null;
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 the Eclipse Milo Authors
* Copyright (c) 2022 the Eclipse Milo Authors
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -168,13 +168,13 @@ public void createSubscription(ServiceRequest service) {
subscriptions.put(subscriptionId, subscription);
server.getSubscriptions().put(subscriptionId, subscription);
server.getDiagnosticsSummary().getCumulatedSubscriptionCount().increment();
server.getEventBus().post(new SubscriptionCreatedEvent(subscription));
server.getInternalEventBus().post(new SubscriptionCreatedEvent(subscription));

subscription.setStateListener((s, ps, cs) -> {
if (cs == State.Closed) {
subscriptions.remove(s.getId());
server.getSubscriptions().remove(s.getId());
server.getEventBus().post(new SubscriptionDeletedEvent(subscription));
server.getInternalEventBus().post(new SubscriptionDeletedEvent(subscription));
}
});

Expand Down Expand Up @@ -233,7 +233,7 @@ public void deleteSubscription(ServiceRequest service) throws UaException {

if (subscription != null) {
server.getSubscriptions().remove(subscription.getId());
server.getEventBus().post(new SubscriptionDeletedEvent(subscription));
server.getInternalEventBus().post(new SubscriptionDeletedEvent(subscription));

List<BaseMonitoredItem<?>> deletedItems = subscription.deleteSubscription();

Expand Down Expand Up @@ -1204,7 +1204,7 @@ public void sessionClosed(boolean deleteSubscriptions) {

if (deleteSubscriptions) {
server.getSubscriptions().remove(s.getId());
server.getEventBus().post(new SubscriptionDeletedEvent(s));
server.getInternalEventBus().post(new SubscriptionDeletedEvent(s));

List<BaseMonitoredItem<?>> deletedItems = s.deleteSubscription();

Expand Down Expand Up @@ -1239,13 +1239,13 @@ public void sessionClosed(boolean deleteSubscriptions) {
*/
public void addSubscription(Subscription subscription) {
subscriptions.put(subscription.getId(), subscription);
server.getEventBus().post(new SubscriptionCreatedEvent(subscription));
server.getInternalEventBus().post(new SubscriptionCreatedEvent(subscription));

subscription.setStateListener((s, ps, cs) -> {
if (cs == State.Closed) {
subscriptions.remove(s.getId());
server.getSubscriptions().remove(s.getId());
server.getEventBus().post(new SubscriptionDeletedEvent(s));
server.getInternalEventBus().post(new SubscriptionDeletedEvent(s));
}
});
}
Expand All @@ -1258,7 +1258,7 @@ public void addSubscription(Subscription subscription) {
*/
public Subscription removeSubscription(UInteger subscriptionId) {
Subscription subscription = subscriptions.remove(subscriptionId);
server.getEventBus().post(new SubscriptionDeletedEvent(subscription));
server.getInternalEventBus().post(new SubscriptionDeletedEvent(subscription));

if (subscription != null) {
subscription.setStateListener(null);
Expand Down

0 comments on commit 776691f

Please sign in to comment.