## org.red5.server.so
Class SharedObjectScope

    java.lang.Object
      org.red5.server.AttributeStore
          org.red5.server.PersistableAttributeStore
              org.red5.server.BasicScope
                  org.red5.server.so.SharedObjectScope

All Implemented Interfaces:
  Iterable<IBasicScope>, AttributeStoreMBean, IEventDispatcher, IEventHandler, IEventListener, IEventObservable, IAttributeStore, IBasicScope, ICastingAttributeStore, ICoreObject, IScopeService, IPersistable, IServiceHandlerProvider, ISharedObject, ISharedObjectBase, ISharedObjectHandlerProvider, ISharedObjectSecurityService, StatusCodes

    public class SharedObjectScope

extends BasicScope
implements ISharedObject, StatusCodes

Special scope for shared objects

Nested Class Summary

Nested classes/interfaces inherited from class org.red5.server.BasicScope
`BasicScope.EmptyBasicScopeIterator`

Field Summary
`protected SharedObject` `so` Scoped shared object

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.so.ISharedObject
`TYPE`

Fields inherited from interface org.red5.server.api.persistence.IPersistable
`TRANSIENT_PREFIX`

Fields inherited from interface org.red5.server.api.so.ISharedObjectSecurityService
`BEAN_NAME`

Fields 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_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_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_UNPAUSE_NOTIFY, NS_UNPUBLISHED_SUCCESS, SO_CREATION_FAILED, SO_NO_READ_ACCESS, SO_NO_WRITE_ACCESS, SO_PERSISTENCE_MISMATCH`

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.
`Map<String,Object>` `getData()` Return a map containing all attributes of the shared object.
`String` `getName()` Return store name
`String` `getPath()` Ruturn scope path
`Object` `getServiceHandler(String name)` Return a previously registered service handler.
`Set<String>` `getServiceHandlerNames()` Get list of registered service handler names.
`Set<ISharedObjectSecurity>` `getSharedObjectSecurity()` Get handlers that protect shared objects.
`ISharedObjectStatistics` `getStatistics()` Return statistics about the shared object.
`IPersistenceStore` `getStore()` Return persistent store
`String` `getType()` Return scope type
`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` `isPersistentObject()` 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)` Removes attribute
`void` `removeAttributes()` Removes all attributes and sets modified flag
`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 attribute by name and return success as boolean
`void` `setAttributes(IAttributeStore values)` Bulk set of attributes from another attributes store
`void` `setAttributes(Map<String,Object> values)` Set attributes from Map
`void` `setName(String name)` Setter for name
`void` `setPath(String path)` Setter for scope path
`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.BasicScope
`getDepth, getEventListeners, getParent, handleEvent, hasEventListeners, hasParent, iterator, notifyEvent, setKeepDelay`

Methods inherited from class org.red5.server.PersistableAttributeStore
`deserialize, getLastModified, isPersistent, modified, serialize, setPersistent, setStore`

Methods inherited from class org.red5.server.AttributeStore
`filterNull, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute`

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
`getDepth, getParent, hasParent, 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.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`

Methods inherited from interface java.lang.Iterable
`iterator`

Methods inherited from interface org.red5.server.api.persistence.IPersistable
`deserialize, getLastModified, isPersistent, serialize, setPersistent, setStore`

Field Detail

### so

    protected SharedObject so

  Scoped shared object

Constructor Detail

### SharedObjectScope

    public SharedObjectScope(IScope parent,
                             String name,
                             boolean persistent,
                             IPersistenceStore store)

  Creates shared object with given parent scope, name, persistence flag state and store object

  Parameters:
    `parent` - Parent scope
    `name` - Name
    `persistent` - Persistence flag state
    `store` - Persistence store

Method Detail

### registerSharedObjectSecurity

    public void registerSharedObjectSecurity(ISharedObjectSecurity handler)

  Add handler that protects shared objects.

  Specified by:
    `registerSharedObjectSecurity` in interface `ISharedObjectSecurityService`
  Parameters:
    `handler` - Handler to add.

