/** {@inheritDoc} */ public boolean unregisterBroadcastStream(IScope scope, String name, IBroadcastStream bs) { if (log.isDebugEnabled()) { log.debug("Unregistering - name: {} stream: {} scope: {}", new Object[] {name, bs, scope}); ((Scope) scope).dump(); } IBroadcastScope broadcastScope = scope.getBroadcastScope(name); if (bs != null) { log.debug("Unsubscribing scope {} from provider {}", broadcastScope, bs.getProvider()); broadcastScope.unsubscribe(bs.getProvider()); } // if the scope has no listeners try to remove it if (!((BasicScope) broadcastScope).hasEventListeners()) { if (log.isDebugEnabled()) { log.debug("Scope has no event listeners attempting removal"); } scope.removeChildScope(broadcastScope); } // verify that scope was removed return scope.getBasicScope(ScopeType.BROADCAST, name) == null; }
/** {@inheritDoc} */ public boolean registerBroadcastStream(IScope scope, String name, IBroadcastStream bs) { if (log.isDebugEnabled()) { log.debug("Registering - name: {} stream: {} scope: {}", new Object[] {name, bs, scope}); ((Scope) scope).dump(); } IBroadcastScope broadcastScope = scope.getBroadcastScope(name); if (broadcastScope == null) { log.debug("Creating a new scope"); broadcastScope = new BroadcastScope(scope, name); if (scope.addChildScope(broadcastScope)) { log.debug("Broadcast scope added"); } else { log.warn("Broadcast scope was not added to {}", scope); } } // set the client broadcast stream if we have a broadcast scope if (broadcastScope != null && bs instanceof IClientBroadcastStream) { broadcastScope.setClientBroadcastStream((IClientBroadcastStream) bs); } if (log.isDebugEnabled()) { log.debug("Subscribing scope {} to provider {}", broadcastScope, bs.getProvider()); } return broadcastScope.subscribe(bs.getProvider(), null); }