## org.red5.server.adapter
Class StatefulScopeWrappingAdapter

    java.lang.Object
      org.red5.server.adapter.AbstractScopeAdapter
          org.red5.server.adapter.StatefulScopeWrappingAdapter

All Implemented Interfaces:
  AttributeStoreMBean, IEventHandler, IAttributeStore, IScopeAware, IScopeHandler

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 Summary
`protected List<PluginDescriptor>` `plugins` List of plug-in descriptors
`protected IScope` `scope` Wrapped scope

Constructor Summary
`StatefulScopeWrappingAdapter()`

Method Summary
`boolean` `createChildScope(String name)` Creates child scope
`Object` `getAttribute(String name)` Return the value for a given attribute.
`Object` `getAttribute(String name, Object defaultValue)` Return the value for a given attribute and set it if it doesn't exist.
`Set<String>` `getAttributeNames()` Get the attribute names.
`Map<String,Object>` `getAttributes()` Wrapper for Scope#getAttributes
`IScope` `getChildScope(String name)` Return child scope
`Iterator<String>` `getChildScopeNames()` Iterator for child scope names
`Set<IClient>` `getClients()` Getter for set of clients
`Collection<Set<IConnection>>` `getConnections()` Returns all connections in the scope
`IContext` `getContext()` Getter for context
`int` `getDepth()` Getter for depth
`String` `getName()` Getter for name
`IScope` `getParent()` Return parent scope
`String` `getPath()` Getter for stateful scope path
`List<PluginDescriptor>` `getPlugins()` Returns any plug-ins descriptors added
`Resource` `getResource(String path)` Return resource by name
`Resource[]` `getResources(String pattern)` Returns array of resources (as Spring core Resource class instances)
`IScope` `getScope()` Getter for wrapped scope
`boolean` `hasAttribute(String name)` Check the object has an attribute.
`boolean` `hasChildScope(String name)` Whether this scope has a child scope with given name
`boolean` `hasParent()` If this scope has a parent
`Set<IConnection>` `lookupConnections(IClient client)`
`boolean` `removeAttribute(String name)` Remove an attribute.
`void` `removeAttributes()` Remove all attributes.
`boolean` `setAttribute(String name, Object value)` Set an attribute on this object.
`void` `setAttributes(IAttributeStore values)` Set multiple attributes on this object.
`void` `setAttributes(Map<String,Object> values)` Set multiple attributes on this object.
`void` `setPlugins(List<PluginDescriptor> plugins)` Adds a list of plug-in descriptors
`void` `setScope(IScope scope)` Set the scope the object is located in.

Methods inherited from class org.red5.server.adapter.AbstractScopeAdapter
`addChildScope, connect, disconnect, handleEvent, join, leave, removeChildScope, serviceCall, setCanCallService, setCanConnect, setCanStart, setJoin, start, stop`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### scope

    protected IScope scope

  Wrapped scope

### plugins

    protected List<PluginDescriptor> plugins

  List of plug-in descriptors

Constructor Detail

### StatefulScopeWrappingAdapter

    public StatefulScopeWrappingAdapter()

Method Detail

### 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` -

### getAttribute

    public Object getAttribute(String name)

  Return the value for a given attribute.

  Specified by:
    `getAttribute` in interface `AttributeStoreMBean`
  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 `AttributeStoreMBean`
  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 `AttributeStoreMBean`
  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 `AttributeStoreMBean`
  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 `AttributeStoreMBean`
  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 `AttributeStoreMBean`
  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 `AttributeStoreMBean`
  Specified by:
    `removeAttributes` in interface `IAttributeStore`

### setAttribute

    public boolean setAttribute(String name,
                                Object value)

  Set an attribute on this object.

  Specified by:
    `setAttribute` in interface `AttributeStoreMBean`
  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 void setAttributes(IAttributeStore values)

  Set multiple attributes on this object.

  Specified by:
    `setAttributes` in interface `IAttributeStore`
  Parameters:
    `values` - the attributes to set

### setAttributes

    public void setAttributes(Map<String,Object> values)

  Set multiple attributes on this object.

  Specified by:
    `setAttributes` in interface `IAttributeStore`
  Parameters:
    `values` - the attributes to set

### 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 Iterator<String> getChildScopeNames()

  Iterator for child scope names

  Returns:
    Iterator for 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:
    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

### lookupConnections

    public Set<IConnection> lookupConnections(IClient client)

### 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

Copyright © 2006-2010 The Red5 Project