### unregisterSharedObjectSecurity

    public void unregisterSharedObjectSecurity(ISharedObjectSecurity handler)

  Remove handler that protects shared objects.

  Specified by:
    `unregisterSharedObjectSecurity` in interface `ISharedObjectSecurityService`
  Parameters:
    `handler` - Handler to remove.

### getSharedObjectSecurity

    public Set<ISharedObjectSecurity> getSharedObjectSecurity()

  Get handlers that protect shared objects.

  Specified by:
    `getSharedObjectSecurity` in interface `ISharedObjectSecurityService`
  Returns:
    list of handlers

### getStore

    public IPersistenceStore getStore()

  Return persistent store

  Specified by:
    `getStore` in interface `IPersistable`
  Overrides:
    `getStore` in class `PersistableAttributeStore`
  Returns:
    Persistence store

### getName

    public String getName()

  Return store name

  Specified by:
    `getName` in interface `IBasicScope`
  Specified by:
    `getName` in interface `IPersistable`
  Overrides:
    `getName` in class `PersistableAttributeStore`
  Returns:
    Store name

### setName

    public void setName(String name)

  Setter for name

  Specified by:
    `setName` in interface `IPersistable`
  Overrides:
    `setName` in class `PersistableAttributeStore`
  Parameters:
    `name` - Name

### getPath

    public String getPath()

  Ruturn scope path

  Specified by:
    `getPath` in interface `IBasicScope`
  Specified by:
    `getPath` in interface `IPersistable`
  Overrides:
    `getPath` in class `BasicScope`
  Returns:
    Path

### setPath

    public void setPath(String path)

  Setter for scope path

  Specified by:
    `setPath` in interface `IPersistable`
  Overrides:
    `setPath` in class `PersistableAttributeStore`
  Parameters:
    `path` - Path

### getType

    public String getType()

  Return scope type

  Specified by:
    `getType` in interface `IBasicScope`
  Specified by:
    `getType` in interface `IPersistable`
  Overrides:
    `getType` in class `PersistableAttributeStore`
  Returns:
    Scope type

### isPersistentObject

    public boolean isPersistentObject()

  Check if the object has been created as persistent shared object by the client.

  Specified by:
    `isPersistentObject` in interface `ISharedObjectBase`
  Returns:
    true if the shared object is persistent, false otherwise

### beginUpdate

    public void beginUpdate()

  Start performing multiple updates to the shared object from serverside code.

  Specified by:
    `beginUpdate` in interface `ISharedObjectBase`

### beginUpdate

    public void beginUpdate(IEventListener listener)

  Start performing multiple updates to the shared object from a connected client.

  Specified by:
    `beginUpdate` in interface `ISharedObjectBase`
  Parameters:
    `listener` - Update events listener

### endUpdate

    public void endUpdate()

  The multiple updates are complete, notify clients about all changes at once.

  Specified by:
    `endUpdate` in interface `ISharedObjectBase`

### getVersion

    public int getVersion()

  Returns the version of the shared object. The version is incremented automatically on each modification.

  Specified by:
    `getVersion` in interface `ISharedObjectBase`
  Returns:
    the version of the shared object

### sendMessage

    public void sendMessage(String handler,
                            List<?> arguments)

  Send a message to a handler of the shared object.

  Specified by:
    `sendMessage` in interface `ISharedObjectBase`
  Parameters:
    `handler` - the name of the handler to call
    `arguments` - a list of objects that should be passed as arguments to the handler

### removeAttribute

    public boolean removeAttribute(String name)

  Removes attribute

  Specified by:
    `removeAttribute` in interface `AttributeStoreMBean`
  Specified by:
    `removeAttribute` in interface `IAttributeStore`
  Overrides:
    `removeAttribute` in class `PersistableAttributeStore`
  Parameters:
    `name` - Attribute name
  Returns:
    true if attribute was removed, false otherwise

### removeAttributes

    public void removeAttributes()

  Removes all attributes and sets modified flag

  Specified by:
    `removeAttributes` in interface `AttributeStoreMBean`
  Specified by:
    `removeAttributes` in interface `IAttributeStore`
  Overrides:
    `removeAttributes` in class `PersistableAttributeStore`

