/** {@inheritDoc} */ public IMessageInput getLiveProviderInput(IScope scope, String name, boolean needCreate) { log.debug("Get live provider input for {} scope: {}", name, scope); // make sure the create is actually needed IBroadcastScope broadcastScope = scope.getBroadcastScope(name); if (broadcastScope == null && needCreate) { synchronized (scope) { // re-check if another thread already created the scope broadcastScope = scope.getBroadcastScope(name); if (broadcastScope == null) { broadcastScope = new BroadcastScope(scope, name); scope.addChildScope(broadcastScope); } } } return broadcastScope; }
/** {@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); }