Package org.red5.server.so
Class SharedObjectScope
java.lang.Object
org.red5.server.scope.BasicScope
org.red5.server.so.SharedObjectScope
- All Implemented Interfaces:
Comparable<BasicScope>,IEventDispatcher,IEventHandler,IEventListener,IEventObservable,IAttributeStore,ICastingAttributeStore,ICoreObject,IBasicScope,IScopeService,IServiceHandlerProvider,ISharedObject,ISharedObjectBase,ISharedObjectHandlerProvider,ISharedObjectSecurityService,AttributeStoreMXBean,StatusCodes
Special scope for shared objects
-
Field Summary
FieldsFields inherited from class org.red5.server.scope.BasicScope
creation, keepDelay, keepOnDisconnect, listeners, name, parent, persistenceClass, persistent, store, typeFields inherited from interface org.red5.server.api.so.ISharedObjectSecurityService
BEAN_NAMEFields inherited from interface org.red5.server.net.rtmp.status.StatusCodes
APP_GC, APP_RESOURCE_LOWMEMORY, APP_SCRIPT_ERROR, APP_SCRIPT_WARNING, APP_SHUTDOWN, NC_CALL_BADVERSION, NC_CALL_FAILED, NC_CONNECT_APPSHUTDOWN, NC_CONNECT_CLOSED, NC_CONNECT_FAILED, NC_CONNECT_INVALID_APPLICATION, NC_CONNECT_REJECTED, NC_CONNECT_SUCCESS, NS_BUFFER_EMPTY, NS_CLEAR_FAILED, NS_CLEAR_SUCCESS, NS_DATA_START, NS_FAILED, NS_INVALID_ARGUMENT, NS_PAUSE_NOTIFY, NS_PLAY_COMPLETE, NS_PLAY_FAILED, NS_PLAY_FILE_STRUCTURE_INVALID, NS_PLAY_INSUFFICIENT_BW, NS_PLAY_NO_SUPPORTED_TRACK_FOUND, NS_PLAY_PUBLISHNOTIFY, NS_PLAY_RESET, NS_PLAY_START, NS_PLAY_STOP, NS_PLAY_STREAMNOTFOUND, NS_PLAY_SWITCH, NS_PLAY_TRANSITION, NS_PLAY_TRANSITION_COMPLETE, NS_PLAY_UNPUBLISHNOTIFY, NS_PUBLISH_BADNAME, NS_PUBLISH_START, NS_RECORD_FAILED, NS_RECORD_NOACCESS, NS_RECORD_START, NS_RECORD_STOP, NS_SEEK_FAILED, NS_SEEK_NOTIFY, NS_TRANSITION_FORCED, NS_TRANSITION_SUCCESS, NS_UNPAUSE_NOTIFY, NS_UNPUBLISHED_SUCCESS, SO_CREATION_FAILED, SO_NO_READ_ACCESS, SO_NO_WRITE_ACCESS, SO_PERSISTENCE_MISMATCH -
Constructor Summary
ConstructorsConstructorDescriptionSharedObjectScope(IScope parent, String name, boolean persistent, IPersistenceStore store) Creates shared object with given parent scope, name, persistence flag state and store object -
Method Summary
Modifier and TypeMethodDescriptionvoidacquire()Prevent shared object from being released.booleanaddEventListener(IEventListener listener) Add event listener to list of notified objectsvoidaddSharedObjectListener(ISharedObjectListener listener) Register object that will be notified about update events.voidStart performing multiple updates to the shared object from serverside code.voidbeginUpdate(IEventListener listener) Start performing multiple updates to the shared object from a connected client.booleanclear()Deletes all the attributes and sends a clear event to all listeners.voidclose()Detaches a reference from this shared object, this will destroy the reference immediately.voidDispatches event (notifies all listeners)voidThe multiple updates are complete, notify clients about all changes at once.getAttribute(Enum<?> enm) Return the value for a given attribute.getAttribute(String name) Return the value for a given attribute.getAttribute(String name, Object value) Return the value for a given attribute and set it if it doesn't exist.Get the attribute names.Get the attributes.getBoolAttribute(String name) Get Boolean attribute by namegetByteAttribute(String name) Get Byte attribute by namegetData()Return a map containing all attributes of the shared object.getDoubleAttribute(String name) Get Double attribute by namegetIntAttribute(String name) Get Integer attribute by nameList<?> getListAttribute(String name) Get List attribute by namegetLongAttribute(String name) Get boolean attribute by nameMap<?, ?> getMapAttribute(String name) Get Long attribute by namegetName()Get the name of this scope.getPath()Get the full absolute path.getServiceHandler(String name) Return a previously registered service handler.Get list of registered service handler names.Set<?> getSetAttribute(String name) Get Set attribute by nameGet handlers that protect shared objects.getShortAttribute(String name) Get Short attribute by nameReturn statistics about the shared object.getStore()Get the persistable storegetStringAttribute(String name) Get String attribute by nameintReturns the version of the shared object.booleanhasAttribute(Enum<?> enm) Check the object has an attribute.booleanhasAttribute(String name) Check the object has an attribute.booleanCheck if shared object currently is acquired.protected booleanCall handlers and check if connection to the existing SO is allowed.protected booleanisDeleteAllowed(String key) Call handlers and check if deleting a property from the SO is allowed.booleanisLocked()Deprecated.booleanCheck if the object has been created as persistent shared object by the client.protected booleanisSendAllowed(String message, List<?> arguments) Call handlers and check if sending a message to the clients connected to the SO is allowed.protected booleanisWriteAllowed(String key, Object value) Call handlers and check if writing to the SO is allowed.voidregisterServiceHandler(Object handler) Register an object that provides methods which handle calls without a service name to a shared object.voidregisterServiceHandler(String name, Object handler) Register an object that provides methods which can be called from a client.voidAdd handler that protects shared objects.voidrelease()Release previously acquired shared object.booleanremoveAttribute(Enum<?> enm) Remove an attribute.booleanremoveAttribute(String name) Remove an attribute.voidRemove all attributes.booleanremoveEventListener(IEventListener listener) Remove event listener from list of listenersvoidUnregister object to not longer receive update events.voidsendMessage(String handler, List<?> arguments) Send a message to a handler of the shared object.booleansetAttribute(Enum<?> enm, Object value) Set an attribute on this object.booleansetAttribute(String name, Object value) Set an attribute on this object.booleansetAttributes(Map<String, Object> values) Set multiple attributes on this object.booleansetAttributes(IAttributeStore values) Set multiple attributes on this object.voidsetDirty(boolean dirty) Deprecated.voidSets a "dirty" flag to indicate that the named attribute has been modified.voidintsize()Size of the attribute store.toString()voidvoidUnregister the shared object handler for calls without a service name.voidRemove handler that protects shared objects.Methods inherited from class org.red5.server.scope.BasicScope
compareTo, equals, getDepth, getEventListeners, getParent, getType, handleEvent, hasEventListeners, hashCode, hasParent, isConnectionAllowed, isScopeAllowed, isValid, notifyEvent, setKeepDelay, setSecurityHandlersMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.red5.server.api.scope.IBasicScope
getDepth, getParent, getType, hasParent, isConnectionAllowed, isScopeAllowed, isValid, setKeepDelay, setSecurityHandlersMethods inherited from interface org.red5.server.api.event.IEventHandler
handleEventMethods inherited from interface org.red5.server.api.event.IEventListener
notifyEventMethods inherited from interface org.red5.server.api.event.IEventObservable
getEventListeners
-
Field Details
-
so
Scoped shared object
-
-
Constructor Details
-
SharedObjectScope
Creates shared object with given parent scope, name, persistence flag state and store object- Parameters:
parent- Parent scopename- Namepersistent- Persistence flag statestore- Persistence store
-
-
Method Details
-
acquire
public void acquire()Prevent shared object from being released. Each call toacquire
must be paired with a call torelease
so the SO isn't held forever. This method basically is a no-op for persistent SOs as their data is stored and they can be released without losing their contents.- Specified by:
acquirein interfaceISharedObject
-
isAcquired
public boolean isAcquired()Check if shared object currently is acquired.- Specified by:
isAcquiredin interfaceISharedObject- Returns:
true
if the SO is acquired, otherwisefalse
-
release
public void release()Release previously acquired shared object. If the SO is non-persistent, no more clients are connected the SO isn't acquired any more, the data is released.- Specified by:
releasein interfaceISharedObject
-
isLocked
Deprecated.This is no longer supported and is only here to prevent issues at runtime for those implementing the call.- Returns:
- false
-
setDirty
Deprecated.Sets a "dirty" flag to indicate that the attributes have been modified.- Specified by:
setDirtyin interfaceISharedObject- Parameters:
dirty- if dirty / modified
-
setDirty
Sets a "dirty" flag to indicate that the named attribute has been modified.- Specified by:
setDirtyin interfaceISharedObject- Parameters:
name- attribute key which is now dirty
-
beginUpdate
public void beginUpdate()Start performing multiple updates to the shared object from serverside code.- Specified by:
beginUpdatein interfaceISharedObjectBase
-
beginUpdate
Start performing multiple updates to the shared object from a connected client.- Specified by:
beginUpdatein interfaceISharedObjectBase- Parameters:
listener- Update events listener
-
endUpdate
public void endUpdate()The multiple updates are complete, notify clients about all changes at once.- Specified by:
endUpdatein interfaceISharedObjectBase
-
getStore
Get the persistable store- Specified by:
getStorein interfaceIBasicScope- Overrides:
getStorein classBasicScope- Returns:
- the store
-
getName
Get the name of this scope. Eg. someroom- Specified by:
getNamein interfaceIBasicScope- Overrides:
getNamein classBasicScope- Returns:
- the name
-
getPath
Get the full absolute path. Eg. host / myapp / someroom- Specified by:
getPathin interfaceIBasicScope- Overrides:
getPathin classBasicScope- Returns:
- absolute scope path
-
setPath
-
isPersistent
public boolean isPersistent()Check if the object has been created as persistent shared object by the client.- Specified by:
isPersistentin interfaceISharedObjectBase- Returns:
- true if the shared object is persistent, false otherwise
-
getVersion
public int getVersion()Returns the version of the shared object. The version is incremented automatically on each modification.- Specified by:
getVersionin interfaceISharedObjectBase- Returns:
- the version of the shared object
-
sendMessage
Send a message to a handler of the shared object.- Specified by:
sendMessagein interfaceISharedObjectBase- Parameters:
handler- the name of the handler to callarguments- a list of objects that should be passed as arguments to the handler
-
removeAttribute
Remove an attribute.- Specified by:
removeAttributein interfaceAttributeStoreMXBean- Specified by:
removeAttributein interfaceIAttributeStore- Parameters:
name- the name of the attribute to remove- Returns:
- true if the attribute was found and removed otherwise false
-
removeAttribute
Description copied from interface:IAttributeStoreRemove an attribute.- Specified by:
removeAttributein interfaceIAttributeStore- Parameters:
enm- the enum of the attribute to remove- Returns:
- true if the attribute was found and removed otherwise false
-
removeAttributes
public void removeAttributes()Remove all attributes.- Specified by:
removeAttributesin interfaceAttributeStoreMXBean- Specified by:
removeAttributesin interfaceIAttributeStore
-
size
public int size()Size of the attribute store.- Specified by:
sizein interfaceIAttributeStore- Returns:
- count of attributes
-
addEventListener
Add event listener to list of notified objects- Specified by:
addEventListenerin interfaceIEventObservable- Overrides:
addEventListenerin classBasicScope- Parameters:
listener- Listening object- Returns:
- true if listener is added and false otherwise
-
removeEventListener
Remove event listener from list of listeners- Specified by:
removeEventListenerin interfaceIEventObservable- Overrides:
removeEventListenerin classBasicScope- Parameters:
listener- Listener to remove- Returns:
- true if listener is removed and false otherwise
-
hasAttribute
Check the object has an attribute.- Specified by:
hasAttributein interfaceAttributeStoreMXBean- Specified by:
hasAttributein interfaceIAttributeStore- Parameters:
name- the name of the attribute to check- Returns:
- true if the attribute exists otherwise false
-
hasAttribute
Description copied from interface:IAttributeStoreCheck the object has an attribute.- Specified by:
hasAttributein interfaceIAttributeStore- Parameters:
enm- the enum for the attribute to check- Returns:
- true if the attribute exists otherwise false
-
getAttribute
Return the value for a given attribute.- Specified by:
getAttributein interfaceIAttributeStore- Parameters:
name- the name of the attribute to get- Returns:
- the attribute value or null if the attribute doesn't exist
-
getAttribute
Description copied from interface:IAttributeStoreReturn the value for a given attribute.- Specified by:
getAttributein interfaceIAttributeStore- Parameters:
enm- the enum for the attribute to get- Returns:
- the attribute value or null if the attribute doesn't exist
-
getAttribute
Return the value for a given attribute and set it if it doesn't exist. This is a utility function that internally performs the following code:
if (!hasAttribute(name)) setAttribute(name, defaultValue); return getAttribute(name);- Specified by:
getAttributein interfaceIAttributeStore- Parameters:
name- the name of the attribute to getvalue- the value of the attribute to set if the attribute doesn't exist- Returns:
- the attribute value
-
getAttributes
Get the attributes. The resulting map will be read-only.- Specified by:
getAttributesin interfaceIAttributeStore- Returns:
- map containing all attributes
-
getAttributeNames
Get the attribute names. The resulting set will be read-only.- Specified by:
getAttributeNamesin interfaceAttributeStoreMXBean- Specified by:
getAttributeNamesin interfaceIAttributeStore- Returns:
- set containing all attribute names
-
getBoolAttribute
Get Boolean attribute by name- Specified by:
getBoolAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getByteAttribute
Get Byte attribute by name- Specified by:
getByteAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getDoubleAttribute
Get Double attribute by name- Specified by:
getDoubleAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getIntAttribute
Get Integer attribute by name- Specified by:
getIntAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getListAttribute
Get List attribute by name- Specified by:
getListAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getLongAttribute
Get boolean attribute by name- Specified by:
getLongAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getMapAttribute
Get Long attribute by name- Specified by:
getMapAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getSetAttribute
Get Set attribute by name- Specified by:
getSetAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getShortAttribute
Get Short attribute by name- Specified by:
getShortAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getStringAttribute
Get String attribute by name- Specified by:
getStringAttributein interfaceICastingAttributeStore- Parameters:
name- Attribute name- Returns:
- Attribute
-
getData
Return a map containing all attributes of the shared object.
NOTE: The returned map will be read-only.- Specified by:
getDatain interfaceISharedObjectBase- Returns:
- a map containing all attributes of the shared object
-
isConnectionAllowed
protected boolean isConnectionAllowed()Call handlers and check if connection to the existing SO is allowed.- Returns:
- is connection allowed
-
isWriteAllowed
Call handlers and check if writing to the SO is allowed.- Parameters:
key- keyvalue- value- Returns:
- is write allowed
-
isDeleteAllowed
Call handlers and check if deleting a property from the SO is allowed.- Parameters:
key- key- Returns:
- is delete allowed
-
isSendAllowed
Call handlers and check if sending a message to the clients connected to the SO is allowed.- Parameters:
message- messagearguments- arguments- Returns:
- is send allowed
-
dispatchEvent
Dispatches event (notifies all listeners)- Specified by:
dispatchEventin interfaceIEventDispatcher- Overrides:
dispatchEventin classBasicScope- Parameters:
e- Event to dispatch
-
setAttribute
Set an attribute on this object.- Specified by:
setAttributein interfaceIAttributeStore- Parameters:
name- the name of the attribute to changevalue- the new value of the attribute- Returns:
- true if the attribute value changed otherwise false
-
setAttribute
Description copied from interface:IAttributeStoreSet an attribute on this object.- Specified by:
setAttributein interfaceIAttributeStore- Parameters:
enm- the enum of the attribute to changevalue- the new value of the attribute- Returns:
- true if the attribute value was added or changed, otherwise false
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributesin interfaceIAttributeStore- Parameters:
values- the attributes to set- Returns:
- true if the attribute values changed otherwise false
-
setAttributes
Set multiple attributes on this object.- Specified by:
setAttributesin interfaceIAttributeStore- Parameters:
values- the attributes to set- Returns:
- true if the attribute values changed otherwise false
-
registerServiceHandler
Register an object that provides methods which handle calls without a service name to a shared object.- Specified by:
registerServiceHandlerin interfaceISharedObjectHandlerProvider- Parameters:
handler- the handler object
-
registerServiceHandler
Register an object that provides methods which can be called from a client.
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.- Specified by:
registerServiceHandlerin interfaceIServiceHandlerProvider- Parameters:
name- the name of the handlerhandler- the handler object
-
unregisterServiceHandler
public void unregisterServiceHandler() -
unregisterServiceHandler
Unregister the shared object handler for calls without a service name.- Specified by:
unregisterServiceHandlerin interfaceIServiceHandlerProvider- Specified by:
unregisterServiceHandlerin interfaceISharedObjectHandlerProvider- Parameters:
name- the name of the handler
-
getServiceHandler
Return a previously registered service handler.- Specified by:
getServiceHandlerin interfaceIServiceHandlerProvider- Parameters:
name- the name of the handler to return- Returns:
- the previously registered handler
-
getServiceHandlerNames
Get list of registered service handler names.- Specified by:
getServiceHandlerNamesin interfaceIServiceHandlerProvider- Returns:
- the names of the registered handlers
-
clear
public boolean clear()Deletes all the attributes and sends a clear event to all listeners. The persistent data object is also removed from a persistent shared object.- Specified by:
clearin interfaceISharedObjectBase- Returns:
- true if successful; false otherwise
-
close
public void close()Detaches a reference from this shared object, this will destroy the reference immediately. This is useful when you don't want to proxy a shared object any longer.- Specified by:
closein interfaceISharedObjectBase
-
getStatistics
Return statistics about the shared object.- Specified by:
getStatisticsin interfaceISharedObject- Returns:
- statistics
-
toString
-