Package org.red5.server.persistence
Class RamPersistence
java.lang.Object
org.red5.server.persistence.RamPersistence
- All Implemented Interfaces:
IPersistenceStore
Persistence implementation that stores the objects in memory. This serves as default persistence if nothing has been configured.
- Author:
- The Red5 Project, Joachim Bauch (jojo@struktur.de), Michael Klishin (michael@novemberain.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConcurrentMap<String, IPersistable> Map for persistable objectsprotected static final StringThis is used in the id for objects that have a name ofprotected org.springframework.core.io.support.ResourcePatternResolverResource pattern resolver. -
Constructor Summary
ConstructorsConstructorDescriptionRamPersistence(IScope scope) Creates RAM persistence object from scopeRamPersistence(org.springframework.core.io.support.ResourcePatternResolver resources) Creates RAM persistence object from resource pattern resolvers -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetObjectId(IPersistable object) Get object idprotected StringgetObjectName(String id) Get resource name from path.Return iterator over the names of all already loaded objects in the storage.protected StringgetObjectPath(String id, String name) Get object path for given id and name.Return iterator over the already loaded objects in the storage.Load a persistent object with the given name.booleanload(IPersistable obj) Load state of an already instantiated persistent object.voidNotify store that it's being closed.booleanDelete the persistent object with the given name.booleanremove(IPersistable object) Delete the passed persistent object.booleansave(IPersistable object) Persist given object.
-
Field Details
-
PERSISTENCE_NO_NAME
This is used in the id for objects that have a name ofnull
- See Also:
-
objects
Map for persistable objects -
resources
protected org.springframework.core.io.support.ResourcePatternResolver resourcesResource pattern resolver. Resolves resources from patterns, loads resources.
-
-
Constructor Details
-
RamPersistence
public RamPersistence(org.springframework.core.io.support.ResourcePatternResolver resources) Creates RAM persistence object from resource pattern resolvers- Parameters:
resources- Resource pattern resolver and loader
-
RamPersistence
Creates RAM persistence object from scope- Parameters:
scope- Scope
-
-
Method Details
-
getObjectName
Get resource name from path. The format of the object id istype / path / objectName
- Parameters:
id- object id- Returns:
- resource name
-
getObjectPath
Get object path for given id and name. The format of the object id istype / path / objectName
- Parameters:
id- object idname- object name- Returns:
- resource path
-
getObjectId
Get object id- Parameters:
object- Persistable object whose id is asked for- Returns:
- Given persistable object id
-
save
Persist given object.- Specified by:
savein interfaceIPersistenceStore- Parameters:
object- Object to store- Returns:
true
on success,false
otherwise
-
load
Load a persistent object with the given name. The object must provide either a constructor that takes an input stream as only parameter or an empty constructor so it can be loaded from the persistence store.- Specified by:
loadin interfaceIPersistenceStore- Parameters:
name- the name of the object to load- Returns:
- The loaded object or
null
if no such object was found
-
load
Load state of an already instantiated persistent object.- Specified by:
loadin interfaceIPersistenceStore- Parameters:
obj- the object to initializ- Returns:
- true if the object was initialized, false otherwise
-
remove
Delete the passed persistent object.- Specified by:
removein interfaceIPersistenceStore- Parameters:
object- the object to delete- Returns:
true
if object was persisted and thus can be removed,false
otherwise
-
remove
Delete the persistent object with the given name.- Specified by:
removein interfaceIPersistenceStore- Parameters:
name- the name of the object to delete- Returns:
true
if object was persisted and thus can be removed,false
otherwise
-
getObjectNames
Return iterator over the names of all already loaded objects in the storage.- Specified by:
getObjectNamesin interfaceIPersistenceStore- Returns:
- Set of all object names
-
getObjects
Return iterator over the already loaded objects in the storage.- Specified by:
getObjectsin interfaceIPersistenceStore- Returns:
- Set of all objects
-
notifyClose
public void notifyClose()Notify store that it's being closed. This allows the store to write any pending objects to disk.- Specified by:
notifyClosein interfaceIPersistenceStore
-