org.norther.tammi.core.rt
Class DefaultVariableRegistry

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultObjectFactory
          extended by org.norther.tammi.core.rt.DefaultVariableRegistry
All Implemented Interfaces:
Serializable, NotificationBroadcaster, NotificationEmitter, Manageable, MBeanDelegate, ObjectFactory, VariableRegistry

public class DefaultVariableRegistry
extends DefaultObjectFactory
implements VariableRegistry

A default implementation of VariableRegistry.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultVariableRegistry()
          Constructs a new registry.
 
Method Summary
 void clearAllTypes()
          Clears registered attributes of all variable types.
 Variable createVariable(String type)
          Creates a new variable instance of the specified type.
 Class defineVariableClass(String className)
          Defines a new variable of the named class.
 Class defineVariableClass(String className, Class superClass)
          Defines a new variable of the named class extending the specified super class.
 Class defineVariableClass(String className, String superName)
          Defines a new variable of the named class extending the named super class.
 AttributeExporter getAttributeExporter(String type)
          Gets the registered exporter of the specified variable type.
 AttributeImporter getAttributeImporter(String type)
          Gets the registered importer of the specified variable type.
 Collection getAttributeInfo(String type)
          Gets a registered attribute collection of locked attributes of the specified variable type.
 List getAttributeList(String type)
          Gets a registered attribute list of cloned and unlocked attributes of the specified variable type.
 OrderedMap getAttributeMap(String type)
          Gets a registered attribute map of locked attributes of the specified variable type.
 AttributeValidator getAttributeValidator(String type)
          Gets the registered validator of the specified variable type.
 String getDefaultBaseClassName()
          Gets the default base class name applied to defined variable classes.
 String getDefaultVariableClassName()
          Gets the default variable class name applied to virtual variable types.
 String getExporterClassName(String type)
          Gets the exporter class name of the specified variable type.
 String getImporterClassName(String type)
          Gets the importer class name of the specified variable type.
 Object getInstance(String className, ObjectName loader, Object[] params, String[] signature)
          Gets an instance of a named class using a specified class loader.
 ObjectName getNamePattern(String type)
          Gets the name pattern of the specified variable type.
 String getValidatorClassName(String type)
          Gets the validator class name of the specified variable type.
 String getVariableClassName(String type)
          Gets the variable class name of the specified variable type.
 boolean isLocalizedVariables()
          Checks whether variables in this registry are localized.
 boolean isTypeRegistered(String type)
          Checks whether the specified variable type is registered.
 void removeAttributeInfo(String type)
          Removes registered attributes of the specified variable type.
 void setAttributeExporter(String type, AttributeExporter exporter)
          Sets the registered exporter of the specified variable type.
 void setAttributeImporter(String type, AttributeImporter importer)
          Sets the registered importer of the specified variable type.
 void setAttributeInfo(String type, Collection attributes)
          Sets registered attributes of the specified variable type.
 void setAttributeInfo(String type, Collection attributes, String validatorClassName)
          Sets registered attributes and a validator class for the specified variable type.
 void setAttributeInfo(String type, String className, Collection attributes)
          Sets registered attributes and a variable class for the specified variable type.
 void setAttributeInfo(String type, String className, Collection attributes, String validatorClassName)
          Sets registered attributes, a variable class and a validator class for the specified variable type.
 void setAttributeInfo(String type, String className, Collection attributes, String validatorClassName, ObjectName pattern)
          Sets registered attributes, a variable class, a validator class and an optional object name pattern for the specified variable type.
 void setAttributeInfo(String type, String className, String importerClassName, String exporterClassName, Collection attributes, String validatorClassName, ObjectName pattern)
          Sets registered attributes, a variable class, an importer class, an exporter class, a validator class and an optional object name pattern for the specified variable type.
 void setAttributeValidator(String type, AttributeValidator validator)
          Sets the registered validator of the specified variable type.
 void setDefaultBaseClassName(String className)
          Sets the default base class name applied to defined variable classes.
 void setDefaultVariableClassName(String className)
          Sets the default variable class name applied to virtual variable types.
 void setExporterClassName(String type, String className)
          Sets the exporter class name of the specified variable type.
 void setImporterClassName(String type, String className)
          Sets the importer class name of the specified variable type.
 void setLocalizedVariables(boolean flag)
          Sets whether variables in this registry are localized.
 void setNamePattern(String type, ObjectName pattern)
          Sets the name pattern of the specified variable type.
 void setValidatorClassName(String type, String className)
          Sets the validator class name of the specified variable type.
 void setVariableClassName(String type, String className)
          Sets the variable class name of the specified variable type.
 Set typeSet()
          Returns a read-only set of registered variable types.
 Set typeSet(String prefix)
          Returns a set of registered variable types with the given prefix.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.core.base.DefaultObjectFactory
