org.jdesktop.wonderland.client.cell.registry
Class CellRegistry

java.lang.Object
  extended by org.jdesktop.wonderland.client.cell.registry.CellRegistry
All Implemented Interfaces:
PrimaryServerListener

public class CellRegistry
extends java.lang.Object
implements PrimaryServerListener

The Cell Registry manages the collection of Cell registered with the system. Each Cell is represented by a Cell Factory that implements the CellFactorySPI interface. This CellFactorySPI interface tells the system how to create a new instance of the Cell in the world.

Modules may register Cell Factories in this Cell Registry in one of two ways:

(1) Annotate their CellFactorySPI class with the @CellFactory annotation. (2) Manually register their CellFactorySPI class using registerCellFactory().

This class maintains the set of registered Cell Factories for the current primary ServerSessionManager. When the primary ServerSessionManager changes, the current set of Cell Factories that were registered via the @CellFactory annotation are unregistered before the set of Cell Factories associated with the new primary ServerSessionManager and annotated with @CellFactory are added.

Modules that manually add CellFactorySPI class with registerCellFactory() must manually unregister their class with unregisterCellFactory() whenever the primary ServerSessionManager changes.

Author:
Jordan Slott

Nested Class Summary
static interface CellRegistry.CellRegistryListener
          A listener indicating that a change has happened to the set of registered Cell factories.
 
Constructor Summary
CellRegistry()
          Default constructor
 
Method Summary
 void addCellRegistryListener(CellRegistry.CellRegistryListener listener)
          Adds a new listener for changes to the Cell registry.
 java.util.Set<CellFactorySPI> getAllCellFactories()
          Returns a set of all cell factories.
 java.util.Set<CellFactorySPI> getCellFactoriesByExtension(java.lang.String extension)
          Returns a set of cell factories given the extension type.
static CellRegistry getCellRegistry()
          Returns a single instance of this class
 void primaryServer(ServerSessionManager server)
          Notification that the primary server has changed.
 void registerCellFactory(CellFactorySPI factory)
          Registers a CellFactory.
protected  void registerFactories(ServerSessionManager manager)
          Register all factories associated with the given session manager.
 void removeCellRegistryListener(CellRegistry.CellRegistryListener listener)
          Removes a listener for changes to the Cell registry.
 void unregisterCellFactory(CellFactorySPI factory)
          Removes a CellFactory registration.
protected  void unregisterFactories()
          Unregister all factories associated with the current session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellRegistry

public CellRegistry()
Default constructor

Method Detail

getCellRegistry

public static final CellRegistry getCellRegistry()
Returns a single instance of this class

Returns:
Single instance of this class.

registerCellFactory

public void registerCellFactory(CellFactorySPI factory)
Registers a CellFactory. This cell factory is used to generate cell setup classes, GUI panels to configuration the cell setup information, and information so that the cell type can be used in a world assembly palette of cell types.

This method also generates an event to the listeners for changes in the set of registered cell factories.

Parameters:
factory - The cell factory

unregisterCellFactory

public void unregisterCellFactory(CellFactorySPI factory)
Removes a CellFactory registration. This method also generates an event to the listeners for changes in the set of registered cell factories.

Parameters:
factory - The cell factory

getAllCellFactories

public java.util.Set<CellFactorySPI> getAllCellFactories()
Returns a set of all cell factories. If no factories are registered, returns an empty set.

Returns:
A set of registered cell factories

getCellFactoriesByExtension

public java.util.Set<CellFactorySPI> getCellFactoriesByExtension(java.lang.String extension)
Returns a set of cell factories given the extension type. If no factories are present for the given extension, returns null.

Parameters:
extension - File type extension (e.g. 'jpg', 'dae')
Returns:
A set of CellFactory objects registered on the extension

primaryServer

public void primaryServer(ServerSessionManager server)
Notification that the primary server has changed. Update our maps accordingly.

Specified by:
primaryServer in interface PrimaryServerListener
Parameters:
server - the new primary server (may be null)

registerFactories

protected void registerFactories(ServerSessionManager manager)
Register all factories associated with the given session manager.


unregisterFactories

protected void unregisterFactories()
Unregister all factories associated with the current session


addCellRegistryListener

public void addCellRegistryListener(CellRegistry.CellRegistryListener listener)
Adds a new listener for changes to the Cell registry. If this listener is already present, this method does nothing.

Parameters:
listener - The new listener to add

removeCellRegistryListener

public void removeCellRegistryListener(CellRegistry.CellRegistryListener listener)
Removes a listener for changes to the Cell registry. If this listener is not present, this method does nothing.

Parameters:
listener - The listener to remove


Open Wonderland - http://openwonderland.org