|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.red5.server.AttributeStore
org.red5.server.PersistableAttributeStore
org.red5.server.BasicScope
org.red5.server.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. The following are all names for scopes: application, room, place, lobby.
| Nested Class Summary | |
|---|---|
static class |
Scope.Builder
Builder pattern |
| Nested classes/interfaces inherited from class org.red5.server.BasicScope |
|---|
BasicScope.EmptyBasicScopeIterator |
| Field Summary | |
|---|---|
protected StatisticsCounter |
clientStats
Statistics about clients connected to the scope. |
protected StatisticsCounter |
connectionStats
Statistics about connections to the scope. |
protected Lock |
lock
Lock for critical sections, to prevent concurrent modification. |
protected static Logger |
log
Logger |
protected ObjectName |
oName
Mbean object name. |
protected StatisticsCounter |
subscopeStats
Statistics about sub-scopes. |
| Fields inherited from class org.red5.server.BasicScope |
|---|
keepDelay, keepOnDisconnect, listeners, parent, persistenceClass |
| Fields inherited from class org.red5.server.PersistableAttributeStore |
|---|
lastModified, name, path, persistent, store, type |
| Fields inherited from class org.red5.server.AttributeStore |
|---|
attributes |
| Fields inherited from interface org.red5.server.api.IScope |
|---|
ID, SEPARATOR |
| Fields inherited from interface org.red5.server.api.persistence.IPersistable |
|---|
TRANSIENT_PREFIX |
| 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 unnamed scope |
|
Scope(Scope.Builder builder)
Creates scope using a Builder |
|
Scope(String name)
Creates scope with given name |
|
| 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()
|
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. |
IBasicScope |
getBasicScope(String type,
String name)
Return base scope of given type with given name |
Iterator<String> |
getBasicScopeNames(String type)
Return basic scope names iterator |
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 |
Iterator<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 |
hasChildScope(String name)
Check whether scope has child scope with given name |
boolean |
hasChildScope(String type,
String name)
Check whether scope has child scope with given name and type |
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 |
Iterator<IBasicScope> |
iterator()
Child scopes iterator |
void |
lock()
Lock handling - attempts to obtain a lock |
Set<IConnection> |
lookupConnections(IClient client)
Looks up connections for client |
void |
registerServiceHandler(String name,
Object handler)
Register service handler by name |
void |
removeChildScope(IBasicScope scope)
Removes child scope |
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. |
void |
unlock()
Lock handling - attempts to unlock a lock |
void |
unregisterServiceHandler(String name)
Unregisters service handler by name |
| Methods inherited from class org.red5.server.BasicScope |
|---|
addEventListener, getEventListeners, hasEventListeners, notifyEvent, removeEventListener, setKeepDelay |
| Methods inherited from class org.red5.server.PersistableAttributeStore |
|---|
deserialize, getAttribute, getLastModified, getName, getStore, getType, isPersistent, modified, removeAttribute, removeAttributes, serialize, setAttribute, setAttributes, setAttributes, setPath, setPersistent, setStore |
| Methods inherited from class org.red5.server.AttributeStore |
|---|
filterNull, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.red5.server.api.IBasicScope |
|---|
getName, getType, setKeepDelay |
| Methods inherited from interface org.red5.server.api.ICastingAttributeStore |
|---|
getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute |
| Methods inherited from interface org.red5.server.api.IAttributeStore |
|---|
getAttribute, getAttribute, getAttributeNames, getAttributes, hasAttribute, removeAttribute, removeAttributes, setAttribute, setAttributes, setAttributes |
| 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.persistence.IPersistable |
|---|
deserialize, getLastModified, getStore, isPersistent, serialize, setPath, setPersistent, setStore |
| Methods inherited from interface org.red5.server.api.statistics.IScopeStatistics |
|---|
getName |
| Field Detail |
|---|
protected static Logger log
protected final StatisticsCounter clientStats
protected final StatisticsCounter connectionStats
protected final StatisticsCounter subscopeStats
protected Lock lock
protected ObjectName oName
| Constructor Detail |
|---|
public Scope()
public Scope(String name)
name - Scope namepublic 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 ScopeMBeanname - Child scope name
true on success, false otherwisepublic void destroy()
destroy in interface ScopeMBeanpublic void disconnect(IConnection conn)
disconnect in interface IScopeconn - Connection objectpublic void dispatchEvent(IEvent event)
dispatchEvent in interface IEventDispatcherdispatchEvent in class BasicScopeevent - Event to dispatchpublic int getActiveClients()
getActiveClients in interface IScopeStatisticsgetActiveClients in interface ScopeMBeanpublic int getActiveConnections()
getActiveConnections in interface IScopeStatisticsgetActiveConnections in interface ScopeMBeanpublic int getActiveSubscopes()
getActiveSubscopes in interface IScopeStatisticsgetActiveSubscopes in interface ScopeMBean
public IBasicScope getBasicScope(String type,
String name)
getBasicScope in interface IScopegetBasicScope in interface ScopeMBeantype - Scope typename - Scope name
public Iterator<String> getBasicScopeNames(String type)
getBasicScopeNames in interface IScopegetBasicScopeNames in interface ScopeMBeantype - Scope type
public ClassLoader getClassLoader()
getClassLoader in interface ResourceLoaderpublic Set<IClient> getClients()
getClients in interface IScopegetClients in interface ScopeMBeanIClient.getConnections(IScope)public Collection<Set<IConnection>> getConnections()
getConnections in interface IScopegetConnections in interface ScopeMBeanpublic IContext getContext()
getContext in interface IScopegetContext in interface ScopeMBeanpublic String getContextPath()
getContextPath in interface IScopegetContextPath in interface ScopeMBeanpublic long getCreationTime()
getCreationTime in interface IStatisticsBasepublic int getDepth()
getDepth in interface IBasicScopegetDepth in interface IScopeStatisticsgetDepth in interface ScopeMBeangetDepth in class BasicScopepublic IScopeHandler getHandler()
getHandler in interface IScopegetHandler in interface ScopeMBeanpublic int getMaxClients()
getMaxClients in interface IScopeStatisticsgetMaxClients in interface ScopeMBeanpublic int getMaxConnections()
getMaxConnections in interface IScopeStatisticsgetMaxConnections in interface ScopeMBeanpublic int getMaxSubscopes()
getMaxSubscopes in interface IScopeStatisticsgetMaxSubscopes in interface ScopeMBeanpublic IScope getParent()
getParent in interface IBasicScopegetParent in interface ScopeMBeangetParent in class BasicScopepublic String getPath()
getPath in interface IBasicScopegetPath in interface IPersistablegetPath in interface IScopeStatisticsgetPath in interface ScopeMBeangetPath in class BasicScopepublic Resource getResource(String path)
getResource in interface ScopeMBeangetResource in interface ResourceLoaderpath - Resource path
public Resource[] getResources(String path)
throws IOException
getResources in interface ScopeMBeangetResources in interface ResourcePatternResolverpath - Resources path
IOException - I/O exceptionpublic IScope getScope(String name)
getScope in interface IScopegetScope in interface ScopeMBeanname - Scope name
public Iterator<String> getScopeNames()
getScopeNames in interface IScopegetScopeNames in interface ScopeMBeanpublic Object getServiceHandler(String name)
getServiceHandler in interface IServiceHandlerProvidergetServiceHandler in interface ScopeMBeanname - Handler name
public Set<String> getServiceHandlerNames()
getServiceHandlerNames in interface IServiceHandlerProvidergetServiceHandlerNames in interface ScopeMBeanprotected 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 ScopeMBeanpublic int getTotalConnections()
getTotalConnections in interface IScopeStatisticsgetTotalConnections in interface ScopeMBeanpublic int getTotalSubscopes()
getTotalSubscopes in interface IScopeStatisticsgetTotalSubscopes in interface ScopeMBeanpublic 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 ScopeMBeanname - Child scope name
true if scope has child node with given name,
false otherwise
public boolean hasChildScope(String type,
String name)
hasChildScope in interface IScopehasChildScope in interface ScopeMBeantype - Child scope typename - Child scope name
true if scope has child node with given name and
type, false otherwisepublic boolean hasContext()
hasContext in interface ScopeMBeantrue if scope has context, false
otherwisepublic boolean hasHandler()
hasHandler in interface IScopehasHandler in interface ScopeMBeantrue if scope or it's parent scope has a handler,
false otherwisepublic boolean hasParent()
hasParent in interface IBasicScopehasParent in interface ScopeMBeanhasParent in class BasicScopetrue if scope has parent scope, false
otherwise`public void init()
true
init in interface ScopeMBeanpublic void uninit()
public boolean isEnabled()
true if scope is enabled, false
otherwisepublic boolean getEnabled()
getEnabled in interface ScopeMBeantrue if scope is enabled, false otherwisepublic boolean isRunning()
true if scope is in running state,
false otherwisepublic boolean getRunning()
getRunning in interface ScopeMBeantrue if scope is in running state, false otherwisepublic Iterator<IBasicScope> iterator()
iterator in interface Iterable<IBasicScope>iterator in class BasicScopepublic Set<IConnection> lookupConnections(IClient client)
lookupConnections in interface IScopeclient - Client
public void registerServiceHandler(String name,
Object handler)
registerServiceHandler in interface IServiceHandlerProviderregisterServiceHandler in interface ScopeMBeanname - Service handler namehandler - Service handlerpublic void removeChildScope(IBasicScope scope)
removeChildScope in interface IScopescope - Child scope to removepublic void setAutoStart(boolean autoStart)
setAutoStart in interface ScopeMBeanautoStart - Autostart flag valuepublic void setChildLoadPath(String pattern)
setChildLoadPath in interface ScopeMBeanpattern - Load path patternpublic void setContext(IContext context)
context - Context objectpublic void setDepth(int depth)
setDepth in interface ScopeMBeandepth - Scope depthpublic void setEnabled(boolean enabled)
setEnabled in interface ScopeMBeanenabled - Enable flag valuepublic void setHandler(IScopeHandler handler)
handler - Event handlerpublic void setName(String name)
setName in interface IPersistablesetName in interface ScopeMBeansetName in class PersistableAttributeStorename - Scope namepublic void setParent(IScope parent)
parent - Parent scope
public void setPersistenceClass(String persistenceClass)
throws Exception
setPersistenceClass in interface ScopeMBeanpersistenceClass - Scope's persistence class
Exception - Exceptionpublic boolean start()
start in interface ScopeMBeantrue if scope has handler and it's start method
returned true, false otherwisepublic void stop()
stop in interface ScopeMBeanpublic String toString()
toString in class Objectpublic void unregisterServiceHandler(String name)
unregisterServiceHandler in interface IServiceHandlerProviderunregisterServiceHandler in interface ScopeMBeanname - Service handler namepublic IServer getServer()
public void lock()
IBasicScope
lock in interface IBasicScopepublic void unlock()
IBasicScope
unlock in interface IBasicScopepublic void dump()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||