Package org.red5.server.adapter
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 Summary
Modifier and TypeFieldDescriptionprotected List<PluginDescriptor>
List of plug-in descriptorsprotected IScope
Wrapped scope -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
createChildScope
(String name) Creates child scopegetAttribute
(String name) Return the value for a given attribute.getAttribute
(String name, Object defaultValue) Return the value for a given attribute and set it if it doesn't exist.Get the attribute names.Wrapper for Scope#getAttributesgetChildScope
(String name) Return child scopeIterator for child scope namesGetter for set of clientsReturns all connections in the scopeGetter for contextint
getDepth()
Getter for depthgetName()
Getter for nameReturn parent scopegetPath()
Getter for stateful scope pathReturns any plug-ins descriptors addedgetResource
(String path) Return resource by nameResource[]
getResources
(String pattern) Returns array of resources (as Spring core Resource class instances)getScope()
Getter for wrapped scopeboolean
hasAttribute
(String name) Check the object has an attribute.boolean
hasChildScope
(String name) Whether this scope has a child scope with given nameboolean
If this scope has a parentlookupConnections
(IClient client) Returns all connections for a given clientboolean
removeAttribute
(String name) Remove an attribute.void
Remove all attributes.boolean
setAttribute
(String name, Object value) Set an attribute on this object.boolean
setAttributes
(Map<String, Object> attributes) Set multiple attributes on this object.boolean
setAttributes
(IAttributeStore attributes) Set multiple attributes on this object.void
setPlugins
(List<PluginDescriptor> plugins) Adds a list of plug-in descriptorsvoid
Set the scope the object is located in.int
size()
Size of the attribute store.Methods inherited from class org.red5.server.adapter.AbstractScopeAdapter
addChildScope, checkBandwidth, checkBandwidthUp, connect, disconnect, handleEvent, join, leave, removeChildScope, serviceCall, setCanCallService, setCanConnect, setCanStart, setJoin, start, stop
-
Field Details
-
scope
Wrapped scope -
plugins
List of plug-in descriptors
-
-
Constructor Details
-
StatefulScopeWrappingAdapter
public StatefulScopeWrappingAdapter()
-
-
Method Details
-
setScope
Set the scope the object is located in.- Specified by:
setScope
in interfaceIScopeAware
- Parameters:
scope
- Scope for this object
-
getScope
Getter for wrapped scope- Returns:
- Wrapped scope
-
getPlugins
Returns any plug-ins descriptors added- Returns:
- plug-in descriptor list
-
setPlugins
Adds a list of plug-in descriptors- Parameters:
plugins
- plugins
-
getAttribute
Return the value for a given attribute.- Specified by:
getAttribute
in interfaceIAttributeStore
- Parameters:
name
- the name of the attribute to get- Returns:
- the attribute value or null if the attribute doesn't exist
-
getAttribute
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 interfaceIAttributeStore
- Parameters:
name
- the name of the attribute to getdefaultValue
- the value of the attribute to set if the attribute doesn't exist- Returns:
- the attribute value
-
getAttributeNames
Get the attribute names. The resulting set will be read-only.- Specified by:
getAttributeNames
in interfaceAttributeStoreMXBean
- Specified by:
getAttributeNames
in interfaceIAttributeStore
- Returns:
- set containing all attribute names
-
getAttributes
Wrapper for Scope#getAttributes- Specified by:
getAttributes
in interfaceIAttributeStore
- Returns:
- Scope attributes map
-
hasAttribute
Check the object has an attribute.- Specified by:
hasAttribute
in interfaceAttributeStoreMXBean
- Specified by:
hasAttribute
in interfaceIAttributeStore
- Parameters:
name
- the name of the attribute to check- Returns:
- true if the attribute exists otherwise false
-
removeAttribute
Remove an attribute.- Specified by:
removeAttribute
in interfaceAttributeStoreMXBean
- Specified by:
removeAttribute
in interfaceIAttributeStore
- 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 interfaceAttributeStoreMXBean
- Specified by:
removeAttributes
in interfaceIAttributeStore
-
size
public int size()Size of the attribute store.- Specified by:
size
in interfaceIAttributeStore
- Returns:
- count of attributes
-
setAttribute
Set an attribute on this object.- Specified by:
setAttribute
in interfaceIAttributeStore
- Parameters:
name
- the name of the attribute to changevalue
- the new value of the attribute- Returns:
- true if the attribute value changed otherwise false
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributes
in interfaceIAttributeStore
- Parameters:
attributes
- the attributes to set- Returns:
- true if the attribute values changed otherwise false
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributes
in interfaceIAttributeStore
- Parameters:
attributes
- the attributes to set- Returns:
- true if the attribute values changed otherwise false
-
createChildScope
Creates child scope- Parameters:
name
- Child scope name- Returns:
- true on success, false otherwise
-
getChildScope
Return child scope- Parameters:
name
- Child scope name- Returns:
- Child scope with given name
-
getChildScopeNames
Iterator for child scope names- Returns:
- collection of child scope names
-
getClients
Getter for set of clients- Returns:
- Set of clients
-
getConnections
Returns all connections in the scope- Returns:
- collection of a set of connections
-
lookupConnections
Returns all connections for a given client- Parameters:
client
- client- Returns:
- set of connections
-
getContext
Getter for context- Returns:
- Value for context
-
getDepth
public int getDepth()Getter for depth- Returns:
- Value for depth
-
getName
Getter for name- Returns:
- Value for name
-
getParent
Return parent scope- Returns:
- Parent scope
-
getPath
Getter for stateful scope path- Returns:
- Value for path
-
hasChildScope
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
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
Return resource by name- Parameters:
path
- Resource name- Returns:
- Resource with given name
-