getInstance, getInstance, getInstance, isLoaderSupported
 
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, unregister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.base.ObjectFactory
getInstance, getInstance, getInstance, isLoaderSupported
 

Constructor Detail

DefaultVariableRegistry

public DefaultVariableRegistry()
Constructs a new registry.

Method Detail

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Overrides:
unmanaged in class Adaptee
Throws:
Exception - if the adaptee refused to be unmanaged.

getDefaultBaseClassName

public String getDefaultBaseClassName()
Description copied from interface: VariableRegistry
Gets the default base class name applied to defined variable classes.

Specified by:
getDefaultBaseClassName in interface VariableRegistry
Returns:
the default base class name.

setDefaultBaseClassName

public void setDefaultBaseClassName(String className)
Description copied from interface: VariableRegistry
Sets the default base class name applied to defined variable classes.

Specified by:
setDefaultBaseClassName in interface VariableRegistry
Parameters:
className - the default base class name.

getDefaultVariableClassName

public String getDefaultVariableClassName()
Description copied from interface: VariableRegistry
Gets the default variable class name applied to virtual variable types.

Specified by:
getDefaultVariableClassName in interface VariableRegistry
Returns:
the default variable class name.

setDefaultVariableClassName

public void setDefaultVariableClassName(String className)
Description copied from interface: VariableRegistry
Sets the default variable class name applied to virtual variable types.

Specified by:
setDefaultVariableClassName in interface VariableRegistry
Parameters:
className - the default variable class name.

isLocalizedVariables

public boolean isLocalizedVariables()
Description copied from interface: VariableRegistry
Checks whether variables in this registry are localized.

Specified by:
isLocalizedVariables in interface VariableRegistry
Returns:
true if localized, otherwise false.

setLocalizedVariables

public void setLocalizedVariables(boolean flag)
Description copied from interface: VariableRegistry
Sets whether variables in this registry are localized.

Specified by:
setLocalizedVariables in interface VariableRegistry
Parameters:
flag - true if localized, otherwise false.

isTypeRegistered

public boolean isTypeRegistered(String type)
Description copied from interface: VariableRegistry
Checks whether the specified variable type is registered.

Specified by:
isTypeRegistered in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
true if the type is registered, otherwise false.

getAttributeList

public List getAttributeList(String type)
Description copied from interface: VariableRegistry
Gets a registered attribute list of cloned and unlocked attributes of the specified variable type. Both the list and the attributes may be modified and re-registered after modifications.

Specified by:
getAttributeList in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
a list of MBeanAttributeInfo instances or null.

getAttributeMap

public OrderedMap getAttributeMap(String type)
Description copied from interface: VariableRegistry
Gets a registered attribute map of locked attributes of the specified variable type.

Specified by:
getAttributeMap in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
a read-only map of MBeanAttributeInfo instances or null.

getAttributeInfo

public Collection getAttributeInfo(String type)
Description copied from interface: VariableRegistry
Gets a registered attribute collection of locked attributes of the specified variable type.

Specified by:
getAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
a read-only collection of MBeanAttributeInfo instances or null.

setAttributeInfo

public void setAttributeInfo(String type,
                             Collection attributes)
Description copied from interface: VariableRegistry
Sets registered attributes of the specified variable type.

Specified by:
setAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
attributes - a collection of MBeanAttributeInfo instances.

getVariableClassName

public String getVariableClassName(String type)
Description copied from interface: VariableRegistry
Gets the variable class name of the specified variable type.

Specified by:
getVariableClassName in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the variable class name or null.

setVariableClassName

public void setVariableClassName(String type,
                                 String className)
Description copied from interface: VariableRegistry
Sets the variable class name of the specified variable type.

The variable class has to implement the Variable interface and provide a constructor with three parameters. The first one for the MBean server of type javax.management.MBeanServer, the second one for the object name of the variable registry of type javax.management.ObjectName and the third one for the variable type of type java.lang.String.

If the named variable class is not available, it will be dynamically defined to be a subclass of VariableX.

Specified by:
setVariableClassName in interface VariableRegistry
Parameters:
type - the variable type.
className - the variable class name or null.

