org.alfresco.util.registry
Class NamedObjectRegistry

java.lang.Object
  extended by org.alfresco.util.registry.NamedObjectRegistry

public class NamedObjectRegistry
extends java.lang.Object

An generic registry of objects held by name. This is effectively a strongly-typed, synchronized map.

Since:
3.2

Constructor Summary
NamedObjectRegistry()
          Default constructor.
NamedObjectRegistry(java.lang.Class type)
          Constructor that takes care of NamedObjectRegistry.setStorageType(Class).
 
Method Summary
 java.util.Map getAllNamedObjects()
           
 java.lang.Object getNamedObject(java.lang.String name)
          Get a named object if it has been registered
 void register(java.lang.String name, java.lang.Object object)
          Register a named object instance.
 void reset()
           
 void setNamePattern(java.lang.String namePattern)
          Optionally set a pattern to which all object names must conform
 void setStorageType(java.lang.Class clazz)
          Set the type of class that the registry holds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedObjectRegistry

public NamedObjectRegistry()
Default constructor. The NamedObjectRegistry.setStorageType(Class) method must be called.


NamedObjectRegistry

public NamedObjectRegistry(java.lang.Class type)
Constructor that takes care of NamedObjectRegistry.setStorageType(Class).

See Also:
NamedObjectRegistry.setStorageType(Class)
Method Detail

setStorageType

public void setStorageType(java.lang.Class clazz)
Set the type of class that the registry holds. Any attempt to register a an instance of another type will be rejected.

Parameters:
clazz - the type to store

setNamePattern

public void setNamePattern(java.lang.String namePattern)
Optionally set a pattern to which all object names must conform

Parameters:
namePattern - a regular expression

register

public void register(java.lang.String name,
                     java.lang.Object object)
Register a named object instance.

Parameters:
name - the name of the object
object - the instance to register, which correspond to the type

getNamedObject

public java.lang.Object getNamedObject(java.lang.String name)
Get a named object if it has been registered

Parameters:
name - the name of the object to retrieve
Returns:
Returns the instance of the object, which will necessarily be of the correct type, or null

getAllNamedObjects

public java.util.Map getAllNamedObjects()
Returns:
Returns a copy of the map of instances

reset

public void reset()


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.