|
||||||||||
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.so.SharedObjectScope
public class SharedObjectScope
Special scope for shared objects
Field Summary | |
---|---|
protected SharedObject |
so
Scoped shared object |
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.so.ISharedObjectSecurityService |
---|
BEAN_NAME |
Constructor Summary | |
---|---|
SharedObjectScope(IScope parent,
String name,
boolean persistent,
IPersistenceStore store)
Creates shared object with given parent scope, name, persistence flag state and store object |
Method Summary | |
---|---|
void |
acquire()
Prevent shared object from being released. |
void |
addEventListener(IEventListener listener)
Add event listener to list of notified objects |
void |
addSharedObjectListener(ISharedObjectListener listener)
Register object that will be notified about update events. |
void |
beginUpdate()
Start performing multiple updates to the shared object from serverside code. |
void |
beginUpdate(IEventListener listener)
Start performing multiple updates to the shared object from a connected client. |
boolean |
clear()
Deletes all the attributes and sends a clear event to all listeners. |
void |
close()
Detaches a reference from this shared object, this will destroy the reference immediately. |
void |
dispatchEvent(IEvent e)
Dispatches event (notifies all listeners) |
void |
endUpdate()
The multiple updates are complete, notify clients about all changes at once. |
Object |
getAttribute(String name)
Return the value for a given attribute. |
Object |
getAttribute(String name,
Object value)
Return the value for a given attribute and set it if it doesn't exist. |
Set<String> |
getAttributeNames()
Get the attribute names. |
Map<String,Object> |
getAttributes()
Get the attributes. |
Boolean |
getBoolAttribute(String name)
Get Boolean attribute by name |
Byte |
getByteAttribute(String name)
Get Byte attribute by name |
Map<String,Object> |
getData()
Return a map containing all attributes of the shared object. |
Double |
getDoubleAttribute(String name)
Get Double attribute by name |
Integer |
getIntAttribute(String name)
Get Integer attribute by name |
List<?> |
getListAttribute(String name)
Get List attribute by name |
Long |
getLongAttribute(String name)
Get boolean attribute by name |
Map<?,?> |
getMapAttribute(String name)
Get Long attribute by name |
String |
getName()
Get the name of this scope. |
String |
getPath()
Get the full absolute path. |
Object |
getServiceHandler(String name)
Return a previously registered service handler. |
Set<String> |
getServiceHandlerNames()
Get list of registered service handler names. |
Set<?> |
getSetAttribute(String name)
Get Set attribute by name |
Set<ISharedObjectSecurity> |
getSharedObjectSecurity()
Get handlers that protect shared objects. |
Short |
getShortAttribute(String name)
Get Short attribute by name |
ISharedObjectStatistics |
getStatistics()
Return statistics about the shared object. |
IPersistenceStore |
getStore()
Get the persistable store |
String |
getStringAttribute(String name)
Get String attribute by name |
int |
getVersion()
Returns the version of the shared object. |
boolean |
hasAttribute(String name)
Check the object has an attribute. |
boolean |
isAcquired()
Check if shared object currently is acquired. |
protected boolean |
isConnectionAllowed()
Call handlers and check if connection to the existing SO is allowed. |
protected boolean |
isDeleteAllowed(String key)
Call handlers and check if deleting a property from the SO is allowed. |
boolean |
isLocked()
Returns the locked state of this SharedObject. |
boolean |
isPersistent()
Check if the object has been created as persistent shared object by the client. |
protected boolean |
isSendAllowed(String message,
List<?> arguments)
Call handlers and check if sending a message to the clients connected to the SO is allowed. |
protected boolean |
isWriteAllowed(String key,
Object value)
Call handlers and check if writing to the SO is allowed. |
void |
lock()
Locks the shared object instance. |
void |
registerServiceHandler(Object handler)
Register an object that provides methods which handle calls without a service name to a shared object. |
void |
registerServiceHandler(String name,
Object handler)
Register an object that provides methods which can be called from a client. |
void |
registerSharedObjectSecurity(ISharedObjectSecurity handler)
Add handler that protects shared objects. |
void |
release()
Release previously acquired shared object. |
boolean |
removeAttribute(String name)
Remove an attribute. |
void |
removeAttributes()
Remove all attributes. |
void |
removeEventListener(IEventListener listener)
Remove event listener from list of listeners |
void |
removeSharedObjectListener(ISharedObjectListener listener)
Unregister object to not longer receive update events. |
void |
sendMessage(String handler,
List<?> arguments)
Send a message to a handler of the shared object. |
boolean |
setAttribute(String name,
Object value)
Set an attribute on this object. |
boolean |
setAttributes(IAttributeStore values)
Set multiple attributes on this object. |
boolean |
setAttributes(Map<String,Object> values)
Set multiple attributes on this object. |
void |
setPath(String path)
|
int |
size()
Size of the attribute store. |
String |
toString()
|
void |
unlock()
Unlocks a shared object instance that was locked with SharedObject.lock(). |
void |
unregisterServiceHandler()
|
void |
unregisterServiceHandler(String name)
Unregister the shared object handler for calls without a service name. |
void |
unregisterSharedObjectSecurity(ISharedObjectSecurity handler)
Remove handler that protects shared objects. |
Methods inherited from class org.red5.server.scope.BasicScope |
---|
equals, getDepth, getEventListeners, getParent, getType, handleEvent, hasEventListeners, hashCode, hasParent, isValid, notifyEvent, 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 |
---|
getDepth, getParent, getType, hasParent, isValid, setKeepDelay |
Methods inherited from interface org.red5.server.api.event.IEventHandler |
---|
handleEvent |
Methods inherited from interface org.red5.server.api.event.IEventListener |
---|
notifyEvent |
Methods inherited from interface org.red5.server.api.event.IEventObservable |
---|
getEventListeners |
Field Detail |
---|
protected volatile SharedObject so
Constructor Detail |
---|
public SharedObjectScope(IScope parent, String name, boolean persistent, IPersistenceStore store)
parent
- Parent scopename
- Namepersistent
- Persistence flag statestore
- Persistence storeMethod Detail |
---|
public void registerSharedObjectSecurity(ISharedObjectSecurity handler)
registerSharedObjectSecurity
in interface ISharedObjectSecurityService
handler
- Handler to add.public void unregisterSharedObjectSecurity(ISharedObjectSecurity handler)
unregisterSharedObjectSecurity
in interface ISharedObjectSecurityService
handler
- Handler to remove.public Set<ISharedObjectSecurity> getSharedObjectSecurity()
getSharedObjectSecurity
in interface ISharedObjectSecurityService
public IPersistenceStore getStore()
getStore
in interface IBasicScope
getStore
in class BasicScope
public String getName()
someroom
.
getName
in interface IBasicScope
getName
in class BasicScope
public String getPath()
host/myapp/someroom
.
getPath
in interface IBasicScope
getPath
in class BasicScope
public void setPath(String path)
public boolean isPersistent()
isPersistent
in interface ISharedObjectBase
public void beginUpdate()
beginUpdate
in interface ISharedObjectBase
public void beginUpdate(IEventListener listener)
beginUpdate
in interface ISharedObjectBase
listener
- Update events listenerpublic void endUpdate()
endUpdate
in interface ISharedObjectBase
public int getVersion()
getVersion
in interface ISharedObjectBase
public void sendMessage(String handler, List<?> arguments)
sendMessage
in interface ISharedObjectBase
handler
- the name of the handler to callarguments
- a list of objects that should be passed as arguments to the
handlerpublic boolean removeAttribute(String name)
removeAttribute
in interface IAttributeStore
removeAttribute
in interface AttributeStoreMXBean
name
- the name of the attribute to remove
public void removeAttributes()
removeAttributes
in interface IAttributeStore
removeAttributes
in interface AttributeStoreMXBean
public int size()
size
in interface IAttributeStore
public void addEventListener(IEventListener listener)
addEventListener
in interface IEventObservable
addEventListener
in class BasicScope
listener
- Listening objectpublic void removeEventListener(IEventListener listener)
removeEventListener
in interface IEventObservable
removeEventListener
in class BasicScope
listener
- Listener to removepublic boolean hasAttribute(String name)
hasAttribute
in interface IAttributeStore
hasAttribute
in interface AttributeStoreMXBean
name
- the name of the attribute to check
public Object getAttribute(String name)
getAttribute
in interface IAttributeStore
name
- the name of the attribute to get
public Object getAttribute(String name, Object value)
This is a utility function that internally performs the following code:
if (!hasAttribute(name)) setAttribute(name, defaultValue);
return getAttribute(name);
getAttribute
in interface IAttributeStore
name
- the name of the attribute to getvalue
- the value of the attribute to set if the attribute doesn't
exist
public Map<String,Object> getAttributes()
getAttributes
in interface IAttributeStore
public Set<String> getAttributeNames()
getAttributeNames
in interface IAttributeStore
getAttributeNames
in interface AttributeStoreMXBean
public Boolean getBoolAttribute(String name)
getBoolAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Byte getByteAttribute(String name)
getByteAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Double getDoubleAttribute(String name)
getDoubleAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Integer getIntAttribute(String name)
getIntAttribute
in interface ICastingAttributeStore
name
- Attribute name
public List<?> getListAttribute(String name)
getListAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Long getLongAttribute(String name)
getLongAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Map<?,?> getMapAttribute(String name)
getMapAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Set<?> getSetAttribute(String name)
getSetAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Short getShortAttribute(String name)
getShortAttribute
in interface ICastingAttributeStore
name
- Attribute name
public String getStringAttribute(String name)
getStringAttribute
in interface ICastingAttributeStore
name
- Attribute name
public Map<String,Object> getData()
getData
in interface ISharedObjectBase
protected boolean isConnectionAllowed()
protected boolean isWriteAllowed(String key, Object value)
key
- keyvalue
- value
protected boolean isDeleteAllowed(String key)
key
- key
protected boolean isSendAllowed(String message, List<?> arguments)
message
- messagearguments
- arguments
public void dispatchEvent(IEvent e)
dispatchEvent
in interface IEventDispatcher
dispatchEvent
in class BasicScope
e
- Event to dispatchpublic boolean setAttribute(String name, Object value)
setAttribute
in interface IAttributeStore
name
- the name of the attribute to changevalue
- the new value of the attribute
public boolean setAttributes(IAttributeStore values)
setAttributes
in interface IAttributeStore
values
- the attributes to set
public boolean setAttributes(Map<String,Object> values)
setAttributes
in interface IAttributeStore
values
- the attributes to set
public String toString()
toString
in class Object
public void addSharedObjectListener(ISharedObjectListener listener)
addSharedObjectListener
in interface ISharedObjectBase
listener
- the object to notifypublic void removeSharedObjectListener(ISharedObjectListener listener)
removeSharedObjectListener
in interface ISharedObjectBase
listener
- the object to unregisterpublic void registerServiceHandler(Object handler)
registerServiceHandler
in interface ISharedObjectHandlerProvider
handler
- the handler objectpublic void registerServiceHandler(String name, Object handler)
Example:
If you registered a handler with the name "one.two
" that
provides a method "callMe
", you can call a method
"one.two.callMe
" from the client.
registerServiceHandler
in interface IServiceHandlerProvider
name
- the name of the handlerhandler
- the handler objectpublic void unregisterServiceHandler()
public void unregisterServiceHandler(String name)
unregisterServiceHandler
in interface IServiceHandlerProvider
unregisterServiceHandler
in interface ISharedObjectHandlerProvider
name
- the name of the handlerpublic Object getServiceHandler(String name)
getServiceHandler
in interface IServiceHandlerProvider
name
- the name of the handler to return
public Set<String> getServiceHandlerNames()
getServiceHandlerNames
in interface IServiceHandlerProvider
public void lock()
lock
in interface ISharedObjectBase
public void unlock()
unlock
in interface ISharedObjectBase
public boolean isLocked()
isLocked
in interface ISharedObjectBase
public boolean clear()
clear
in interface ISharedObjectBase
public void close()
close
in interface ISharedObjectBase
public void acquire()
acquire
must be paired with a call to release
so the SO isn't held
forever.
This method basically is a noop for persistent SOs as their data is stored
and they can be released without losing their contents.
acquire
in interface ISharedObject
public boolean isAcquired()
isAcquired
in interface ISharedObject
true
if the SO is acquired, otherwise false
public void release()
release
in interface ISharedObject
public ISharedObjectStatistics getStatistics()
getStatistics
in interface ISharedObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |