com.wowza.wms.sharedobject
Class SharedObject

Object
  extended by com.wowza.wms.sharedobject.SharedObject
All Implemented Interfaces:
ISharedObject

public class SharedObject
extends Object
implements ISharedObject


Field Summary
static int READACCESS
           
static int WRITEACCESS
           
 
Fields inherited from interface com.wowza.wms.sharedobject.ISharedObject
FILEEXTENSION, SHAREDOBJECT_CMD_CONNECT, SHAREDOBJECT_CMD_CONNECTSUCCESS, SHAREDOBJECT_CMD_DELETE, SHAREDOBJECT_CMD_DISCONNECT, SHAREDOBJECT_CMD_ERROR, SHAREDOBJECT_CMD_SEND, SHAREDOBJECT_CMD_SETVALUE, SHAREDOBJECT_STATUS_CHANGE, SHAREDOBJECT_STATUS_CLEAR, SHAREDOBJECT_STATUS_DELETE, SHAREDOBJECT_STATUS_SUCCESS
 
Constructor Summary
SharedObject(String name)
          Create new shared object
SharedObject(String name, boolean isPersistent, String storageDir)
          Create new shared object
 
Method Summary
 void acquire()
          Increment the reference count to this shared object.
 void addClient(IClient client)
          Add a client to this shared object.
 void addSlotListener(ISharedObjectSlotNotify slotListener)
          Add a slot listener.
 void clear()
          Clear all properties from a shared object
 void close()
          Force close this shared object (not implemented)
 boolean containsProperty(String slotName)
          Returns true is slot/property name exists
 boolean containsSlot(String slotName)
          Returns true is slot/property name exists
 void deleteSlot(IClient client, String slotName)
          Remove a slot (property)
 void deleteSlot(String slotName)
          Remove slot (property)
 void disconnect(IClient client)
          Disconnect client from shared object.
 void flush()
          Flush (write to disk) shared object
static boolean[] getAccess(IClient client, String soName)
           
 java.util.List<com.wowza.wms.sharedobject.SharedObjectClient> getClients()
          Get a list of client that are connected to this shared object.
 void getClientUpdates(IClient client)
           
 String getName()
          Get shared object name
 ISharedObjects getParent()
          Get the shared object container to which this shared object belongs.
 AMFData getProperty(String slotName)
          Get slot (property) value.
 int getRefCount()
          Get the current reference (clients) connected to this shared object.
 ISharedObjectSlot getSlot(String name)
          Get ISharedObjectSlot interface to a slot (property) by name
 java.util.List<String> getSlotNames()
          Get a list of slot (property) names
 java.util.List<ISharedObjectSlot> getSlots()
          Get a list of active slots
 String getStorageDir()
          Get path used to store shared object.
 int getVersion()
          Get the internval version number.
 boolean isClient(IClient client)
          Is this client connected to shared object
 boolean isPersistent()
          Is this shared object being persisted.
 void load()
           
 void lock()
          Lock a shared object for write access
 void notifySlotDelete(ISharedObjectSlot slot)
           
 void notifySlotSetValue(ISharedObjectSlot slot)
           
 int purge(int version)
          Purge all deleted properties older than the version number
 void putSlot(String name, ISharedObjectSlot slot)
          Add a new slot (property) to a shared object.
 void release()
          Descrement the reference count to this shared object.
 void removeClient(IClient client)
          Remove a client from this shared object.
 void removeSlotListener(ISharedObjectSlotNotify slotListener)
          Remove slot listener
 void send(String handlerName)
          Call client side handler attached to shared object (no parameters).
 void send(String handlerName, Object... params)
          Call client side handler attached to shared object.
 void sendInternal(IClient client, String handlerName, byte[] msgBytes)
           
 void sendInternal(IClient client, String handlerName, byte[] msgBytes, AMFDataContextDeserialize context)
           
 void sendInternal(String handlerName, AMFData[] params)
           
 void setName(String name)
          Set shared object name
 void setParent(ISharedObjects parent)
           
 void setPersistent(boolean isPersistent)
          Set is shared object persisted.
 void setProperty(String slotName, AMFData data)
          Set slot (property) value as AMFData object.
 void setProperty(String slotName, boolean value)
          Set slot (property) value as a boolean value (will be wrapped in an AMFDataItem object)
 void setProperty(String slotName, java.util.Date value)
          Set slot (property) value as a date value (will be wrapped in an AMFDataItem object)
 void setProperty(String slotName, double value)
          Set slot (property) value as a double value (will be wrapped in an AMFDataItem object)
 void setProperty(String slotName, int value)
          Set slot (property) value as a int value (will be wrapped in an AMFDataItem object)
 void setProperty(String slotName, long value)
          Set slot (property) value as a long value (will be wrapped in an AMFDataItem object)
 void setProperty(String slotName, String value)
          Set slot (property) value as a string value (will be wrapped in an AMFDataItem object)
 void setSlotValue(IClient client, String slotName, AMFData amfData)
           
 void setSlotValue(IClient client, String slotName, byte[] byteData)
           
 void setSlotValue(IClient client, String slotName, byte[] byteData, AMFData amfData)
           
 void setSlotValue(IClient client, String slotName, byte[] byteData, AMFData amfData, AMFDataContextDeserialize context)
           
 void setSlotValue(IClient client, String slotName, byte[] byteData, AMFDataContextDeserialize context)
           
 void setStorageDir(String storageDir)
          Set path used to store shared object.
 void setVersion(int version)
          Set the internal version number.
 int size()
          Get the number of active slot (properties).
 void unlock()
          Unlock a shared object for write access
 void writeDeleteError(IClient client, String soName, boolean isPersistent, String slotName, String errorMsg)
          Write an delete error message back to the client
static void writeError(IClient client, String soName, boolean isPersistent, String errorMsg, boolean isConnect)
           
 void writeSetValueError(IClient client, String soName, boolean isPersistent, String slotName, String errorMsg)
          Write an set value error message back to the client
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READACCESS

public static final int READACCESS
See Also:
Constant Field Values

WRITEACCESS

public static final int WRITEACCESS
See Also:
Constant Field Values
Constructor Detail

SharedObject

public SharedObject(String name)
Create new shared object

Parameters:
name - shared object name

SharedObject

public SharedObject(String name,
                    boolean isPersistent,
                    String storageDir)
Create new shared object

Parameters:
name - shared object name
isPersistent - is persistent
storageDir - storage directory for persistent shared object
Method Detail

acquire

public void acquire()
Description copied from interface: ISharedObject
Increment the reference count to this shared object.

Specified by:
acquire in interface ISharedObject

addClient

public void addClient(IClient client)
Description copied from interface: ISharedObject
Add a client to this shared object.

Specified by:
addClient in interface ISharedObject
Parameters:
client - client

addSlotListener

public void addSlotListener(ISharedObjectSlotNotify slotListener)
Description copied from interface: ISharedObject
Add a slot listener. Will receive the following events: onSlotSetValue and onSlotDelete

Specified by:
addSlotListener in interface ISharedObject
Parameters:
slotListener - slot listener

clear

public void clear()
Description copied from interface: ISharedObject
Clear all properties from a shared object

Specified by:
clear in interface ISharedObject

close

public void close()
Description copied from interface: ISharedObject
Force close this shared object (not implemented)

Specified by:
close in interface ISharedObject

containsProperty

public boolean containsProperty(String slotName)
Description copied from interface: ISharedObject
Returns true is slot/property name exists

Specified by:
containsProperty in interface ISharedObject
Parameters:
slotName - slot/property name
Returns:
true is slot/property name exists

containsSlot

public boolean containsSlot(String slotName)
Description copied from interface: ISharedObject
Returns true is slot/property name exists

Specified by:
containsSlot in interface ISharedObject
Parameters:
slotName - slot/property name
Returns:
true is slot/property name exists

deleteSlot

public void deleteSlot(IClient client,
                       String slotName)
Description copied from interface: ISharedObject
Remove a slot (property)

Specified by:
deleteSlot in interface ISharedObject
Parameters:
client - client removing slot or null if server side code
slotName - slot (property) name

deleteSlot

public void deleteSlot(String slotName)
Description copied from interface: ISharedObject
Remove slot (property)

Specified by:
deleteSlot in interface ISharedObject
Parameters:
slotName - slot (property) name

disconnect

public void disconnect(IClient client)
Description copied from interface: ISharedObject
Disconnect client from shared object.

Specified by:
disconnect in interface ISharedObject
Parameters:
client - client to disconnect

flush

public void flush()
Description copied from interface: ISharedObject
Flush (write to disk) shared object

Specified by:
flush in interface ISharedObject

getAccess

public static boolean[] getAccess(IClient client,
                                  String soName)

getClients

public java.util.List<com.wowza.wms.sharedobject.SharedObjectClient> getClients()
Description copied from interface: ISharedObject
Get a list of client that are connected to this shared object.

Specified by:
getClients in interface ISharedObject
Returns:
list of client that are connected to this shared object

getClientUpdates

public void getClientUpdates(IClient client)

getName

public String getName()
Description copied from interface: ISharedObject
Get shared object name

Specified by:
getName in interface ISharedObject
Returns:
shared object name

getParent

public ISharedObjects getParent()
Description copied from interface: ISharedObject
Get the shared object container to which this shared object belongs.

Specified by:
getParent in interface ISharedObject
Returns:
shared object container

getProperty

public AMFData getProperty(String slotName)
Description copied from interface: ISharedObject
Get slot (property) value.

Specified by:
getProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
Returns:
slot (property) value as AMFData object

getRefCount

public int getRefCount()
Description copied from interface: ISharedObject
Get the current reference (clients) connected to this shared object. Includes unbalanced count of calls to acquire.

Specified by:
getRefCount in interface ISharedObject
Returns:
the current reference (clients) connected to this shared object

getSlot

public ISharedObjectSlot getSlot(String name)
Description copied from interface: ISharedObject
Get ISharedObjectSlot interface to a slot (property) by name

Specified by:
getSlot in interface ISharedObject
Parameters:
name - slot (property) name
Returns:
ISharedObjectSlot interface

getSlotNames

public java.util.List<String> getSlotNames()
Description copied from interface: ISharedObject
Get a list of slot (property) names

Specified by:
getSlotNames in interface ISharedObject
Returns:
list of slot (property) names

getSlots

public java.util.List<ISharedObjectSlot> getSlots()
Description copied from interface: ISharedObject
Get a list of active slots

Specified by:
getSlots in interface ISharedObject
Returns:
list of active slots

getStorageDir

public String getStorageDir()
Description copied from interface: ISharedObject
Get path used to store shared object.

Specified by:
getStorageDir in interface ISharedObject
Returns:
path used to store shared object

getVersion

public int getVersion()
Description copied from interface: ISharedObject
Get the internval version number.

Specified by:
getVersion in interface ISharedObject
Returns:
internval version number

isClient

public boolean isClient(IClient client)
Description copied from interface: ISharedObject
Is this client connected to shared object

Specified by:
isClient in interface ISharedObject
Parameters:
client - client
Returns:
true if client is conencted to shared object

isPersistent

public boolean isPersistent()
Description copied from interface: ISharedObject
Is this shared object being persisted.

Specified by:
isPersistent in interface ISharedObject
Returns:
true if shared object is being persisted

load

public void load()

lock

public void lock()
Description copied from interface: ISharedObject
Lock a shared object for write access

Specified by:
lock in interface ISharedObject

notifySlotDelete

public void notifySlotDelete(ISharedObjectSlot slot)

notifySlotSetValue

public void notifySlotSetValue(ISharedObjectSlot slot)

purge

public int purge(int version)
Description copied from interface: ISharedObject
Purge all deleted properties older than the version number

Specified by:
purge in interface ISharedObject
Returns:
number of slots purged

putSlot

public void putSlot(String name,
                    ISharedObjectSlot slot)
Description copied from interface: ISharedObject
Add a new slot (property) to a shared object.

Specified by:
putSlot in interface ISharedObject
Parameters:
name - slot (property) name
slot - new slot

release

public void release()
Description copied from interface: ISharedObject
Descrement the reference count to this shared object.

Specified by:
release in interface ISharedObject

removeClient

public void removeClient(IClient client)
Description copied from interface: ISharedObject
Remove a client from this shared object.

Specified by:
removeClient in interface ISharedObject
Parameters:
client - client

removeSlotListener

public void removeSlotListener(ISharedObjectSlotNotify slotListener)
Description copied from interface: ISharedObject
Remove slot listener

Specified by:
removeSlotListener in interface ISharedObject
Parameters:
slotListener - slot listener

send

public void send(String handlerName)
Description copied from interface: ISharedObject
Call client side handler attached to shared object (no parameters).

Specified by:
send in interface ISharedObject
Parameters:
handlerName - handler name

send

public void send(String handlerName,
                 Object... params)
Description copied from interface: ISharedObject
Call client side handler attached to shared object.

Specified by:
send in interface ISharedObject
Parameters:
handlerName - handler name
params - variable argument list of parameters

sendInternal

public void sendInternal(IClient client,
                         String handlerName,
                         byte[] msgBytes)

sendInternal

public void sendInternal(IClient client,
                         String handlerName,
                         byte[] msgBytes,
                         AMFDataContextDeserialize context)

sendInternal

public void sendInternal(String handlerName,
                         AMFData[] params)

setName

public void setName(String name)
Description copied from interface: ISharedObject
Set shared object name

Specified by:
setName in interface ISharedObject
Parameters:
name - shared object name

setParent

public void setParent(ISharedObjects parent)

setPersistent

public void setPersistent(boolean isPersistent)
Description copied from interface: ISharedObject
Set is shared object persisted.

Specified by:
setPersistent in interface ISharedObject
Parameters:
isPersistent - true if shared object is being persisted

setProperty

public void setProperty(String slotName,
                        AMFData data)
Description copied from interface: ISharedObject
Set slot (property) value as AMFData object.

Specified by:
setProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
data - slot value as AMFData object. Example: new AMFDataItem((double)1.234) or new AMFDataItem()

setProperty

public void setProperty(String slotName,
                        boolean value)
Description copied from interface: ISharedObject
Set slot (property) value as a boolean value (will be wrapped in an AMFDataItem object)

Specified by:
setProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
value - boolean value

setProperty

public void setProperty(String slotName,
                        java.util.Date value)
Description copied from interface: ISharedObject
Set slot (property) value as a date value (will be wrapped in an AMFDataItem object)

Specified by:
setProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
value - date value

setProperty

public void setProperty(String slotName,
                        double value)
Description copied from interface: ISharedObject
Set slot (property) value as a double value (will be wrapped in an AMFDataItem object)

Specified by:
setProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
value - double value

setProperty

public void setProperty(String slotName,
                        int value)
Description copied from interface: ISharedObject
Set slot (property) value as a int value (will be wrapped in an AMFDataItem object)

Specified by:
setProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
value - int value

setProperty

public void setProperty(String slotName,
                        long value)
Description copied from interface: ISharedObject
Set slot (property) value as a long value (will be wrapped in an AMFDataItem object)

Specified by:
setProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
value - long value

setProperty

public void setProperty(String slotName,
                        String value)
Description copied from interface: ISharedObject
Set slot (property) value as a string value (will be wrapped in an AMFDataItem object)

Specified by:
setProperty in interface ISharedObject
Parameters:
slotName - slot (property) name
value - string value

setSlotValue

public void setSlotValue(IClient client,
                         String slotName,
                         AMFData amfData)

setSlotValue

public void setSlotValue(IClient client,
                         String slotName,
                         byte[] byteData)

setSlotValue

public void setSlotValue(IClient client,
                         String slotName,
                         byte[] byteData,
                         AMFData amfData)

setSlotValue

public void setSlotValue(IClient client,
                         String slotName,
                         byte[] byteData,
                         AMFData amfData,
                         AMFDataContextDeserialize context)

setSlotValue

public void setSlotValue(IClient client,
                         String slotName,
                         byte[] byteData,
                         AMFDataContextDeserialize context)

setStorageDir

public void setStorageDir(String storageDir)
Description copied from interface: ISharedObject
Set path used to store shared object.

Specified by:
setStorageDir in interface ISharedObject
Parameters:
storageDir - path used to store shared object

setVersion

public void setVersion(int version)
Description copied from interface: ISharedObject
Set the internal version number.

Specified by:
setVersion in interface ISharedObject
Parameters:
version - internal version number

size

public int size()
Description copied from interface: ISharedObject
Get the number of active slot (properties). Deleted slots are not counted.

Specified by:
size in interface ISharedObject
Returns:
number of active slot (properties). Deleted slots are not counted

unlock

public void unlock()
Description copied from interface: ISharedObject
Unlock a shared object for write access

Specified by:
unlock in interface ISharedObject

writeDeleteError

public void writeDeleteError(IClient client,
                             String soName,
                             boolean isPersistent,
                             String slotName,
                             String errorMsg)
Description copied from interface: ISharedObject
Write an delete error message back to the client

Specified by:
writeDeleteError in interface ISharedObject
Parameters:
client - client removing slot or null if server side code
soName - sharedObject name
isPersistent - is persistent
slotName - slot name
errorMsg - error message

writeError

public static void writeError(IClient client,
                              String soName,
                              boolean isPersistent,
                              String errorMsg,
                              boolean isConnect)

writeSetValueError

public void writeSetValueError(IClient client,
                               String soName,
                               boolean isPersistent,
                               String slotName,
                               String errorMsg)
Description copied from interface: ISharedObject
Write an set value error message back to the client

Specified by:
writeSetValueError in interface ISharedObject
Parameters:
client - client removing slot or null if server side code
soName - sharedObject name
isPersistent - is persistent
slotName - slot name
errorMsg - error message