### addEventListener

    public void addEventListener(IEventListener listener)

  Add event listener to list of notified objects

  Specified by:
    `addEventListener` in interface `IEventObservable`
  Overrides:
    `addEventListener` in class `BasicScope`
  Parameters:
    `listener` - Listening object

### removeEventListener

    public void removeEventListener(IEventListener listener)

  Remove event listener from list of listeners

  Specified by:
    `removeEventListener` in interface `IEventObservable`
  Overrides:
    `removeEventListener` in class `BasicScope`
  Parameters:
    `listener` - Listener to remove

### hasAttribute

    public boolean hasAttribute(String name)

  Check the object has an attribute.

  Specified by:
    `hasAttribute` in interface `AttributeStoreMBean`
  Specified by:
    `hasAttribute` in interface `IAttributeStore`
  Overrides:
    `hasAttribute` in class `AttributeStore`
  Parameters:
    `name` - the name of the attribute to check
  Returns:
    true if the attribute exists otherwise false

### getAttribute

    public Object getAttribute(String name)

  Return the value for a given attribute.

  Specified by:
    `getAttribute` in interface `AttributeStoreMBean`
  Specified by:
    `getAttribute` in interface `IAttributeStore`
  Overrides:
    `getAttribute` in class `AttributeStore`
  Parameters:
    `name` - the name of the attribute to get
  Returns:
    the attribute value or null if the attribute doesn't exist

### getAttribute

    public Object getAttribute(String name,
                               Object value)

  Return the value for a given attribute and set it if it doesn't exist.

  Specified by:
    `getAttribute` in interface `AttributeStoreMBean`
  Specified by:
    `getAttribute` in interface `IAttributeStore`
  Overrides:
    `getAttribute` in class `PersistableAttributeStore`
  Parameters:
    `name` - the name of the attribute to get
    `value` - the value of the attribute to set if the attribute doesn't exist
  Returns:
    the attribute value

### getAttributes

    public Map<String,Object> getAttributes()

  Get the attributes. The resulting map will be read-only.

  Specified by:
    `getAttributes` in interface `AttributeStoreMBean`
  Specified by:
    `getAttributes` in interface `IAttributeStore`
  Overrides:
    `getAttributes` in class `AttributeStore`
  Returns:
    map containing all attributes

### getAttributeNames

    public Set<String> getAttributeNames()

  Get the attribute names. The resulting set will be read-only.

  Specified by:
    `getAttributeNames` in interface `AttributeStoreMBean`
  Specified by:
    `getAttributeNames` in interface `IAttributeStore`
  Overrides:
    `getAttributeNames` in class `AttributeStore`
  Returns:
    set containing all attribute names

### getData

    public Map<String,Object> getData()

  Return a map containing all attributes of the shared object.
  NOTE: The returned map will be read-only.

  Specified by:
    `getData` in interface `ISharedObjectBase`
  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

    protected boolean isWriteAllowed(String key,
                                     Object value)

  Call handlers and check if writing to the SO is allowed.

  Parameters:
    `key` - key
    `value` - value
  Returns:
    is write allowed

### isDeleteAllowed

    protected boolean isDeleteAllowed(String key)

  Call handlers and check if deleting a property from the SO is allowed.

  Parameters:
    `key` - key
  Returns:
    is delete allowed

### isSendAllowed

    protected boolean isSendAllowed(String message,
                                    List<?> arguments)

  Call handlers and check if sending a message to the clients connected to the SO is allowed.

  Parameters:
    `message` - message
    `arguments` - arguments
  Returns:
    is send allowed

### dispatchEvent

    public void dispatchEvent(IEvent e)

  Dispatches event (notifies all listeners)

  Specified by:
    `dispatchEvent` in interface `IEventDispatcher`
  Overrides:
    `dispatchEvent` in class `BasicScope`
  Parameters:
    `e` - Event to dispatch

### setAttribute

    public boolean setAttribute(String name,
                                Object value)

  Set attribute by name and return success as boolean

  Specified by:
    `setAttribute` in interface `AttributeStoreMBean`
  Specified by:
    `setAttribute` in interface `IAttributeStore`
  Overrides:
    `setAttribute` in class `PersistableAttributeStore`
  Parameters:
    `name` - Attribute name
    `value` - Attribute value
  Returns:
    true if attribute was set, false otherwise

