org.jdesktop.wonderland.client.cell
Class CellCacheBasicImpl

java.lang.Object
  extended by org.jdesktop.wonderland.client.cell.CellCacheBasicImpl
All Implemented Interfaces:
CellCache, CellCacheConnection.CellCacheMessageListener
Direct Known Subclasses:
JmeCellCache

public class CellCacheBasicImpl
extends java.lang.Object
implements CellCache, CellCacheConnection.CellCacheMessageListener

A basic implementation of core cell cache features. This is a convenience class designed to be called from more complete cache implementations.

Author:
paulby

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jdesktop.wonderland.client.cell.CellCache
CellCache.CellCacheListener
 
Field Summary
protected static java.util.logging.Logger logger
           
 
Constructor Summary
CellCacheBasicImpl(WonderlandSession session, java.lang.ClassLoader classLoader, CellCacheConnection cellCacheConnection, CellChannelConnection cellChannelConnection)
          Create a new cache implementation
 
Method Summary
 void addCellCacheListener(CellCache.CellCacheListener listener)
          Add a cell cache listener
 void changeParent(CellID cellID, CellID parentCellID, CellTransform cellTransform)
          TODO - this is not used yet, we are reparenting by removing and adding nodes as a test to ensure there are no threading issues Changes the parent of the cell.
 void configureCell(CellID cellID, CellClientState clientState, java.lang.String cellName)
          (Re)configures an existing cell with a new client state
protected  CellRenderer createCellRenderer(Cell cell)
          Create a the cell renderer for this cache.
 void deleteCell(CellID cellId)
          Delete the cell and all its content from the client
protected  void fireCellLoaded(Cell cell)
          Notify listeners that a cell is loaded
protected  void fireCellLoadFailed(CellID cellID, java.lang.String className, CellID parentCellID, java.lang.Throwable cause)
          Notify listeners that a cell laod failed
protected  void fireCellUnloaded(Cell cell)
          Notify listeners that a cell is unloaded
 Cell getCell(CellID cellId)
          Return the cell with the specified id, or null if no such cell exists.
 CellChannelConnection getCellChannelConnection()
          Get the CellChannelConnection
 Cell[] getCells()
          Return the set of cells in this cache
static Cell getCurrentActiveCell()
          Get the currently active cell for this thread.
 EnvironmentCell getEnvironmentCell()
          Get the singleton environment cell for the world represented by this cache
 java.util.Collection<Cell> getRootCells()
          Returns a collection of root cells in this cache.
 WonderlandSession getSession()
          Return the session with which this cell cache is associated.
 CellStatistics getStatistics()
          Get the CellStatistics for cells in this cache
 ViewCell getViewCell()
          Returns the ViewCell for this cache
 Cell loadCell(CellID cellId, java.lang.String className, com.jme.bounding.BoundingVolume localBounds, CellID parentCellID, CellTransform cellTransform, CellClientState setup, java.lang.String cellName)
          Load the cell and prepare it for use
 void removeCellCacheListener(CellCache.CellCacheListener listener)
          Remove a cell cache listener
 void setViewCell(ViewCell viewCell)
          Set the view cell for this cache
 void unloadCell(CellID cellId)
          Unload the cell from memory, sets the Cells status to DISK
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static java.util.logging.Logger logger
Constructor Detail

CellCacheBasicImpl

public CellCacheBasicImpl(WonderlandSession session,
                          java.lang.ClassLoader classLoader,
                          CellCacheConnection cellCacheConnection,
                          CellChannelConnection cellChannelConnection)
Create a new cache implementation

Parameters:
session - the WonderlandSession the cache is associated with
cellCacheConnection - the connection for sending cell cache information
cellChannelConnection - the connectiong for sending cell channel messages
Method Detail

getCell

public Cell getCell(CellID cellId)
Return the cell with the specified id, or null if no such cell exists.

Specified by:
getCell in interface CellCache
Parameters:
cellId - the id of the cell to return
Returns:
the cell with the specified ID.

getEnvironmentCell

public EnvironmentCell getEnvironmentCell()
Get the singleton environment cell for the world represented by this cache

Specified by:
getEnvironmentCell in interface CellCache
Returns:
the environment cell, or null if there is no environment cell

getCells

public Cell[] getCells()
Return the set of cells in this cache

Returns:

loadCell

public Cell loadCell(CellID cellId,
                     java.lang.String className,
                     com.jme.bounding.BoundingVolume localBounds,
                     CellID parentCellID,
                     CellTransform cellTransform,
                     CellClientState setup,
                     java.lang.String cellName)
Load the cell and prepare it for use

Specified by:
loadCell in interface CellCacheConnection.CellCacheMessageListener

configureCell

public void configureCell(CellID cellID,
                          CellClientState clientState,
                          java.lang.String cellName)
(Re)configures an existing cell with a new client state

Specified by:
configureCell in interface CellCacheConnection.CellCacheMessageListener
Parameters:
cellID - The unique ID of the cell
clientState - The new client state for the cell
cellName - The (new) name of the cell

createCellRenderer

protected CellRenderer createCellRenderer(Cell cell)
Create a the cell renderer for this cache.

Parameters:
cell - the cell to create a renderer for

unloadCell

public void unloadCell(CellID cellId)
Unload the cell from memory, sets the Cells status to DISK

Specified by:
unloadCell in interface CellCacheConnection.CellCacheMessageListener
Parameters:
cellId -

deleteCell

public void deleteCell(CellID cellId)
Delete the cell and all its content from the client

Specified by:
deleteCell in interface CellCacheConnection.CellCacheMessageListener

changeParent

public void changeParent(CellID cellID,
                         CellID parentCellID,
                         CellTransform cellTransform)
TODO - this is not used yet, we are reparenting by removing and adding nodes as a test to ensure there are no threading issues Changes the parent of the cell.

Specified by:
changeParent in interface CellCacheConnection.CellCacheMessageListener
Parameters:
cellID - The Cell ID of the Cell to move
parentCellID - The Cell ID of the new parent
cellTransform - The new local transform of the Cell

getRootCells

public java.util.Collection<Cell> getRootCells()
Returns a collection of root cells in this cache. The returned collection is a copy of the internal collection.

Specified by:
getRootCells in interface CellCache
Returns:
the RootCells for this cache

setViewCell

public void setViewCell(ViewCell viewCell)
Set the view cell for this cache

Specified by:
setViewCell in interface CellCache
Parameters:
viewCell - the view cell

getViewCell

public ViewCell getViewCell()
Returns the ViewCell for this cache

Specified by:
getViewCell in interface CellCache

getSession

public WonderlandSession getSession()
Return the session with which this cell cache is associated.

Specified by:
getSession in interface CellCache
Returns:
the session for this cache

getCellChannelConnection

public CellChannelConnection getCellChannelConnection()
Description copied from interface: CellCache
Get the CellChannelConnection

Specified by:
getCellChannelConnection in interface CellCache
Returns:
the CellChannelConnection for this CellCache

addCellCacheListener

public void addCellCacheListener(CellCache.CellCacheListener listener)
Add a cell cache listener

Specified by:
addCellCacheListener in interface CellCache
Parameters:
listener - the listener to add

removeCellCacheListener

public void removeCellCacheListener(CellCache.CellCacheListener listener)
Remove a cell cache listener

Specified by:
removeCellCacheListener in interface CellCache
Parameters:
listener - the listener to remove

getStatistics

public CellStatistics getStatistics()
Get the CellStatistics for cells in this cache

Specified by:
getStatistics in interface CellCache
Returns:
the cell statistics

fireCellLoaded

protected void fireCellLoaded(Cell cell)
Notify listeners that a cell is loaded

Parameters:
cell - the cell that was loaded

fireCellLoadFailed

protected void fireCellLoadFailed(CellID cellID,
                                  java.lang.String className,
                                  CellID parentCellID,
                                  java.lang.Throwable cause)
Notify listeners that a cell laod failed

Parameters:
cellID - the id of the cell that failed to load
className - the class of the cell that failed to load
parentCellID - the id of the cell's parent
cause - the reason for failure

fireCellUnloaded

protected void fireCellUnloaded(Cell cell)
Notify listeners that a cell is unloaded

Parameters:
cell - the cell that was unloaded

getCurrentActiveCell

public static Cell getCurrentActiveCell()
Get the currently active cell for this thread. If no cell is active, this method return null.

Returns:
the currently active cell for this thread, if any


Open Wonderland - http://openwonderland.org