org.red5.server.so

## Class SharedObjectService

- java.lang.Object
- - org.red5.server.so.SharedObjectService

All Implemented Interfaces:
  IScopeService, ISharedObjectService, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean

    public class SharedObjectService
    extends Object
    implements ISharedObjectService, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

Shared object service

### Field Summary

Fields
`static ExecutorService` `SHAREDOBJECT_EXECUTOR`

### Fields inherited from interface org.red5.server.api.so.ISharedObjectService

`BEAN_NAME`

### Constructor Summary

Constructors
Constructor and Description
`SharedObjectService()`

### Method Summary

Methods
`void` `afterPropertiesSet()`
`boolean` `clearSharedObjects(IScope scope, String name)` Deletes persistent shared objects specified by name and clears all properties from active shared objects (persistent and nonpersistent).
`boolean` `createSharedObject(IScope scope, String name, boolean persistent)` Create a new shared object.
`void` `destroy()`
`ISharedObject` `getSharedObject(IScope scope, String name)` Get a shared object by name.
`ISharedObject` `getSharedObject(IScope scope, String name, boolean persistent)` Get a shared object by name and create it if it doesn't exist.
`Set<String>` `getSharedObjectNames(IScope scope)` Get a set of the shared object names.
`boolean` `hasSharedObject(IScope scope, String name)` Check if a shared object exists.
`void` `setExecutorThreadPoolSize(int value)`
`void` `setPersistenceClassName(String name)` Setter for persistence class name.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SHAREDOBJECT_EXECUTOR

    public static ExecutorService SHAREDOBJECT_EXECUTOR

### Constructor Detail

#### SharedObjectService

    public SharedObjectService()

### Method Detail

#### setExecutorThreadPoolSize

    public void setExecutorThreadPoolSize(int value)

#### afterPropertiesSet

    public void afterPropertiesSet()
                            throws Exception

Specified by:
  `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
Throws:
  `Exception`

#### setPersistenceClassName

    public void setPersistenceClassName(String name)

Setter for persistence class name.

Parameters:
  `name` - Setter for persistence class name

#### createSharedObject

    public boolean createSharedObject(IScope scope,
                             String name,
                             boolean persistent)

Create a new shared object.

Specified by:
  `createSharedObject` in interface `ISharedObjectService`
Parameters:
  `scope` - the scope to create the shared object in
  `name` - the name of the shared object
  `persistent` - will the shared object be persistent
Returns:
  `true` if the shared object was created, otherwise `false`

#### getSharedObject

    public ISharedObject getSharedObject(IScope scope,
                                String name)

Get a shared object by name.

Specified by:
  `getSharedObject` in interface `ISharedObjectService`
Parameters:
  `scope` - the scope to get the shared object from
  `name` - the name of the shared object
Returns:
  shared object, or `null` if not found

#### getSharedObject

    public ISharedObject getSharedObject(IScope scope,
                                String name,
                                boolean persistent)

Get a shared object by name and create it if it doesn't exist.

Specified by:
  `getSharedObject` in interface `ISharedObjectService`
Parameters:
  `scope` - the scope to get the shared object from
  `name` - the name of the shared object
  `persistent` - should the shared object be created persistent
Returns:
  the shared object

#### getSharedObjectNames

    public Set<String> getSharedObjectNames(IScope scope)

Get a set of the shared object names.

Specified by:
  `getSharedObjectNames` in interface `ISharedObjectService`
Parameters:
  `scope` - the scope to return the shared object names from
Returns:
  set containing the shared object names

#### hasSharedObject

    public boolean hasSharedObject(IScope scope,
                          String name)

Check if a shared object exists.

Specified by:
  `hasSharedObject` in interface `ISharedObjectService`
Parameters:
  `scope` - the scope to check for the shared object
  `name` - the name of the shared object
Returns:
  `true` if the shared object exists, otherwise `false`

#### clearSharedObjects

    public boolean clearSharedObjects(IScope scope,
                             String name)

Deletes persistent shared objects specified by name and clears all properties from active shared objects (persistent and nonpersistent). The name parameter specifies the name of a shared object, which can include a slash (/) as a delimiter between directories in the path. The last element in the path can contain wildcard patterns (for example, a question mark [?] and an asterisk [*]) or a shared object name. The clearSharedObjects() method traverses the shared object hierarchy along the specified path and clears all the shared objects. Specifying a slash (/) clears all the shared objects associated with an application instance.

The following values are possible for the soPath parameter:
/ clears all local and persistent shared objects associated with the instance.
/foo/bar clears the shared object /foo/bar; if bar is a directory name, no shared objects are deleted.
/foo/bar/* clears all shared objects stored under the instance directory /foo/bar. The bar directory is also deleted if no persistent shared objects are in use within this namespace.
/foo/bar/XX?? clears all shared objects that begin with XX, followed by any two characters. If a directory name matches this specification, all the shared objects within this directory are cleared.

If you call the clearSharedObjects() method and the specified path matches a shared object that is currently active, all its properties are deleted, and a "clear" event is sent to all subscribers of the shared object. If it is a persistent shared object, the persistent store is also cleared.

Specified by:
  `clearSharedObjects` in interface `ISharedObjectService`
Parameters:
  `scope` - the scope to check for the shared object
  `name` - the name of the shared object
Returns:
  true if the shared object at the specified path was deleted; otherwise, false. If using wildcard characters to delete multiple files, the method returns true only if all the shared objects matching the wildcard pattern were successfully deleted; otherwise, it will return false.

#### destroy

    public void destroy()
                 throws Exception

Specified by:
  `destroy` in interface `org.springframework.beans.factory.DisposableBean`
Throws:
  `Exception`