|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.red5.server.scope.BasicScope org.red5.server.scope.Scope
@ManagedResource(objectName="org.red5.server:type=Scope", description="Scope") public class Scope
The scope object.
A stateful object shared between a group of clients connected to the same context path. Scopes are arranged in a hierarchical way, so its possible for a scope to have a parent. If a client is connect to a scope then they are also connected to its parent scope. The scope object is used to access resources, shared object, streams, etc.
Scope layout:/Global scope - Contains application scopes /Application scope - Contains room, shared object, and stream scopes /Room scope - Contains other room, shared object, and / or stream scopes /Shared object scope - Contains shared object /Broadcast stream scope - Contains a broadcast stream
Nested Class Summary | |
---|---|
static class |
Scope.Builder
Builder pattern |
Field Summary | |
---|---|
protected AttributeStore |
attributes
Storage for scope attributes |
protected StatisticsCounter |
clientStats
Statistics about clients connected to the scope. |
protected StatisticsCounter |
connectionStats
Statistics about connections to the scope. |
protected Semaphore |
lock
Lock for critical sections, to prevent concurrent modification. |
protected static Logger |
log
|
protected ObjectName |
oName
Mbean object name. |
protected StatisticsCounter |
subscopeStats
Statistics about sub-scopes. |
Fields inherited from class org.red5.server.scope.BasicScope |
---|
keepDelay, keepOnDisconnect, listeners, name, parent, persistenceClass, persistent, store, type |
Fields inherited from interface org.red5.server.api.scope.IScope |
---|
SEPARATOR |
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver |
---|
CLASSPATH_ALL_URL_PREFIX |
Fields inherited from interface org.springframework.core.io.ResourceLoader |
---|
CLASSPATH_URL_PREFIX |
Constructor Summary | |
---|---|
Scope()
Creates a scope |
|
Scope(Scope.Builder builder)
Creates scope using a Builder |
Method Summary | |
---|---|
boolean |
addChildScope(IBasicScope scope)
Add child scope to this scope |
boolean |
connect(IConnection conn)
Connect to scope |
boolean |
connect(IConnection conn,
Object[] params)
Connect to scope with parameters. |
boolean |
createChildScope(String name)
Create child scope with given name |
void |
destroy()
Destroys scope |
void |
disconnect(IConnection conn)
Disconnect connection from scope |
void |
dispatchEvent(IEvent event)
Dispatches event (notifies all listeners) |
void |
dump()
|
static Scope |
from(CompositeData cd)
Allows for reconstruction via CompositeData. |
int |
getActiveClients()
Return current number of clients connected to the scope. |
int |
getActiveConnections()
Return current number of connections to the scope. |
int |
getActiveSubscopes()
Return number of currently existing subscopes. |
Object |
getAttribute(String name)
Get attribute by name |
Set<String> |
getAttributeNames()
Return attribute names |
Map<String,Object> |
getAttributes()
Return scope attributes |
IBasicScope |
getBasicScope(ScopeType type,
String name)
Return base scope of given type with given name |
Set<String> |
getBasicScopeNames(ScopeType type)
Return basic scope names matching given type |
IBroadcastScope |
getBroadcastScope(String name)
Return the broadcast scope for a given name |
ClassLoader |
getClassLoader()
Return current thread context classloader |
Set<IClient> |
getClients()
Return set of clients |
Collection<Set<IConnection>> |
getConnections()
Return connection iterator |
IContext |
getContext()
Return scope context. |
String |
getContextPath()
Return scope context path |
long |
getCreationTime()
Return the timestamp the object was created. |
int |
getDepth()
return scope depth |
boolean |
getEnabled()
Here for JMX only, uses isEnabled() |
IScopeHandler |
getHandler()
Return scope handler or parent's scope handler if this scope doesn't have one |
int |
getMaxClients()
Return maximum number of clients concurrently connected to the scope. |
int |
getMaxConnections()
Return maximum number of concurrent connections to the scope. |
int |
getMaxSubscopes()
Return maximum number of concurrently existing subscopes. |
IScope |
getParent()
Return parent scope |
String |
getPath()
Return scope path calculated from parent path and parent scope name |
Resource |
getResource(String path)
Return resource located at given path |
Resource[] |
getResources(String path)
Return array of resources from path string, usually used with pattern path |
boolean |
getRunning()
Here for JMX only, uses isEnabled() |
IScope |
getScope(String name)
Return child scope by name |
Set<String> |
getScopeNames()
Return child scope names iterator |
IServer |
getServer()
Return the server instance connected to this scope. |
Object |
getServiceHandler(String name)
Return service handler by name |
Set<String> |
getServiceHandlerNames()
Return set of service handler names. |
protected Map<String,Object> |
getServiceHandlers()
Return map of service handlers. |
protected Map<String,Object> |
getServiceHandlers(boolean allowCreate)
Return map of service handlers and optionally created it if it doesn't exist. |
IScopeStatistics |
getStatistics()
Return statistics informations about the scope. |
int |
getTotalClients()
Return total number of clients connected to the scope. |
int |
getTotalConnections()
Return total number of connections to the scope. |
int |
getTotalSubscopes()
Return total number of subscopes created. |
boolean |
handleEvent(IEvent event)
Handles event. |
boolean |
hasAttribute(String name)
Whether or not an attribute exists, keyed by the given name |
boolean |
hasChildScope(ScopeType type,
String name)
Check whether scope has child scope with given name and type |
boolean |
hasChildScope(String name)
Check whether scope has child scope with given name |
boolean |
hasContext()
Check if scope has a context |
boolean |
hasHandler()
Check if scope or it's parent has handler |
boolean |
hasParent()
Check if scope has parent scope |
void |
init()
Initialization actions, start if autostart is set to true |
boolean |
isEnabled()
Check if scope is enabled |
boolean |
isRunning()
Check if scope is in running state |
Set<IConnection> |
lookupConnections(IClient client)
Looks up connections for client |
protected void |
registerJMX()
|
void |
registerServiceHandler(String name,
Object handler)
Register service handler by name |
boolean |
removeAttribute(String name)
Remove attribute by name |
void |
removeChildren()
Removes all the child scopes |
void |
removeChildScope(IBasicScope scope)
Removes child scope |
boolean |
setAttribute(String name,
Object value)
Set attribute by name |
void |
setAutoStart(boolean autoStart)
Setter for autostart flag |
void |
setChildLoadPath(String pattern)
Setter for child load path. |
void |
setContext(IContext context)
Setter for context |
void |
setDepth(int depth)
Set scope depth |
void |
setEnabled(boolean enabled)
Enable or disable scope by setting enable flag |
void |
setHandler(IScopeHandler handler)
Setter for scope event handler |
void |
setName(String name)
Setter for scope name |
void |
setParent(IScope parent)
Setter for parent scope |
void |
setPersistenceClass(String persistenceClass)
Set scope persistence class |
boolean |
start()
Starts scope |
void |
stop()
Stops scope |
String |
toString()
|
void |
uninit()
Uninitialize scope and unregister from parent. |
protected void |
unregisterJMX()
|
void |
unregisterServiceHandler(String name)
Unregisters service handler by name |
Methods inherited from class org.red5.server.scope.BasicScope |
---|
addEventListener, equals, getEventListeners, getName, getStore, getType, hasEventListeners, hashCode, isValid, notifyEvent, removeEventListener, setKeepDelay |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.red5.server.api.scope.IBasicScope |
---|
getName, getStore, getType, isValid, setKeepDelay |
Methods inherited from interface org.red5.server.api.event.IEventListener |
---|
notifyEvent |
Methods inherited from interface org.red5.server.api.event.IEventObservable |
---|
addEventListener, getEventListeners, removeEventListener |
Methods inherited from interface org.red5.server.api.statistics.IScopeStatistics |
---|
getName |
Field Detail |
---|
protected static Logger log
protected final AttributeStore attributes
protected final StatisticsCounter clientStats
protected final StatisticsCounter connectionStats
protected final StatisticsCounter subscopeStats
protected Semaphore lock
protected ObjectName oName
Constructor Detail |
---|
@ConstructorProperties(value="") public Scope()
@ConstructorProperties(value="builder") public Scope(Scope.Builder builder)
builder
- Method Detail |
---|
public boolean addChildScope(IBasicScope scope)
addChildScope
in interface IScope
scope
- Child scope
true
on success (if scope has handler and it
accepts child scope addition), false
otherwisepublic boolean connect(IConnection conn)
connect
in interface IScope
conn
- Connection object
true
on success, false
otherwisepublic boolean connect(IConnection conn, Object[] params)
connect
in interface IScope
conn
- Connection objectparams
- Parameters passed with connection
true
on success, false
otherwisepublic boolean createChildScope(String name)
createChildScope
in interface IScope
createChildScope
in interface ScopeMXBean
name
- Child scope name
true
on success, false
otherwisepublic void destroy()
destroy
in interface ScopeMXBean
public void disconnect(IConnection conn)
disconnect
in interface IScope
conn
- Connection objectpublic void dispatchEvent(IEvent event)
dispatchEvent
in interface IEventDispatcher
dispatchEvent
in class BasicScope
event
- Event to dispatchpublic Object getAttribute(String name)
getAttribute
in interface IScope
public boolean setAttribute(String name, Object value)
setAttribute
in interface IScope
public boolean hasAttribute(String name)
hasAttribute
in interface IScope
public boolean removeAttribute(String name)
removeAttribute
in interface IScope
public Set<String> getAttributeNames()
getAttributeNames
in interface IScope
public Map<String,Object> getAttributes()
getAttributes
in interface IScope
public int getActiveClients()
getActiveClients
in interface IScopeStatistics
getActiveClients
in interface ScopeMXBean
public int getActiveConnections()
getActiveConnections
in interface IScopeStatistics
getActiveConnections
in interface ScopeMXBean
public int getActiveSubscopes()
getActiveSubscopes
in interface IScopeStatistics
getActiveSubscopes
in interface ScopeMXBean
public IBroadcastScope getBroadcastScope(String name)
getBroadcastScope
in interface IScope
name
-
public IBasicScope getBasicScope(ScopeType type, String name)
getBasicScope
in interface IScope
type
- Scope typename
- Scope name
public Set<String> getBasicScopeNames(ScopeType type)
getBasicScopeNames
in interface IScope
type
- Scope type
public ClassLoader getClassLoader()
getClassLoader
in interface ResourceLoader
public Set<IClient> getClients()
getClients
in interface IScope
IClient.getConnections(IScope)
public Collection<Set<IConnection>> getConnections()
getConnections
in interface IScope
public IContext getContext()
getContext
in interface IScope
public String getContextPath()
getContextPath
in interface IScope
getContextPath
in interface ScopeMXBean
public long getCreationTime()
getCreationTime
in interface IStatisticsBase
public int getDepth()
getDepth
in interface IBasicScope
getDepth
in interface IScopeStatistics
getDepth
in interface ScopeMXBean
getDepth
in class BasicScope
public IScopeHandler getHandler()
getHandler
in interface IScope
public int getMaxClients()
getMaxClients
in interface IScopeStatistics
getMaxClients
in interface ScopeMXBean
public int getMaxConnections()
getMaxConnections
in interface IScopeStatistics
getMaxConnections
in interface ScopeMXBean
public int getMaxSubscopes()
getMaxSubscopes
in interface IScopeStatistics
getMaxSubscopes
in interface ScopeMXBean
public IScope getParent()
getParent
in interface IBasicScope
getParent
in class BasicScope
public String getPath()
getPath
in interface IBasicScope
getPath
in interface IScopeStatistics
getPath
in interface ScopeMXBean
getPath
in class BasicScope
public Resource getResource(String path)
getResource
in interface ResourceLoader
path
- Resource path
public Resource[] getResources(String path) throws IOException
getResources
in interface ResourcePatternResolver
path
- Resources path
IOException
- I/O exceptionpublic IScope getScope(String name)
getScope
in interface IScope
name
- Scope name
public Set<String> getScopeNames()
getScopeNames
in interface IScope
public Object getServiceHandler(String name)
getServiceHandler
in interface IServiceHandlerProvider
name
- Handler name
public Set<String> getServiceHandlerNames()
getServiceHandlerNames
in interface IServiceHandlerProvider
getServiceHandlerNames
in interface ScopeMXBean
protected Map<String,Object> getServiceHandlers()
protected Map<String,Object> getServiceHandlers(boolean allowCreate)
allowCreate
- Should the map be created if it doesn't exist?
public IScopeStatistics getStatistics()
getStatistics
in interface IScope
public int getTotalClients()
getTotalClients
in interface IScopeStatistics
getTotalClients
in interface ScopeMXBean
public int getTotalConnections()
getTotalConnections
in interface IScopeStatistics
getTotalConnections
in interface ScopeMXBean
public int getTotalSubscopes()
getTotalSubscopes
in interface IScopeStatistics
getTotalSubscopes
in interface ScopeMXBean
public boolean handleEvent(IEvent event)
handleEvent
in interface IEventHandler
handleEvent
in class BasicScope
event
- Event to handle
true
on success, false
otherwisepublic boolean hasChildScope(String name)
hasChildScope
in interface IScope
hasChildScope
in interface ScopeMXBean
name
- Child scope name
true
if scope has child node with given name,
false
otherwisepublic boolean hasChildScope(ScopeType type, String name)
hasChildScope
in interface IScope
hasChildScope
in interface ScopeMXBean
type
- Child scope typename
- Child scope name
true
if scope has child node with given name and
type, false
otherwisepublic boolean hasContext()
hasContext
in interface ScopeMXBean
true
if scope has context, false
otherwisepublic boolean hasHandler()
hasHandler
in interface IScope
hasHandler
in interface ScopeMXBean
true
if scope or it's parent scope has a handler,
false
otherwisepublic boolean hasParent()
hasParent
in interface IBasicScope
hasParent
in interface ScopeMXBean
hasParent
in class BasicScope
true
if scope has parent scope, false
otherwise`public void init()
true
init
in interface ScopeMXBean
public void uninit()
public boolean isEnabled()
true
if scope is enabled, false
otherwisepublic boolean getEnabled()
getEnabled
in interface ScopeMXBean
true
if scope is enabled, false
otherwisepublic boolean isRunning()
true
if scope is in running state,
false
otherwisepublic boolean getRunning()
getRunning
in interface ScopeMXBean
true
if scope is in running state, false
otherwisepublic Set<IConnection> lookupConnections(IClient client)
lookupConnections
in interface IScope
client
- Client
public void registerServiceHandler(String name, Object handler)
registerServiceHandler
in interface IServiceHandlerProvider
name
- Service handler namehandler
- Service handlerpublic void removeChildScope(IBasicScope scope)
removeChildScope
in interface IScope
scope
- Child scope to removepublic void removeChildren()
removeChildren
in interface IScope
public void setAutoStart(boolean autoStart)
setAutoStart
in interface ScopeMXBean
autoStart
- Autostart flag valuepublic void setChildLoadPath(String pattern)
setChildLoadPath
in interface ScopeMXBean
pattern
- Load path patternpublic void setContext(IContext context)
context
- Context objectpublic void setDepth(int depth)
setDepth
in interface ScopeMXBean
depth
- Scope depthpublic void setEnabled(boolean enabled)
setEnabled
in interface ScopeMXBean
enabled
- Enable flag valuepublic void setHandler(IScopeHandler handler)
handler
- Event handlerpublic void setName(String name)
setName
in interface ScopeMXBean
name
- Scope namepublic void setParent(IScope parent)
parent
- Parent scopepublic void setPersistenceClass(String persistenceClass) throws Exception
setPersistenceClass
in interface ScopeMXBean
persistenceClass
- Scope's persistence class
Exception
- Exceptionpublic boolean start()
start
in interface ScopeMXBean
true
if scope has handler and it's start method
returned true, false
otherwisepublic void stop()
stop
in interface ScopeMXBean
public String toString()
toString
in class Object
public void unregisterServiceHandler(String name)
unregisterServiceHandler
in interface IServiceHandlerProvider
unregisterServiceHandler
in interface ScopeMXBean
name
- Service handler namepublic IServer getServer()
public void dump()
protected void registerJMX()
protected void unregisterJMX()
public static Scope from(CompositeData cd)
cd
- composite data
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |