public class SharedObjectScope extends BasicScope implements ISharedObject, StatusCodes
| Modifier and Type | Field and Description |
|---|---|
protected SharedObject |
so
Scoped shared object
|
creation, keepDelay, keepOnDisconnect, listeners, name, parent, persistenceClass, persistent, store, typeBEAN_NAMEAPP_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 and Description |
|---|
SharedObjectScope(IScope parent,
String name,
boolean persistent,
IPersistenceStore store)
Creates shared object with given parent scope, name, persistence flag state and store object
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
Prevent shared object from being released.
|
boolean |
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.
|
boolean |
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 |
setDirty(boolean dirty)
Sets a "dirty" flag to indicate that the attributes have been modified.
|
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.
|
compareTo, equals, getDepth, getEventListeners, getParent, getType, handleEvent, hasEventListeners, hashCode, hasParent, isConnectionAllowed, isScopeAllowed, isValid, notifyEvent, setKeepDelay, setSecurityHandlersclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetDepth, getParent, getType, hasParent, isConnectionAllowed, isScopeAllowed, isValid, setKeepDelay, setSecurityHandlershandleEventnotifyEventgetEventListenersprotected volatile SharedObject so
public SharedObjectScope(IScope parent, String name, boolean persistent, IPersistenceStore store)
parent - Parent scopename - Namepersistent - Persistence flag statestore - Persistence storepublic void registerSharedObjectSecurity(ISharedObjectSecurity handler)
registerSharedObjectSecurity in interface ISharedObjectSecurityServicehandler - Handler to add.public void unregisterSharedObjectSecurity(ISharedObjectSecurity handler)
unregisterSharedObjectSecurity in interface ISharedObjectSecurityServicehandler - Handler to remove.public Set<ISharedObjectSecurity> getSharedObjectSecurity()
getSharedObjectSecurity in interface ISharedObjectSecurityServicepublic IPersistenceStore getStore()
getStore in interface IBasicScopegetStore in class BasicScopepublic String getName()
getName in interface IBasicScopegetName in class BasicScopepublic String getPath()
getPath in interface IBasicScopegetPath in class BasicScopepublic void setPath(String path)
public boolean isPersistent()
isPersistent in interface ISharedObjectBasepublic void beginUpdate()
beginUpdate in interface ISharedObjectBasepublic void beginUpdate(IEventListener listener)
beginUpdate in interface ISharedObjectBaselistener - Update events listenerpublic void endUpdate()
endUpdate in interface ISharedObjectBasepublic int getVersion()
getVersion in interface ISharedObjectBasepublic void sendMessage(String handler, List<?> arguments)
sendMessage in interface ISharedObjectBasehandler - 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 IAttributeStoreremoveAttribute in interface AttributeStoreMXBeanname - the name of the attribute to removepublic void removeAttributes()
removeAttributes in interface IAttributeStoreremoveAttributes in interface AttributeStoreMXBeanpublic int size()
size in interface IAttributeStorepublic boolean addEventListener(IEventListener listener)
addEventListener in interface IEventObservableaddEventListener in class BasicScopelistener - Listening objectpublic boolean removeEventListener(IEventListener listener)
removeEventListener in interface IEventObservableremoveEventListener in class BasicScopelistener - Listener to removepublic boolean hasAttribute(String name)
hasAttribute in interface IAttributeStorehasAttribute in interface AttributeStoreMXBeanname - the name of the attribute to checkpublic Object getAttribute(String name)
getAttribute in interface IAttributeStorename - the name of the attribute to getpublic Object getAttribute(String name, Object value)
if (!hasAttribute(name))
setAttribute(name, defaultValue);
return getAttribute(name);
getAttribute in interface IAttributeStorename - the name of the attribute to getvalue - the value of the attribute to set if the attribute doesn't existpublic Map<String,Object> getAttributes()
getAttributes in interface IAttributeStorepublic Set<String> getAttributeNames()
getAttributeNames in interface IAttributeStoregetAttributeNames in interface AttributeStoreMXBeanpublic Boolean getBoolAttribute(String name)
getBoolAttribute in interface ICastingAttributeStorename - Attribute namepublic Byte getByteAttribute(String name)
getByteAttribute in interface ICastingAttributeStorename - Attribute namepublic Double getDoubleAttribute(String name)
getDoubleAttribute in interface ICastingAttributeStorename - Attribute namepublic Integer getIntAttribute(String name)
getIntAttribute in interface ICastingAttributeStorename - Attribute namepublic List<?> getListAttribute(String name)
getListAttribute in interface ICastingAttributeStorename - Attribute namepublic Long getLongAttribute(String name)
getLongAttribute in interface ICastingAttributeStorename - Attribute namepublic Map<?,?> getMapAttribute(String name)
getMapAttribute in interface ICastingAttributeStorename - Attribute namepublic Set<?> getSetAttribute(String name)
getSetAttribute in interface ICastingAttributeStorename - Attribute namepublic Short getShortAttribute(String name)
getShortAttribute in interface ICastingAttributeStorename - Attribute namepublic String getStringAttribute(String name)
getStringAttribute in interface ICastingAttributeStorename - Attribute namepublic Map<String,Object> getData()
getData in interface ISharedObjectBaseprotected boolean isConnectionAllowed()
protected boolean isWriteAllowed(String key, Object value)
key - keyvalue - valueprotected boolean isDeleteAllowed(String key)
key - keyprotected boolean isSendAllowed(String message, List<?> arguments)
message - messagearguments - argumentspublic void dispatchEvent(IEvent e)
dispatchEvent in interface IEventDispatcherdispatchEvent in class BasicScopee - Event to dispatchpublic boolean setAttribute(String name, Object value)
setAttribute in interface IAttributeStorename - the name of the attribute to changevalue - the new value of the attributepublic boolean setAttributes(IAttributeStore values)
setAttributes in interface IAttributeStorevalues - the attributes to setpublic boolean setAttributes(Map<String,Object> values)
setAttributes in interface IAttributeStorevalues - the attributes to setpublic void addSharedObjectListener(ISharedObjectListener listener)
addSharedObjectListener in interface ISharedObjectBaselistener - the object to notifypublic void removeSharedObjectListener(ISharedObjectListener listener)
removeSharedObjectListener in interface ISharedObjectBaselistener - the object to unregisterpublic void registerServiceHandler(Object handler)
registerServiceHandler in interface ISharedObjectHandlerProviderhandler - the handler objectpublic void registerServiceHandler(String name, Object handler)
one.two" that provides a method "
callMe", you can call a method "
one.two.callMe" from the client.
registerServiceHandler in interface IServiceHandlerProvidername - the name of the handlerhandler - the handler objectpublic void unregisterServiceHandler()
public void unregisterServiceHandler(String name)
unregisterServiceHandler in interface IServiceHandlerProviderunregisterServiceHandler in interface ISharedObjectHandlerProvidername - the name of the handlerpublic Object getServiceHandler(String name)
getServiceHandler in interface IServiceHandlerProvidername - the name of the handler to returnpublic Set<String> getServiceHandlerNames()
getServiceHandlerNames in interface IServiceHandlerProviderpublic void lock()
lock in interface ISharedObjectBasepublic void unlock()
unlock in interface ISharedObjectBasepublic boolean isLocked()
isLocked in interface ISharedObjectBasepublic boolean clear()
clear in interface ISharedObjectBasepublic void close()
close in interface ISharedObjectBasepublic void acquire()
acquiremust be paired with a call to
releaseso 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.
acquire in interface ISharedObjectpublic boolean isAcquired()
isAcquired in interface ISharedObjecttrueif the SO is acquired, otherwise
false
public void release()
release in interface ISharedObjectpublic ISharedObjectStatistics getStatistics()
getStatistics in interface ISharedObjectpublic void setDirty(boolean dirty)
setDirty in interface ISharedObjectdirty - if dirty / modifiedCopyright © 2005–2017 Red5. All rights reserved.