Class StatefulScopeWrappingAdapter

java.lang.Object
org.red5.server.adapter.AbstractScopeAdapter
org.red5.server.adapter.StatefulScopeWrappingAdapter
All Implemented Interfaces:
IEventHandler, IAttributeStore, IScopeAware, IScopeHandler, AttributeStoreMXBean
Direct Known Subclasses:
MultiThreadedApplicationAdapter

public class StatefulScopeWrappingAdapter extends AbstractScopeAdapter implements IScopeAware, IAttributeStore
StatefulScopeWrappingAdapter class wraps stateful IScope functionality. That is, it has attributes that you can work with, subscopes, associated resources and connections.
  • Field Details

  • Constructor Details

    • StatefulScopeWrappingAdapter

      public StatefulScopeWrappingAdapter()
  • Method Details

    • setScope

      public void setScope(IScope scope)
      Set the scope the object is located in.
      Specified by:
      setScope in interface IScopeAware
      Parameters:
      scope - Scope for this object
    • getScope

      public IScope getScope()
      Getter for wrapped scope
      Returns:
      Wrapped scope
    • getPlugins

      public List<PluginDescriptor> getPlugins()
      Returns any plug-ins descriptors added
      Returns:
      plug-in descriptor list
    • setPlugins

      public void setPlugins(List<PluginDescriptor> plugins)
      Adds a list of plug-in descriptors
      Parameters:
      plugins - plugins
    • getAttribute

      public Object getAttribute(String name)
      Return the value for a given attribute.
      Specified by:
      getAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to get
      Returns:
      the attribute value or null if the attribute doesn't exist
    • getAttribute

      public Object getAttribute(String name, Object defaultValue)
      Return the value for a given attribute and set it if it doesn't exist. This is a utility function that internally performs the following code:
       if (!hasAttribute(name))
           setAttribute(name, defaultValue);
       return getAttribute(name);
       
      Specified by:
      getAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to get
      defaultValue - the value of the attribute to set if the attribute doesn't exist
      Returns:
      the attribute value
    • getAttributeNames

      public Set<String> getAttributeNames()
      Get the attribute names. The resulting set will be read-only.
      Specified by:
      getAttributeNames in interface AttributeStoreMXBean
      Specified by:
      getAttributeNames in interface IAttributeStore
      Returns:
      set containing all attribute names
    • getAttributes

      public Map<String,Object> getAttributes()
      Wrapper for Scope#getAttributes
      Specified by:
      getAttributes in interface IAttributeStore
      Returns:
      Scope attributes map
    • hasAttribute

      public boolean hasAttribute(String name)
      Check the object has an attribute.
      Specified by:
      hasAttribute in interface AttributeStoreMXBean
      Specified by:
      hasAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to check
      Returns:
      true if the attribute exists otherwise false
    • removeAttribute

      public boolean removeAttribute(String name)
      Remove an attribute.
      Specified by:
      removeAttribute in interface AttributeStoreMXBean
      Specified by:
      removeAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to remove
      Returns:
      true if the attribute was found and removed otherwise false
    • removeAttributes

      public void removeAttributes()
      Remove all attributes.
      Specified by:
      removeAttributes in interface AttributeStoreMXBean
      Specified by:
      removeAttributes in interface IAttributeStore
    • size

      public int size()
      Size of the attribute store.
      Specified by:
      size in interface IAttributeStore
      Returns:
      count of attributes
    • setAttribute

      public boolean setAttribute(String name, Object value)
      Set an attribute on this object.
      Specified by:
      setAttribute in interface IAttributeStore
      Parameters:
      name - the name of the attribute to change
      value - the new value of the attribute
      Returns:
      true if the attribute value changed otherwise false
    • setAttributes

      public boolean setAttributes(IAttributeStore attributes)
      Set multiple attributes on this object.
      Specified by:
      setAttributes in interface IAttributeStore
      Parameters:
      attributes - the attributes to set
      Returns:
      true if the attribute values changed otherwise false
    • setAttributes

      public boolean setAttributes(Map<String,Object> attributes)
      Set multiple attributes on this object.
      Specified by:
      setAttributes in interface IAttributeStore
      Parameters:
      attributes - the attributes to set
      Returns:
      true if the attribute values changed otherwise false
    • createChildScope

      public boolean createChildScope(String name)
      Creates child scope
      Parameters:
      name - Child scope name
      Returns:
      true on success, false otherwise
    • getChildScope

      public IScope getChildScope(String name)
      Return child scope
      Parameters:
      name - Child scope name
      Returns:
      Child scope with given name
    • getChildScopeNames

      public Set<String> getChildScopeNames()
      Iterator for child scope names
      Returns:
      collection of child scope names
    • getClients

      public Set<IClient> getClients()
      Getter for set of clients
      Returns:
      Set of clients
    • getConnections

      public Collection<Set<IConnection>> getConnections()
      Returns all connections in the scope
      Returns:
      collection of a set of connections
    • lookupConnections

      public Set<IConnection> lookupConnections(IClient client)
      Returns all connections for a given client
      Parameters:
      client - client
      Returns:
      set of connections
    • getContext

      public IContext getContext()
      Getter for context
      Returns:
      Value for context
    • getDepth

      public int getDepth()
      Getter for depth
      Returns:
      Value for depth
    • getName

      public String getName()
      Getter for name
      Returns:
      Value for name
    • getParent

      public IScope getParent()
      Return parent scope
      Returns:
      Parent scope
    • getPath

      public String getPath()
      Getter for stateful scope path
      Returns:
      Value for path
    • hasChildScope

      public boolean hasChildScope(String name)
      Whether this scope has a child scope with given name
      Parameters:
      name - Child scope name
      Returns:
      true if it does have it, false otherwise
    • hasParent

      public boolean hasParent()
      If this scope has a parent
      Returns:
      true if this scope has a parent scope, false otherwise
    • getResources

      public Resource[] getResources(String pattern) throws IOException
      Returns array of resources (as Spring core Resource class instances)
      Parameters:
      pattern - Resource pattern
      Returns:
      Returns array of resources
      Throws:
      IOException - I/O exception
    • getResource

      public Resource getResource(String path)
      Return resource by name
      Parameters:
      path - Resource name
      Returns:
      Resource with given name