### setAttributes

    public void setAttributes(IAttributeStore values)

  Bulk set of attributes from another attributes store

  Specified by:
    `setAttributes` in interface `IAttributeStore`
  Overrides:
    `setAttributes` in class `PersistableAttributeStore`
  Parameters:
    `values` - Attributes store

### setAttributes

    public void setAttributes(Map<String,Object> values)

  Set attributes from Map

  Specified by:
    `setAttributes` in interface `IAttributeStore`
  Overrides:
    `setAttributes` in class `PersistableAttributeStore`
  Parameters:
    `values` - Attributes as Map

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### addSharedObjectListener

    public void addSharedObjectListener(ISharedObjectListener listener)

  Register object that will be notified about update events.

  Specified by:
    `addSharedObjectListener` in interface `ISharedObjectBase`
  Parameters:
    `listener` - the object to notify

### removeSharedObjectListener

    public void removeSharedObjectListener(ISharedObjectListener listener)

  Unregister object to not longer receive update events.

  Specified by:
    `removeSharedObjectListener` in interface `ISharedObjectBase`
  Parameters:
    `listener` - the object to unregister

### registerServiceHandler

    public void registerServiceHandler(Object handler)

  Register an object that provides methods which handle calls without a service name to a shared object.

  Specified by:
    `registerServiceHandler` in interface `ISharedObjectHandlerProvider`
  Parameters:
    `handler` - the handler object

### registerServiceHandler

    public void registerServiceHandler(String name,
                                       Object handler)

  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:
    `registerServiceHandler` in interface `IServiceHandlerProvider`
  Parameters:
    `name` - the name of the handler
    `handler` - the handler object

### unregisterServiceHandler

    public void unregisterServiceHandler()

### unregisterServiceHandler

    public void unregisterServiceHandler(String name)

  Unregister the shared object handler for calls without a service name.

  Specified by:
    `unregisterServiceHandler` in interface `IServiceHandlerProvider`
  Specified by:
    `unregisterServiceHandler` in interface `ISharedObjectHandlerProvider`
  Parameters:
    `name` - the name of the handler

### getServiceHandler

    public Object getServiceHandler(String name)

  Return a previously registered service handler.

  Specified by:
    `getServiceHandler` in interface `IServiceHandlerProvider`
  Parameters:
    `name` - the name of the handler to return
  Returns:
    the previously registered handler

### getServiceHandlerNames

    public Set<String> getServiceHandlerNames()

  Get list of registered service handler names.

  Specified by:
    `getServiceHandlerNames` in interface `IServiceHandlerProvider`
  Returns:
    the names of the registered handlers

### lock

    public void lock()

  Locks the shared object instance. Prevents any changes to this object by clients until the SharedObject.unlock() method is called.

  Specified by:
    `lock` in interface `IBasicScope`
  Specified by:
    `lock` in interface `ISharedObjectBase`

### unlock

    public void unlock()

  Unlocks a shared object instance that was locked with SharedObject.lock().

  Specified by:
    `unlock` in interface `IBasicScope`
  Specified by:
    `unlock` in interface `ISharedObjectBase`

### isLocked

    public boolean isLocked()

  Returns the locked state of this SharedObject.

  Specified by:
    `isLocked` in interface `ISharedObjectBase`
  Returns:
    true if in a locked state; false otherwise

### 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:
    `clear` in interface `ISharedObjectBase`
  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:
    `close` in interface `ISharedObjectBase`

### acquire

    public void acquire()

  Prevent shared object from being released. Each call to `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.

  Specified by:
    `acquire` in interface `ISharedObject`

### isAcquired

    public boolean isAcquired()

  Check if shared object currently is acquired.

  Specified by:
    `isAcquired` in interface `ISharedObject`
  Returns:
    `true` if the SO is acquired, otherwise `false`

### 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:
    `release` in interface `ISharedObject`

### getStatistics

    public ISharedObjectStatistics getStatistics()

  Return statistics about the shared object.

  Specified by:
    `getStatistics` in interface `ISharedObject`
  Returns:
    statistics

Copyright © 2006-2010 The Red5 Project