org.red5.server
Class PersistableAttributeStore

java.lang.Object
  extended by org.red5.server.AttributeStore
      extended by org.red5.server.PersistableAttributeStore
All Implemented Interfaces:
IAttributeStore, ICastingAttributeStore, IPersistable, AttributeStoreMXBean

public class PersistableAttributeStore
extends AttributeStore
implements IPersistable

Persistable attributes store. Server-side SharedObjects feature based on this class.


Field Summary
protected  long lastModified
          Last modified Timestamp
protected  String name
          Attribute store name
protected  String path
          Attribute store path (on local hard drive)
protected  boolean persistent
          Persistence flag
protected  IPersistenceStore store
          Store object that deals with save/load routines
protected  String type
          Attribute store type
 
Fields inherited from class org.red5.server.AttributeStore
attributes, log
 
Fields inherited from interface org.red5.server.api.persistence.IPersistable
TRANSIENT_PREFIX
 
Constructor Summary
PersistableAttributeStore(String type, String name, String path, boolean persistent)
          Creates persistable attribute store
 
Method Summary
 void deserialize(Input input)
          Deserializes data from input to attributes
 Object getAttribute(String name, Object defaultValue)
          Return the value for a given attribute and set it if it doesn't exist.
 long getLastModified()
          Returns last modification time as timestamp
 String getName()
          Return store name
 String getPath()
          Ruturn scope path
 IPersistenceStore getStore()
          Return persistent store
 String getType()
          Return scope type
 boolean isPersistent()
          Check whether object is persistent or not
protected  void modified()
          Set last modified flag to current system time
 boolean removeAttribute(String name)
          Removes attribute
 void removeAttributes()
          Removes all attributes and sets modified flag
 void serialize(Output output)
          Serializes byte buffer output, storing them to attributes
 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 setName(String name)
          Setter for name
 void setPath(String path)
          Setter for scope path
 void setPersistent(boolean persistent)
          Set for persistence
 void setStore(IPersistenceStore store)
          Load data from another persistent store
 
Methods inherited from class org.red5.server.AttributeStore
filterNull, from, getAttribute, getAttributeNames, getAttributes, getBoolAttribute, getByteAttribute, getDoubleAttribute, getIntAttribute, getListAttribute, getLongAttribute, getMapAttribute, getSetAttribute, getShortAttribute, getStringAttribute, hasAttribute, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistent

protected boolean persistent
Persistence flag


name

protected String name
Attribute store name


type

protected String type
Attribute store type


path

protected String path
Attribute store path (on local hard drive)


lastModified

protected long lastModified
Last modified Timestamp


store

protected IPersistenceStore store
Store object that deals with save/load routines

Constructor Detail

PersistableAttributeStore

public PersistableAttributeStore(String type,
                                 String name,
                                 String path,
                                 boolean persistent)
Creates persistable attribute store

Parameters:
type - Attribute store type
name - Attribute store name
path - Attribute store path
persistent - Whether store is persistent or not
Method Detail

modified

protected void modified()
Set last modified flag to current system time


isPersistent

public boolean isPersistent()
Check whether object is persistent or not

Specified by:
isPersistent in interface IPersistable
Returns:
true if object is persistent, false otherwise

setPersistent

public void setPersistent(boolean persistent)
Set for persistence

Specified by:
setPersistent in interface IPersistable
Parameters:
persistent - Persistence flag value

getLastModified

public long getLastModified()
Returns last modification time as timestamp

Specified by:
getLastModified in interface IPersistable
Returns:
Timestamp of last attribute modification

getName

public String getName()
Return store name

Specified by:
getName in interface IPersistable
Returns:
Store name

setName

public void setName(String name)
Setter for name

Specified by:
setName in interface IPersistable
Parameters:
name - Name

getPath

public String getPath()
Ruturn scope path

Specified by:
getPath in interface IPersistable
Returns:
Path

setPath

public void setPath(String path)
Setter for scope path

Specified by:
setPath in interface IPersistable
Parameters:
path - Path

getType

public String getType()
Return scope type

Specified by:
getType in interface IPersistable
Returns:
Scope type

serialize

public void serialize(Output output)
               throws IOException
Serializes byte buffer output, storing them to attributes

Specified by:
serialize in interface IPersistable
Parameters:
output - Output object
Throws:
IOException - if error

deserialize

public void deserialize(Input input)
                 throws IOException
Deserializes data from input to attributes

Specified by:
deserialize in interface IPersistable
Parameters:
input - Input object
Throws:
IOException - I/O exception

setStore

public void setStore(IPersistenceStore store)
Load data from another persistent store

Specified by:
setStore in interface IPersistable
Parameters:
store - Persistent store

getStore

public IPersistenceStore getStore()
Return persistent store

Specified by:
getStore in interface IPersistable
Returns:
Persistence store

getAttribute

public Object getAttribute(String name,
                           Object defaultValue)
Return the value for a given attribute and set it if it doesn't exist.

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

setAttribute

public boolean setAttribute(String name,
                            Object value)
Set an attribute on this object.

Specified by:
setAttribute in interface IAttributeStore
Overrides:
setAttribute in class AttributeStore
Parameters:
name - the name of the attribute to change
value - the new value of the attribute
Returns:
true if the attribute value was added or changed, otherwise false

setAttributes

public boolean setAttributes(Map<String,Object> values)
Set multiple attributes on this object.

Specified by:
setAttributes in interface IAttributeStore
Overrides:
setAttributes in class AttributeStore
Parameters:
values - the attributes to set
Returns:
true if the attribute values changed otherwise false

setAttributes

public boolean setAttributes(IAttributeStore values)
Set multiple attributes on this object.

Specified by:
setAttributes in interface IAttributeStore
Overrides:
setAttributes in class AttributeStore
Parameters:
values - the attributes to set
Returns:
true if the attribute values changed otherwise false

removeAttribute

public boolean removeAttribute(String name)
Removes attribute

Specified by:
removeAttribute in interface IAttributeStore
Specified by:
removeAttribute in interface AttributeStoreMXBean
Overrides:
removeAttribute in class AttributeStore
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 IAttributeStore
Specified by:
removeAttributes in interface AttributeStoreMXBean
Overrides:
removeAttributes in class AttributeStore


Copyright © 2006-2012 The Red5 Project