Kieker 1.9

kieker.common.util.registry
Class Registry<E>

java.lang.Object
  extended by kieker.common.util.registry.Registry<E>
Type Parameters:
E - the type of registered objects
All Implemented Interfaces:
IRegistry<E>

public final class Registry<E>
extends Object
implements IRegistry<E>

A simple registry to assign unique ids to objects. The basic strategy is to subdivide the table among Segments, each of which itself is a concurrently readable hash table. Based upon ConcurrentHashMap. Written by Doug Lea with assistance from members of JCP JSR-166 Expert Group and released to the public domain, as explained at http://creativecommons.org/publicdomain/zero/1.0/

Since:
1.5
Author:
Jan Waller

Constructor Summary
Registry()
          Creates a new, empty registry with a default initial capacity (32), load factor (0.75) and concurrencyLevel (8).
 
Method Summary
 void clear()
          Clears the whole registry.
 int get(E value)
          Gets a unique id for an object.
 E get(int id)
          Gets the object associated with the unique id.
 E[] getAll()
          Return an array with all registered objects.
 int getSize()
          Returns the number of registered objects.
 void remove(E value)
          Removes the given element from the registry.
 void setRecordReceiver(IMonitoringRecordReceiver recordReceiver)
          Enables logging of newly registered objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Registry

public Registry()
Creates a new, empty registry with a default initial capacity (32), load factor (0.75) and concurrencyLevel (8).

Method Detail

setRecordReceiver

public final void setRecordReceiver(IMonitoringRecordReceiver recordReceiver)
Enables logging of newly registered objects. Must only be called for E == String

Specified by:
setRecordReceiver in interface IRegistry<E>
Parameters:
recordReceiver - the IMonitoringRecordReceiver logged to

get

public final int get(E value)
Gets a unique id for an object.

Specified by:
get in interface IRegistry<E>
Parameters:
value - the object
Returns:
the unique id

get

public final E get(int id)
Gets the object associated with the unique id.

Specified by:
get in interface IRegistry<E>
Parameters:
id - the unique id
Returns:
the associated object

getAll

public final E[] getAll()
Return an array with all registered objects.

Specified by:
getAll in interface IRegistry<E>
Returns:
array of registered objects

getSize

public final int getSize()
Description copied from interface: IRegistry
Returns the number of registered objects.

Specified by:
getSize in interface IRegistry<E>
Returns:
number of registered objects

remove

public final void remove(E value)
Removes the given element from the registry.

Parameters:
value - The element to remove.

clear

public final void clear()
Clears the whole registry.


Kieker 1.9

Copyright 2014 Kieker Project, http://kieker-monitoring.net