Package org.red5.server.api.scope

Examples of org.red5.server.api.scope.IScope


   *
   * @param from Scope to find root for
   * @return  Root scope object
   */
  public static IScope findRoot(IScope from) {
    IScope current = from;
    while (current.hasParent()) {
      current = current.getParent();
    }
    return current;
  }
View Full Code Here


   *
   * @param from Scope to find application for
   * @return    Application scope.
   */
  public static IScope findApplication(IScope from) {
    IScope current = from;
    while (current.hasParent() && !current.getType().equals(ScopeType.APPLICATION)) {
      current = current.getParent();
    }
    return current;
  }
View Full Code Here

      return scope.getAttribute(attr);
    }

    Object handler = null;
    if (checkHandler) {
      IScope current = scope;
      while (current != null) {
        IScopeHandler scopeHandler = current.getHandler();
        if (intf.isInstance(scopeHandler)) {
          handler = scopeHandler;
          break;
        }
        if (!current.hasParent()) {
          break;
        }
        current = current.getParent();
      }
    }

    if (handler == null && IScopeService.class.isAssignableFrom(intf)) {
      // we've got an IScopeService, try to lookup bean
View Full Code Here

   */
  public static void invokeOnAllConnections(String method, Object[] params, IPendingServiceCallback callback) {
    IConnection conn = Red5.getConnectionLocal();
    if (conn != null) {
      log.debug("Connection for invoke on all: {}", conn);
      IScope scope = conn.getScope();
      log.debug("Scope for invoke on all: {}", scope);
      invokeOnAllScopeConnections(scope, method, params, callback);
    } else {
      log.warn("Connection was null (thread local), scope cannot be located and cannot execute invoke request");
    }
View Full Code Here

   */
  public static void notifyOnAllConnections(String method, Object[] params) {
    IConnection conn = Red5.getConnectionLocal();
    if (conn != null) {
      log.debug("Connection for notify on all: {}", conn);
      IScope scope = conn.getScope();
      log.debug("Scope for notify on all: {}", scope);
      notifyOnAllScopeConnections(scope, method, params);
    } else {
      log.warn("Connection was null (thread local), scope cannot be located and cannot execute notify request");
    }
View Full Code Here

      case PipeConnectionEvent.CONSUMER_DISCONNECT:
      case PipeConnectionEvent.PROVIDER_DISCONNECT:
        if (compCounter.decrementAndGet() <= 0) {
          // XXX should we synchronize parent before removing?
          if (hasParent()) {
            IScope parent = getParent();
            IProviderService providerService = (IProviderService) parent.getContext().getBean(IProviderService.BEAN_NAME);
            removed = providerService.unregisterBroadcastStream(parent, getName());
          } else {
            removed = true;
          }
        }
View Full Code Here

    log.debug("resolveScope - root: {} path: {}", root, path);
    if (root == null) {
      throw new ScopeException("Null root scope");
    }
    // start from root scope
    IScope scope = root;
    // if there's no path return root scope (e.i. root path scope)
    if (StringUtils.isNotEmpty(path)) {
      // Split path to parts
      final String[] parts = path.split("/");
      log.debug("Split path: {}", Arrays.toString(parts));
      // Iterate thru them, skip empty parts
      for (String child : parts) {
        if (StringUtils.isEmpty(child)) {
          // skip empty path elements
          continue;
        }
        // if scope does not exist and we are not in the root, create a child scope
        if (!scope.hasChildScope(child) && !scope.equals(root)) {
          scope.createChildScope(child);
        }
        // get child scope
        scope = scope.getScope(child);
        // if the scope is null then the room was not found
        if (scope == null) {
          throw new ScopeNotFoundException(scope, child);
        }
        // some scopes don't implement IScope, such as SharedObjectScope
        if (scope instanceof IScope) {
          if (scope.getType().equals(ScopeType.APPLICATION) && ((WebScope) scope).isShuttingDown()) {
            throw new ScopeShuttingDownException(scope);
          }
        }
      }
    }
View Full Code Here

  private void sendStartNotifications(IEventListener source) {
    if (sendStartNotification) {
      // notify handler that stream starts recording/publishing
      sendStartNotification = false;
      if (source instanceof IConnection) {
        IScope scope = ((IConnection) source).getScope();
        if (scope.hasHandler()) {
          final Object handler = scope.getHandler();
          if (handler instanceof IStreamAwareScopeHandler) {
            if (recordingListener != null && recordingListener.get().isRecording()) {
              // callback for record start
              ((IStreamAwareScopeHandler) handler).streamRecordStart(this);
            } else {
View Full Code Here

  /** {@inheritDoc} */
  public void start() {
    //ensure the play engine exists
    if (engine == null) {
      IScope scope = getScope();
      if (scope != null) {
        IContext ctx = scope.getContext();
        if (ctx.hasBean(ISchedulingService.BEAN_NAME)) {
          schedulingService = (ISchedulingService) ctx.getBean(ISchedulingService.BEAN_NAME);
        } else {
          //try the parent
          schedulingService = (ISchedulingService) scope.getParent().getContext().getBean(ISchedulingService.BEAN_NAME);
        }
        IConsumerService consumerService = null;
        if (ctx.hasBean(IConsumerService.KEY)) {
          consumerService = (IConsumerService) ctx.getBean(IConsumerService.KEY);
        } else {
          //try the parent
          consumerService = (IConsumerService) scope.getParent().getContext().getBean(IConsumerService.KEY);
        }
        IProviderService providerService = null;
        if (ctx.hasBean(IProviderService.BEAN_NAME)) {
          providerService = (IProviderService) ctx.getBean(IProviderService.BEAN_NAME);
        } else {
          //try the parent
          providerService = (IProviderService) scope.getParent().getContext().getBean(IProviderService.BEAN_NAME);
        }

        engine = new PlayEngine.Builder(this, schedulingService, consumerService, providerService).build();
      } else {
        log.info("Scope was null on start");
View Full Code Here

  private void setupScopes() {
    log.debug("-------------------------------------------------------------setupScopes");
    //Room 1
    // /default/junit/room1
    assertFalse(appScope.createChildScope("room1")); // room1 is defined in context xml file, this should fail
    IScope room1 = appScope.getScope("room1");
    log.debug("Room 1: {}", room1);
    assertTrue(room1.getDepth() == 2);
    IContext rmCtx1 = room1.getContext();
    log.debug("Context 1: {}", rmCtx1);
    //Room 2
    // /default/junit/room1/room2
    if (room1.getScope("room2") == null) {
      assertTrue(room1.createChildScope("room2"));
    }
    IScope room2 = room1.getScope("room2");
    log.debug("Room 2: {}", room2);
    assertNotNull(room2);
    assertTrue(room2.getDepth() == 3);
    IContext rmCtx2 = room2.getContext();
    log.debug("Context 2: {}", rmCtx2);
    //Room 3
    // /default/junit/room1/room2/room3
    if (room2.getScope("room3") == null) {
      assertTrue(room2.createChildScope("room3"));
    }
    IScope room3 = room2.getScope("room3");
    log.debug("Room 3: {}", room3);
    assertNotNull(room3);
    assertTrue(room3.getDepth() == 4);
    IContext rmCtx3 = room3.getContext();
    log.debug("Context 3: {}", rmCtx3);
    //Room 4 attaches at Room 1 (per bug example)
    // /default/junit/room1/room4
    if (room1.getScope("room4") == null) {
      assertTrue(room1.createChildScope("room4"));
    }
    IScope room4 = room1.getScope("room4");
    log.debug("Room 4: {}", room4);
    assertNotNull(room4);
    assertTrue(room4.getDepth() == 3);
    IContext rmCtx4 = room4.getContext();
    log.debug("Context 4: {}", rmCtx4);
    //Room 5
    // /default/junit/room1/room4/room5
    if (room4.getScope("room5") == null) {
      assertTrue(room4.createChildScope("room5"));
    }
    IScope room5 = room4.getScope("room5");
    log.debug("Room 5: {}", room5);
    assertNotNull(room5);
    assertTrue(room5.getDepth() == 4);
    IContext rmCtx5 = room5.getContext();
    log.debug("Context 5: {}", rmCtx5);
  }
View Full Code Here

TOP

Related Classes of org.red5.server.api.scope.IScope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.