org.jboss.portal.common.util
Class CopyOnWriteRegistry

java.lang.Object
  extended by org.jboss.portal.common.util.CopyOnWriteRegistry

public class CopyOnWriteRegistry
extends java.lang.Object

Implementation of a registry that implements copy on write semantics.

Version:
$Revision: 7228 $
Author:
Julien Viet

Constructor Summary
CopyOnWriteRegistry()
           
 
Method Summary
 java.util.Set getKeys()
          Return an unmodifiable set containing the keys.
 java.lang.Object getRegistration(java.lang.Object key)
          Return a registration or null if it does not exist.
 java.util.Collection getRegistrations()
          Return an unmodifable collection containing the registrations.
 boolean register(java.lang.Object key, java.lang.Object object)
          Register an object.
 java.lang.Object unregister(java.lang.Object key)
          Unregister an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CopyOnWriteRegistry

public CopyOnWriteRegistry()
Method Detail

register

public boolean register(java.lang.Object key,
                        java.lang.Object object)
                 throws java.lang.IllegalArgumentException
Register an object.

Parameters:
key - the registration key
object - the registered object
Returns:
true if the registration was made
Throws:
java.lang.IllegalArgumentException - if the one argument is null

unregister

public java.lang.Object unregister(java.lang.Object key)
                            throws java.lang.IllegalArgumentException
Unregister an object.

Parameters:
key - the registration key
Returns:
true if the unregistration was made
Throws:
java.lang.IllegalArgumentException - if the key is null

getKeys

public java.util.Set getKeys()
Return an unmodifiable set containing the keys.

Returns:
the keys

getRegistrations

public java.util.Collection getRegistrations()
Return an unmodifable collection containing the registrations.

Returns:
the registrations

getRegistration

public java.lang.Object getRegistration(java.lang.Object key)
                                 throws java.lang.IllegalArgumentException
Return a registration or null if it does not exist.

Parameters:
key - the registration key
Returns:
the registeted object
Throws:
java.lang.IllegalArgumentException - if the key is null