|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.red5.server.scope.BasicScope
org.red5.server.scope.Scope
@ManagedResource(objectName="org.red5.server:type=Scope",
description="Scope")
public class ScopeThe 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 IScopescope - Child scope
true on success (if scope has handler and it
accepts child scope addition), false otherwisepublic boolean connect(IConnection conn)
connect in interface IScopeconn - Connection object
true on success, false otherwise
public boolean connect(IConnection conn,
Object[] params)
connect in interface IScopeconn - Connection objectparams - Parameters passed with connection
true on success, false otherwisepublic boolean createChildScope(String name)
createChildScope in interface IScopecreateChildScope in interface ScopeMXBeanname - Child scope name
true on success, false otherwisepublic void destroy()
destroy in interface ScopeMXBeanpublic void disconnect(IConnection conn)
disconnect in interface IScopeconn - Connection objectpublic void dispatchEvent(IEvent event)
dispatchEvent in interface IEventDispatcherdispatchEvent in class BasicScopeevent - Event to dispatchpublic Object getAttribute(String name)
getAttribute in interface IScope
public boolean setAttribute(String name,
Object value)
setAttribute in interface IScopepublic boolean hasAttribute(String name)
hasAttribute in interface IScopepublic boolean removeAttribute(String name)
removeAttribute in interface IScopepublic Set<String> getAttributeNames()
getAttributeNames in interface IScopepublic Map<String,Object> getAttributes()
getAttributes in interface IScopepublic int getActiveClients()
getActiveClients in interface IScopeStatisticsgetActiveClients in interface ScopeMXBeanpublic int getActiveConnections()
getActiveConnections in interface IScopeStatisticsgetActiveConnections in interface ScopeMXBeanpublic int getActiveSubscopes()
getActiveSubscopes in interface IScopeStatisticsgetActiveSubscopes in interface ScopeMXBeanpublic IBroadcastScope getBroadcastScope(String name)
getBroadcastScope in interface IScopename -
public IBasicScope getBasicScope(ScopeType type,
String name)
getBasicScope in interface IScopetype - Scope typename - Scope name
public Set<String> getBasicScopeNames(ScopeType type)
getBasicScopeNames in interface IScopetype - Scope type
public ClassLoader getClassLoader()
getClassLoader in interface ResourceLoaderpublic Set<IClient> getClients()
getClients in interface IScopeIClient.getConnections(IScope)public Collection<Set<IConnection>> getConnections()
getConnections in interface IScopepublic IContext getContext()
getContext in interface IScopepublic String getContextPath()
getContextPath in interface IScopegetContextPath in interface ScopeMXBeanpublic long getCreationTime()
getCreationTime in interface IStatisticsBasepublic int getDepth()
getDepth in interface IBasicScopegetDepth in interface IScopeStatisticsgetDepth in interface ScopeMXBeangetDepth in class BasicScopepublic IScopeHandler getHandler()
getHandler in interface IScopepublic int getMaxClients()
getMaxClients in interface IScopeStatisticsgetMaxClients in interface ScopeMXBeanpublic int getMaxConnections()
getMaxConnections in interface IScopeStatisticsgetMaxConnections in interface ScopeMXBeanpublic int getMaxSubscopes()
getMaxSubscopes in interface IScopeStatisticsgetMaxSubscopes in interface ScopeMXBeanpublic IScope getParent()
getParent in interface IBasicScopegetParent in class BasicScopepublic String getPath()
getPath in interface IBasicScopegetPath in interface IScopeStatisticsgetPath in interface ScopeMXBeangetPath in class BasicScopepublic Resource getResource(String path)
getResource in interface ResourceLoaderpath - Resource path
public Resource[] getResources(String path)
throws IOException
getResources in interface ResourcePatternResolverpath - Resources path
IOException - I/O exceptionpublic IScope getScope(String name)
getScope in interface IScopename - Scope name
public Set<String> getScopeNames()
getScopeNames in interface IScopepublic Object getServiceHandler(String name)
getServiceHandler in interface IServiceHandlerProvidername - Handler name
public Set<String> getServiceHandlerNames()
getServiceHandlerNames in interface IServiceHandlerProvidergetServiceHandlerNames in interface ScopeMXBeanprotected 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 IScopepublic int getTotalClients()
getTotalClients in interface IScopeStatisticsgetTotalClients in interface ScopeMXBeanpublic int getTotalConnections()
getTotalConnections in interface IScopeStatisticsgetTotalConnections in interface ScopeMXBeanpublic int getTotalSubscopes()
getTotalSubscopes in interface IScopeStatisticsgetTotalSubscopes in interface ScopeMXBeanpublic boolean handleEvent(IEvent event)
handleEvent in interface IEventHandlerhandleEvent in class BasicScopeevent - Event to handle
true on success, false otherwisepublic boolean hasChildScope(String name)
hasChildScope in interface IScopehasChildScope in interface ScopeMXBeanname - Child scope name
true if scope has child node with given name,
false otherwise
public boolean hasChildScope(ScopeType type,
String name)
hasChildScope in interface IScopehasChildScope in interface ScopeMXBeantype - Child scope typename - Child scope name
true if scope has child node with given name and
type, false otherwisepublic boolean hasContext()
hasContext in interface ScopeMXBeantrue if scope has context, false
otherwisepublic boolean hasHandler()
hasHandler in interface IScopehasHandler in interface ScopeMXBeantrue if scope or it's parent scope has a handler,
false otherwisepublic boolean hasParent()
hasParent in interface IBasicScopehasParent in interface ScopeMXBeanhasParent in class BasicScopetrue if scope has parent scope, false
otherwise`public void init()
true
init in interface ScopeMXBeanpublic void uninit()
public boolean isEnabled()
true if scope is enabled, false
otherwisepublic boolean getEnabled()
getEnabled in interface ScopeMXBeantrue if scope is enabled, false otherwisepublic boolean isRunning()
true if scope is in running state,
false otherwisepublic boolean getRunning()
getRunning in interface ScopeMXBeantrue if scope is in running state, false otherwisepublic Set<IConnection> lookupConnections(IClient client)
lookupConnections in interface IScopeclient - Client
public void registerServiceHandler(String name,
Object handler)
registerServiceHandler in interface IServiceHandlerProvidername - Service handler namehandler - Service handlerpublic void removeChildScope(IBasicScope scope)
removeChildScope in interface IScopescope - Child scope to removepublic void removeChildren()
removeChildren in interface IScopepublic void setAutoStart(boolean autoStart)
setAutoStart in interface ScopeMXBeanautoStart - Autostart flag valuepublic void setChildLoadPath(String pattern)
setChildLoadPath in interface ScopeMXBeanpattern - Load path patternpublic void setContext(IContext context)
context - Context objectpublic void setDepth(int depth)
setDepth in interface ScopeMXBeandepth - Scope depthpublic void setEnabled(boolean enabled)
setEnabled in interface ScopeMXBeanenabled - Enable flag valuepublic void setHandler(IScopeHandler handler)
handler - Event handlerpublic void setName(String name)
setName in interface ScopeMXBeanname - Scope namepublic void setParent(IScope parent)
parent - Parent scope
public void setPersistenceClass(String persistenceClass)
throws Exception
setPersistenceClass in interface ScopeMXBeanpersistenceClass - Scope's persistence class
Exception - Exceptionpublic boolean start()
start in interface ScopeMXBeantrue if scope has handler and it's start method
returned true, false otherwisepublic void stop()
stop in interface ScopeMXBeanpublic String toString()
toString in class Objectpublic void unregisterServiceHandler(String name)
unregisterServiceHandler in interface IServiceHandlerProviderunregisterServiceHandler in interface ScopeMXBeanname - 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 | |||||||||