getImporterClassName

public String getImporterClassName(String type)
Description copied from interface: VariableRegistry
Gets the importer class name of the specified variable type.

Specified by:
getImporterClassName in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the importer class name or null.

setImporterClassName

public void setImporterClassName(String type,
                                 String className)
Description copied from interface: VariableRegistry
Sets the importer class name of the specified variable type.

The importer class has to implement the AttributeImporter interface.

Specified by:
setImporterClassName in interface VariableRegistry
Parameters:
type - the variable type.
className - the importer class name or null.

getAttributeImporter

public AttributeImporter getAttributeImporter(String type)
Description copied from interface: VariableRegistry
Gets the registered importer of the specified variable type.

Specified by:
getAttributeImporter in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the importer or null.

setAttributeImporter

public void setAttributeImporter(String type,
                                 AttributeImporter importer)
Description copied from interface: VariableRegistry
Sets the registered importer of the specified variable type.

Specified by:
setAttributeImporter in interface VariableRegistry
Parameters:
type - the variable type.
importer - the importer or null.

getExporterClassName

public String getExporterClassName(String type)
Description copied from interface: VariableRegistry
Gets the exporter class name of the specified variable type.

Specified by:
getExporterClassName in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the exporter class name or null.

setExporterClassName

public void setExporterClassName(String type,
                                 String className)
Description copied from interface: VariableRegistry
Sets the exporter class name of the specified variable type.

The exporter class has to implement the AttributeExporter interface.

Specified by:
setExporterClassName in interface VariableRegistry
Parameters:
type - the variable type.
className - the exporter class name or null.

getAttributeExporter

public AttributeExporter getAttributeExporter(String type)
Description copied from interface: VariableRegistry
Gets the registered exporter of the specified variable type.

Specified by:
getAttributeExporter in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the exporter or null.

setAttributeExporter

public void setAttributeExporter(String type,
                                 AttributeExporter exporter)
Description copied from interface: VariableRegistry
Sets the registered exporter of the specified variable type.

Specified by:
setAttributeExporter in interface VariableRegistry
Parameters:
type - the variable type.
exporter - the exporter or null.

getValidatorClassName

public String getValidatorClassName(String type)
Description copied from interface: VariableRegistry
Gets the validator class name of the specified variable type.

Specified by:
getValidatorClassName in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the validator class name or null.

setValidatorClassName

public void setValidatorClassName(String type,
                                  String className)
Description copied from interface: VariableRegistry
Sets the validator class name of the specified variable type.

The validator class has to implement the AttributeValidator interface.

Specified by:
setValidatorClassName in interface VariableRegistry
Parameters:
type - the variable type.
className - the validator class name or null.

getAttributeValidator

public AttributeValidator getAttributeValidator(String type)
Description copied from interface: VariableRegistry
Gets the registered validator of the specified variable type.

Specified by:
getAttributeValidator in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the validator or null.

setAttributeValidator

public void setAttributeValidator(String type,
                                  AttributeValidator validator)
Description copied from interface: VariableRegistry
Sets the registered validator of the specified variable type.

Specified by:
setAttributeValidator in interface VariableRegistry
Parameters:
type - the variable type.
validator - the validator or null.

getNamePattern

public ObjectName getNamePattern(String type)
Description copied from interface: VariableRegistry
Gets the name pattern of the specified variable type.

Specified by:
getNamePattern in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
the name pattern or null.

setNamePattern

public void setNamePattern(String type,
                           ObjectName pattern)
Description copied from interface: VariableRegistry
Sets the name pattern of the specified variable type.

Specified by:
setNamePattern in interface VariableRegistry
Parameters:
type - the variable type.
pattern - the name pattern or null.

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             Collection attributes)
Description copied from interface: VariableRegistry
Sets registered attributes and a variable class for the specified variable type.

Specified by:
setAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
className - the variable class name.
attributes - a collection of MBeanAttributeInfo instances.

setAttributeInfo

public void setAttributeInfo(String type,
                             Collection attributes,
                             String validatorClassName)
Description copied from interface: VariableRegistry
Sets registered attributes and a validator class for the specified variable type.

Specified by:
setAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
attributes - a collection of MBeanAttributeInfo instances.
validatorClassName - the validator class name.

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             Collection attributes,
                             String validatorClassName)
Description copied from interface: VariableRegistry
Sets registered attributes, a variable class and a validator class for the specified variable type.

Specified by:
setAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
className - the variable class name.
attributes - a collection of MBeanAttributeInfo instances.
validatorClassName - the validator class name.

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             Collection attributes,
                             String validatorClassName,
                             ObjectName pattern)
Description copied from interface: VariableRegistry
Sets registered attributes, a variable class, a validator class and an optional object name pattern for the specified variable type.

Specified by:
setAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
className - the variable class name.
attributes - a collection of MBeanAttributeInfo instances.
validatorClassName - the validator class name.
pattern - an optional object name pattern.

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             String importerClassName,
                             String exporterClassName,
                             Collection attributes,
                             String validatorClassName,
                             ObjectName pattern)
Description copied from interface: VariableRegistry
Sets registered attributes, a variable class, an importer class, an exporter class, a validator class and an optional object name pattern for the specified variable type.

Specified by:
setAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
className - the variable class name.
importerClassName - the importer class name.
exporterClassName - the exporter class name.
attributes - a collection of MBeanAttributeInfo instances.
validatorClassName - the validator class name.
pattern - an optional object name pattern.

removeAttributeInfo

public void removeAttributeInfo(String type)
Description copied from interface: VariableRegistry
Removes registered attributes of the specified variable type.

Specified by:
removeAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.

clearAllTypes

public void clearAllTypes()
Description copied from interface: VariableRegistry
Clears registered attributes of all variable types.

Specified by:
clearAllTypes in interface VariableRegistry

typeSet

public Set typeSet()
Description copied from interface: VariableRegistry
Returns a read-only set of registered variable types.

Specified by:
typeSet in interface VariableRegistry
Returns:
a type set.

typeSet

public Set typeSet(String prefix)
Description copied from interface: VariableRegistry
Returns a set of registered variable types with the given prefix. Types starting with the given prefix followed by any dot separated item are included in the set. The prefix remains in the returned types.

Specified by:
typeSet in interface VariableRegistry
Parameters:
prefix - a prefix.
Returns:
a type set.

defineVariableClass

public Class defineVariableClass(String className)
                          throws ClassNotFoundException,
                                 ClassFormatError
Description copied from interface: VariableRegistry
Defines a new variable of the named class. The defined class extends the default variable implementation.

Specified by:
defineVariableClass in interface VariableRegistry
Parameters:
className - the class name of the variable.
Returns:
the defined class.
Throws:
ClassNotFoundException - for missing classes.
ClassFormatError - if the class hierarchy is invalid.

defineVariableClass

public Class defineVariableClass(String className,
                                 String superName)
                          throws ClassNotFoundException,
                                 ClassFormatError
Description copied from interface: VariableRegistry
Defines a new variable of the named class extending the named super class.

Specified by:
defineVariableClass in interface VariableRegistry
Parameters:
className - the class name of the variable.
superName - the super class name.
Returns:
the defined class.
Throws:
ClassNotFoundException - for missing classes.
ClassFormatError - if the class hierarchy is invalid.

defineVariableClass

public Class defineVariableClass(String className,
                                 Class superClass)
                          throws ClassFormatError
Description copied from interface: VariableRegistry
Defines a new variable of the named class extending the specified super class. The base class must implement the Variable interface and support the default constructor and the registry constructor with two arguments: MBeanReference registry, String type.

Specified by:
defineVariableClass in interface VariableRegistry
Parameters:
className - the class name of the variable.
superClass - the super class.
Returns:
the defined class.
Throws:
ClassFormatError - if the class hierarchy is invalid.

createVariable

public Variable createVariable(String type)
                        throws ConstructionException
Description copied from interface: VariableRegistry
Creates a new variable instance of the specified type.

Specified by:
createVariable in interface VariableRegistry
Parameters:
type - the type of the variable.
Returns:
the variable instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Object getInstance(String className,
                          ObjectName loader,
                          Object[] params,
                          String[] signature)
                   throws ConstructionException
Description copied from interface: ObjectFactory
Gets an instance of a named class using a specified class loader. Parameters for its constructor are given as an array of objects, primitive types must be wrapped with a corresponding class.

Class loaders are supported only if the isLoaderSupported method returns true. Otherwise the loader parameter is ignored.

Specified by:
getInstance in interface ObjectFactory
Overrides:
getInstance in class DefaultObjectFactory
Parameters:
className - the name of the class.
loader - the class loader.
params - an array containing the parameters of the constructor.
signature - an array containing the signature of the constructor.
Returns:
the instance.
Throws:
ConstructionException - if construction fails.


Copyright © 2004 The Norther Organization. All rights reserved.