org.norther.tammi.core.base
Class DefaultRegistry<K,V>

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultRegistry<K,V>
Type Parameters:
K - the registry key type.
V - the registered MBean type.
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Manageable, MBeanDelegate, Registry<K,V>

public class DefaultRegistry<K,V>
extends Adaptee
implements Registry<K,V>

A default implementation of Registry.

Version:
$Id: DefaultRegistry.java,v 1.9 2009/09/28 15:08:42 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Constructor Summary
  DefaultRegistry()
          Constructs a new registry MBean.
  DefaultRegistry(String ifname)
          Constructs a new registry MBean with a named interface.
protected DefaultRegistry(String ifname, int capacity)
          Constructs a new registry MBean with a named interface and initial capacity.
 
Method Summary
protected  int addRegistryKeys(String ifname, ObjectName name, int limit, Collection<K> result)
          Adds specified registry keys into a collection.
 void clear()
          Clears all MBeans from this registry.
 boolean containsKey(Object key)
          Checks whether the specified key is registered in this registry.
 V get(Object key)
          Gets the referent of the MBean in this registry.
 MBeanReference<V> getMBean(Object key)
          Gets a reference to the MBean in this registry.
protected  MBeanHandle<V> getMBeanHandle(Object key)
          Gets a reference to a mapped MBean.
protected  ConcurrentMap<K,MBeanHandle<V>> getMBeanHandles()
          Gets a map of MBean references.
 String getMBeanInterface()
          Gets the interface of MBeans in this registry.
 String getMBeanInterface(Object key)
          Gets the interface of a registry MBean.
 ObjectName getObjectName(Object key)
          Gets the object name of the MBean in this registry, which is also registered in the MBean server.
 Set<ObjectName> getObjectNames(Object key)
          Gets a set of object names registered in the MBean server with names matching the query pattern of the MBean in this registry.
 ObjectName getQueryPattern(Object key)
          Gets the query pattern, with which the MBean is registered in this registry.
 K getRegistryKey(ObjectName name)
          Gets the key of a named MBean in this registry.
 K getRegistryKey(String ifname)
          Gets the key of an MBean of a specific class in this registry.
 K getRegistryKey(String ifname, ObjectName name)
          Gets the key of a named MBean of a specific class in this registry.
 Set<K> registryKeySet()
          Returns a read-only set of all registered keys.
 Set<K> registryKeySet(ObjectName name)
          Returns a set of registered keys a named MBean in this registry.
 Set<K> registryKeySet(String ifname)
          Returns a set of registered keys of MBeans of a specific class in this registry.
 Set<K> registryKeySet(String ifname, ObjectName name)
          Returns a set of registered keys of a named MBean of a specific class in this registry.
 Map<K,ObjectName> registryMap()
          Returns a map view to this registry.
 int registrySize()
          Gets the size of the registry.
 void remove(Object key)
          Removes an MBean from this registry.
 void setMBeanInterface(K key, String ifname)
          Sets the interface of a registry MBean.
 void setQueryPattern(K key, ObjectName name)
          Sets the query pattern of a registry MBean.
 void setQueryPattern(K key, String ifname, ObjectName name)
          Sets the interface and query pattern of a registry MBean.
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getBroker, getCanonicalName, getDomain, getFactory, getLoader, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, postmanaged, premanaged, removeNotificationListener, removeNotificationListener, sendNotification, sendNotification, sendNotification, sendNotification, unmanaged, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRegistry

public DefaultRegistry()
Constructs a new registry MBean.


DefaultRegistry

public DefaultRegistry(String ifname)
Constructs a new registry MBean with a named interface.

Parameters:
ifname - the name of the interface.

DefaultRegistry

protected DefaultRegistry(String ifname,
                          int capacity)
Constructs a new registry MBean with a named interface and initial capacity.

Parameters:
ifname - the name of the interface.
capacity - the initial capacity.
Method Detail

getMBeanInterface

public String getMBeanInterface()
Description copied from interface: Registry
Gets the interface of MBeans in this registry.

Specified by:
getMBeanInterface in interface Registry<K,V>
Returns:
the MBean interface or null for any.

getQueryPattern

public ObjectName getQueryPattern(Object key)
Description copied from interface: Registry
Gets the query pattern, with which the MBean is registered in this registry. The MBean registration is not checked from the MBean server.

Specified by:
getQueryPattern in interface Registry<K,V>
Parameters:
key - the registry key.
Returns:
the pattern or null if not registered.

setQueryPattern

public void setQueryPattern(K key,
                            ObjectName name)
Description copied from interface: Registry
Sets the query pattern of a registry MBean.

Specified by:
setQueryPattern in interface Registry<K,V>
Parameters:
key - the registry key.
name - the object name or a query pattern.

setQueryPattern

public void setQueryPattern(K key,
                            String ifname,
                            ObjectName name)
Description copied from interface: Registry
Sets the interface and query pattern of a registry MBean. If the registry is already configured for a specific interface, the interface name must correspond to it.

Specified by:
setQueryPattern in interface Registry<K,V>
Parameters:
key - the registry key.
ifname - the class or interface name.
name - the object name or a query pattern.

getMBeanInterface

public String getMBeanInterface(Object key)
Description copied from interface: Registry
Gets the interface of a registry MBean.

Specified by:
getMBeanInterface in interface Registry<K,V>
Parameters:
key - the registry key.
Returns:
the class or interface name or null if not registered.

setMBeanInterface

public void setMBeanInterface(K key,
                              String ifname)
Description copied from interface: Registry
Sets the interface of a registry MBean. If the registry is already configured for a specific interface, the interface name must correspond to it.

Specified by:
setMBeanInterface in interface Registry<K,V>
Parameters:
key - the registry key.
ifname - the class or interface name.

containsKey

public boolean containsKey(Object key)
Description copied from interface: Registry
Checks whether the specified key is registered in this registry.

Specified by:
containsKey in interface Registry<K,V>
Parameters:
key - the key to check.
Returns:
true if the key is registered, otherwise false.

get

public V get(Object key)
Description copied from interface: Registry
Gets the referent of the MBean in this registry.

Specified by:
get in interface Registry<K,V>
Parameters:
key - the registry key.
Returns:
the referent or null.

getMBean

public MBeanReference<V> getMBean(Object key)
Description copied from interface: Registry
Gets a reference to the MBean in this registry.

Specified by:
getMBean in interface Registry<K,V>
Parameters:
key - the registry key.
Returns:
the reference or null.

getObjectName

public ObjectName getObjectName(Object key)
Description copied from interface: Registry
Gets the object name of the MBean in this registry, which is also registered in the MBean server.

Specified by:
getObjectName in interface Registry<K,V>
Parameters:
key - the registry key.
Returns:
the name or null if not in registered.

getObjectNames

public Set<ObjectName> getObjectNames(Object key)
Description copied from interface: Registry
Gets a set of object names registered in the MBean server with names matching the query pattern of the MBean in this registry.

Specified by:
getObjectNames in interface Registry<K,V>
Parameters:
key - the registry key.
Returns:
a set of object names or an empty set.

getRegistryKey

public K getRegistryKey(String ifname)
Description copied from interface: Registry
Gets the key of an MBean of a specific class in this registry.

Specified by:
getRegistryKey in interface Registry<K,V>
Parameters:
ifname - the class or interface name.
Returns:
the registry key or null.

getRegistryKey

public K getRegistryKey(ObjectName name)
Description copied from interface: Registry
Gets the key of a named MBean in this registry.

Specified by:
getRegistryKey in interface Registry<K,V>
Parameters:
name - the object name or query pattern.
Returns:
the registry key or null.

getRegistryKey

public K getRegistryKey(String ifname,
                        ObjectName name)
Description copied from interface: Registry
Gets the key of a named MBean of a specific class in this registry.

Specified by:
getRegistryKey in interface Registry<K,V>
Parameters:
ifname - the class or interface name.
name - the object name or query pattern.
Returns:
the registry key or null.

registrySize

public int registrySize()
Description copied from interface: Registry
Gets the size of the registry.

Specified by:
registrySize in interface Registry<K,V>
Returns:
the registry size.

registryKeySet

public Set<K> registryKeySet(String ifname)
Description copied from interface: Registry
Returns a set of registered keys of MBeans of a specific class in this registry.

Specified by:
registryKeySet in interface Registry<K,V>
Parameters:
ifname - the class or interface name.
Returns:
the registry key set.

registryKeySet

public Set<K> registryKeySet(ObjectName name)
Description copied from interface: Registry
Returns a set of registered keys a named MBean in this registry.

Specified by:
registryKeySet in interface Registry<K,V>
Parameters:
name - the object name or query pattern.
Returns:
the registry key set.

registryKeySet

public Set<K> registryKeySet(String ifname,
                             ObjectName name)
Description copied from interface: Registry
Returns a set of registered keys of a named MBean of a specific class in this registry.

Specified by:
registryKeySet in interface Registry<K,V>
Parameters:
ifname - the class or interface name.
name - the object name or query pattern.
Returns:
the registry key set.

registryKeySet

public Set<K> registryKeySet()
Description copied from interface: Registry
Returns a read-only set of all registered keys.

Specified by:
registryKeySet in interface Registry<K,V>
Returns:
a key set.

remove

public void remove(Object key)
Description copied from interface: Registry
Removes an MBean from this registry.

Specified by:
remove in interface Registry<K,V>
Parameters:
key - the registry key.

clear

public void clear()
Description copied from interface: Registry
Clears all MBeans from this registry.

Specified by:
clear in interface Registry<K,V>

registryMap

public Map<K,ObjectName> registryMap()
Description copied from interface: Registry
Returns a map view to this registry. The map is a clone of the transient state of the registry.

Specified by:
registryMap in interface Registry<K,V>
Returns:
a map of registered object names.

addRegistryKeys

protected int addRegistryKeys(String ifname,
                              ObjectName name,
                              int limit,
                              Collection<K> result)
Adds specified registry keys into a collection.

Parameters:
ifname - the specified interface.
name - the specified object name.
limit - the limit for keys (-1 = no limit).
result - the result collection.
Returns:
the number of added keys.

getMBeanHandle

protected MBeanHandle<V> getMBeanHandle(Object key)
Gets a reference to a mapped MBean.

Note that the reference is meant for internal use only.

Parameters:
key - the key to the MBean.
Returns:
the reference or null.

getMBeanHandles

protected ConcurrentMap<K,MBeanHandle<V>> getMBeanHandles()
Gets a map of MBean references. The map is a reference to the internal registry and should be modified with caution.

Returns:
an updated map of references.


Copyright © 2004 The Norther Organization. All rights reserved.