|
||||||||||
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 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 ScopeMBean
name
- Child scope name
true
on success, false
otherwisepublic void destroy()
destroy
in interface ScopeMBean
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 int getActiveClients()
getActiveClients
in interface IScopeStatistics
getActiveClients
in interface ScopeMBean
public int getActiveConnections()
getActiveConnections
in interface IScopeStatistics
getActiveConnections
in interface ScopeMBean
public int getActiveSubscopes()
getActiveSubscopes
in interface IScopeStatistics
getActiveSubscopes
in interface ScopeMBean
public IBasicScope getBasicScope(String type, String name)
getBasicScope
in interface IScope
getBasicScope
in interface ScopeMBean
type
- Scope typename
- Scope name
public Iterator<String> getBasicScopeNames(String type)
getBasicScopeNames
in interface IScope
getBasicScopeNames
in interface ScopeMBean
type
- Scope type
public ClassLoader getClassLoader()
getClassLoader
in interface ResourceLoader
public Set<IClient> getClients()
getClients
in interface IScope
getClients
in interface ScopeMBean
IClient.getConnections(IScope)
public Collection<Set<IConnection>> getConnections()
getConnections
in interface IScope
getConnections
in interface ScopeMBean
public IContext getContext()
getContext
in interface IScope
getContext
in interface ScopeMBean
public String getContextPath()
getContextPath
in interface IScope
getContextPath
in interface ScopeMBean
public long getCreationTime()
getCreationTime
in interface IStatisticsBase
public int getDepth()
getDepth
in interface IBasicScope
getDepth
in interface IScopeStatistics
getDepth
in interface ScopeMBean
getDepth
in class BasicScope
public IScopeHandler getHandler()
getHandler
in interface IScope
getHandler
in interface ScopeMBean
public int getMaxClients()
getMaxClients
in interface IScopeStatistics
getMaxClients
in interface ScopeMBean
public int getMaxConnections()
getMaxConnections
in interface IScopeStatistics
getMaxConnections
in interface ScopeMBean
public int getMaxSubscopes()
getMaxSubscopes
in interface IScopeStatistics
getMaxSubscopes
in interface ScopeMBean
public IScope getParent()
getParent
in interface IBasicScope
getParent
in interface ScopeMBean
getParent
in class BasicScope
public String getPath()
getPath
in interface IBasicScope
getPath
in interface IPersistable
getPath
in interface IScopeStatistics
getPath
in interface ScopeMBean
getPath
in class BasicScope
public Resource getResource(String path)
getResource
in interface ScopeMBean
getResource
in interface ResourceLoader
path
- Resource path
public Resource[] getResources(String path) throws IOException
getResources
in interface ScopeMBean
getResources
in interface ResourcePatternResolver
path
- Resources path
IOException
- I/O exceptionpublic IScope getScope(String name)
getScope
in interface IScope
getScope
in interface ScopeMBean
name
- Scope name
public Iterator<String> getScopeNames()
getScopeNames
in interface IScope
getScopeNames
in interface ScopeMBean
public Object getServiceHandler(String name)
getServiceHandler
in interface IServiceHandlerProvider
getServiceHandler
in interface ScopeMBean
name
- Handler name
public Set<String> getServiceHandlerNames()
getServiceHandlerNames
in interface IServiceHandlerProvider
getServiceHandlerNames
in interface ScopeMBean
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 ScopeMBean
public int getTotalConnections()
getTotalConnections
in interface IScopeStatistics
getTotalConnections
in interface ScopeMBean
public int getTotalSubscopes()
getTotalSubscopes
in interface IScopeStatistics
getTotalSubscopes
in interface ScopeMBean
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 ScopeMBean
name
- Child scope name
true
if scope has child node with given name,
false
otherwisepublic boolean hasChildScope(String type, String name)
hasChildScope
in interface IScope
hasChildScope
in interface ScopeMBean
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 ScopeMBean
true
if scope has context, false
otherwisepublic boolean hasHandler()
hasHandler
in interface IScope
hasHandler
in interface ScopeMBean
true
if scope or it's parent scope has a handler,
false
otherwisepublic boolean hasParent()
hasParent
in interface IBasicScope
hasParent
in interface ScopeMBean
hasParent
in class BasicScope
true
if scope has parent scope, false
otherwise`public void init()
true
init
in interface ScopeMBean
public void uninit()
public boolean isEnabled()
true
if scope is enabled, false
otherwisepublic boolean getEnabled()
getEnabled
in interface ScopeMBean
true
if scope is enabled, false
otherwisepublic boolean isRunning()
true
if scope is in running state,
false
otherwisepublic boolean getRunning()
getRunning
in interface ScopeMBean
true
if scope is in running state, false
otherwisepublic Iterator<IBasicScope> iterator()
iterator
in interface Iterable<IBasicScope>
iterator
in class BasicScope
public Set<IConnection> lookupConnections(IClient client)
lookupConnections
in interface IScope
client
- Client
public void registerServiceHandler(String name, Object handler)
registerServiceHandler
in interface IServiceHandlerProvider
registerServiceHandler
in interface ScopeMBean
name
- Service handler namehandler
- Service handlerpublic void removeChildScope(IBasicScope scope)
removeChildScope
in interface IScope
scope
- Child scope to removepublic void setAutoStart(boolean autoStart)
setAutoStart
in interface ScopeMBean
autoStart
- Autostart flag valuepublic void setChildLoadPath(String pattern)
setChildLoadPath
in interface ScopeMBean
pattern
- Load path patternpublic void setContext(IContext context)
context
- Context objectpublic void setDepth(int depth)
setDepth
in interface ScopeMBean
depth
- Scope depthpublic void setEnabled(boolean enabled)
setEnabled
in interface ScopeMBean
enabled
- Enable flag valuepublic void setHandler(IScopeHandler handler)
handler
- Event handlerpublic void setName(String name)
setName
in interface IPersistable
setName
in interface ScopeMBean
setName
in class PersistableAttributeStore
name
- Scope namepublic void setParent(IScope parent)
parent
- Parent scopepublic void setPersistenceClass(String persistenceClass) throws Exception
setPersistenceClass
in interface ScopeMBean
persistenceClass
- Scope's persistence class
Exception
- Exceptionpublic boolean start()
start
in interface ScopeMBean
true
if scope has handler and it's start method
returned true, false
otherwisepublic void stop()
stop
in interface ScopeMBean
public String toString()
toString
in class Object
public void unregisterServiceHandler(String name)
unregisterServiceHandler
in interface IServiceHandlerProvider
unregisterServiceHandler
in interface ScopeMBean
name
- Service handler namepublic IServer getServer()
public void lock()
IBasicScope
lock
in interface IBasicScope
public void unlock()
IBasicScope
unlock
in interface IBasicScope
public void dump()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |