org.norther.tammi.core.rt
Class ReferableVariableRegistry

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.norther.tammi.acorn.net.URLClassLoader
                  extended by org.norther.tammi.core.base.AbstractLoader<ReferableVariableRegistryMBean>
                      extended by org.norther.tammi.core.rt.ReferableVariableRegistry
All Implemented Interfaces:
Serializable, MBeanRegistration, NotificationBroadcaster, Loader, NamePattern, ObjectFactory<Variable>, ReferableMBean<ReferableVariableRegistryMBean>, ReferableVariableRegistryMBean, VariableRegistry

public class ReferableVariableRegistry
extends AbstractLoader<ReferableVariableRegistryMBean>
implements ReferableVariableRegistryMBean, Serializable

A default implementation of ReferableVariableRegistryMBean.

Version:
$Id: ReferableVariableRegistry.java,v 1.25 2009/09/28 17:56:48 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.norther.tammi.core.base.ReferableMBean
ID, MBEAN, NS, TYPE
 
Constructor Summary
ReferableVariableRegistry()
          Constructs a new loader.
ReferableVariableRegistry(ClassLoader parent)
          Constructs a new loader with a parent.
 
Method Summary
 void clearAllTypes()
          Clears registered attributes of all variable types.
 Introspector createIntrospector()
          Creates a variable introspector for this registry.
 Variable createVariable(String type)
          Creates a new variable instance of the specified type.
 Class<?> defineVariableClass(String className, Class<?>... ifaces)
          Defines a new variable of the named class.
 Class<?> defineVariableClass(String className, Class<?> superClass, Class<?>... ifaces)
          Defines a new variable of the named class extending the specified super class.
 Collection<? extends VariableAttributeInfo> getAttributeInfo(String type)
          Gets the registered attributes of the specified variable type.
 VariableAttributeInfo getAttributeInfo(String type, String name)
          Gets the registered named attribute of the specified variable type.
 List<VariableAttributeInfo> getAttributeList(String type)
          Gets the registered attribute list of cloned and modifiable attributes of the specified variable type.
 VariableAttributeInfo getAttributeNode(VariableAttributeInfo info, String... pattern)
          Gets a non-recursive attribute info node.
 List<VariableAttributeInfo> getAttributeTree(VariableAttributeInfo info, String... pattern)
          Gets a tree of recursive attribute infos, the original one at the index 0 and the non-recursive one at the last index.
 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.
 Variable getInstance(String className)
          Gets an instance of a named class.
 Variable getInstance(String className, Object[] params, String[] signature)
          Gets an instance of a named class.
 Variable getInstance(String className, ObjectName loader)
          Gets an instance of a named class using a specified class loader.
 Variable getInstance(String className, ObjectName loader, Object[] params, String[] signature)
          Gets an instance of a named class using a specified class loader.
protected  MBeanServer getMBeanServer()
          Gets the MBean server.
 VariableInfo getVariableInfo(String type)
          Gets the registered variable info of the specified variable type.
 boolean isLoaderSupported(String className)
          Checks if specified class loaders are supported for a named class.
 boolean isLocalizedVariables()
          Checks whether variables in this registry are localized.
 boolean isTypeRegistered(String type)
          Checks whether the specified variable type is registered.
 void postDeregister()
           
 void postRegister(Boolean done)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
 void removeAttributeInfo(String type)
          Removes registered attributes of the specified variable type.
 void setAttributeInfo(String className)
          Sets the registered attributes of the named variable class.
 void setAttributeInfo(String type, Collection<? extends VariableAttributeInfo> attributes)
          Sets the registered attributes of the specified variable type.
 void setAttributeInfo(String type, Collection<? extends VariableAttributeInfo> attributes, Descriptor descriptor)
          Sets the registered attributes and descriptor of the specified variable type.
 void setAttributeInfo(String type, String className, Collection<? extends VariableAttributeInfo> attributes)
          Sets the registered attributes and class name of the specified variable type.
 void setAttributeInfo(String type, String className, Collection<? extends VariableAttributeInfo> attributes, Descriptor descriptor)
          Sets the registered attributes, class name and descriptor of the specified variable type.
 void setAttributeInfo(String type, String className, String description, Collection<? extends VariableAttributeInfo> attributes)
          Sets the registered attributes, class name and description of the specified variable type.
 void setAttributeInfo(String type, String className, String description, Collection<? extends VariableAttributeInfo> attributes, Descriptor descriptor)
          Sets the registered attributes, class name, description and descriptor 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 setLocalizedVariables(boolean flag)
          Sets whether variables in this registry are localized.
 void setVariableInfo(String type, VariableInfo info)
          Sets the registered variable info of the specified variable type.
 Set<String> typeSet()
          Returns a read-only set of registered variable types.
 Set<String> typeSet(String prefix)
          Returns a set of registered variable types with the given prefix.
 
Methods inherited from class org.norther.tammi.core.base.AbstractLoader
addNotificationListener, addURL, getMBean, getMBeanDelegate, getNamePattern, getNotificationInfo, getQueryPattern, isClassDefined, removeNotificationListener, setNamePattern, setQueryPattern
 
Methods inherited from class org.norther.tammi.acorn.net.URLClassLoader
defineClass, defineSubclass, defineSubclass
 
Methods inherited from class java.net.URLClassLoader
definePackage, findClass, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
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.Loader
addURL, defineClass, defineSubclass, defineSubclass, getResource, getResourceAsStream, getResources, getURLs, isClassDefined, loadClass
 
Methods inherited from interface org.norther.tammi.core.base.ReferableMBean
getMBean
 

Constructor Detail

ReferableVariableRegistry

public ReferableVariableRegistry()
Constructs a new loader.


ReferableVariableRegistry

public ReferableVariableRegistry(ClassLoader parent)
Constructs a new loader with a parent.

Parameters:
parent - the parent class loader.
Method Detail

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Overrides:
preRegister in class AbstractLoader<ReferableVariableRegistryMBean>
Throws:
Exception

postRegister

public void postRegister(Boolean done)
Specified by:
postRegister in interface MBeanRegistration
Overrides:
postRegister in class AbstractLoader<ReferableVariableRegistryMBean>

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Overrides:
preDeregister in class AbstractLoader<ReferableVariableRegistryMBean>
Throws:
Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration
Overrides:
postDeregister in class AbstractLoader<ReferableVariableRegistryMBean>

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<VariableAttributeInfo> getAttributeList(String type)
Description copied from interface: VariableRegistry
Gets the registered attribute list of cloned and modifiable 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 VariableAttributeInfo instances or null.

getVariableInfo

public VariableInfo getVariableInfo(String type)
Description copied from interface: VariableRegistry
Gets the registered variable info of the specified variable type.

Specified by:
getVariableInfo in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
an immutable variable info or null.

setVariableInfo

public void setVariableInfo(String type,
                            VariableInfo info)
Description copied from interface: VariableRegistry
Sets the registered variable info of the specified variable type.

Specified by:
setVariableInfo in interface VariableRegistry
Parameters:
type - the variable type.
info - the variable info or null.

getAttributeInfo

public VariableAttributeInfo getAttributeInfo(String type,
                                              String name)
Description copied from interface: VariableRegistry
Gets the registered named attribute of the specified variable type.

Specified by:
getAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
name - the attribute name.
Returns:
an immutable VariableAttributeInfo instance or null.

getAttributeInfo

public Collection<? extends VariableAttributeInfo> getAttributeInfo(String type)
Description copied from interface: VariableRegistry
Gets the registered attributes of the specified variable type.

Specified by:
getAttributeInfo in interface VariableRegistry
Parameters:
type - the variable type.
Returns:
an immutable collection of VariableAttributeInfo instances or null.

setAttributeInfo

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

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

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             Collection<? extends VariableAttributeInfo> attributes)
Description copied from interface: VariableRegistry
Sets the registered attributes and class name of the specified variable type.

The variable class has to implement the Variable interface

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

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

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             String description,
                             Collection<? extends VariableAttributeInfo> attributes)
Description copied from interface: VariableRegistry
Sets the registered attributes, class name and description of the specified variable type.

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

setAttributeInfo

public void setAttributeInfo(String type,
                             Collection<? extends VariableAttributeInfo> attributes,
                             Descriptor descriptor)
Description copied from interface: VariableRegistry
Sets the registered attributes and descriptor of the specified variable type.

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

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             Collection<? extends VariableAttributeInfo> attributes,
                             Descriptor descriptor)
Description copied from interface: VariableRegistry
Sets the registered attributes, class name and descriptor of the specified variable type.

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

setAttributeInfo

public void setAttributeInfo(String type,
                             String className,
                             String description,
                             Collection<? extends VariableAttributeInfo> attributes,
                             Descriptor descriptor)
Description copied from interface: VariableRegistry
Sets the registered attributes, class name, description and descriptor of the specified variable type.

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

setAttributeInfo

public void setAttributeInfo(String className)
Description copied from interface: VariableRegistry
Sets the registered attributes of the named variable class.

Specified by:
setAttributeInfo in interface VariableRegistry
Parameters:
className - the class name.

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<String> 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<String> 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,
                                    Class<?>... ifaces)
                             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.
ifaces - optional interfaces.
Returns:
the defined class.
Throws:
ClassNotFoundException - for missing classes.
ClassFormatError - if the class hierarchy is invalid.

defineVariableClass

public Class<?> defineVariableClass(String className,
                                    Class<?> superClass,
                                    Class<?>... ifaces)
                             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.
ifaces - optional interfaces.
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.

createIntrospector

public Introspector createIntrospector()
Description copied from interface: VariableRegistry
Creates a variable introspector for this registry.

Specified by:
createIntrospector in interface VariableRegistry
Returns:
the variable introspector.

getAttributeNode

public VariableAttributeInfo getAttributeNode(VariableAttributeInfo info,
                                              String... pattern)
Description copied from interface: VariableRegistry
Gets a non-recursive attribute info node.

Specified by:
getAttributeNode in interface VariableRegistry
Parameters:
info - the recursive attribute info.
pattern - an optional pattern.
Returns:
the non-recursive attribute info.

getAttributeTree

public List<VariableAttributeInfo> getAttributeTree(VariableAttributeInfo info,
                                                    String... pattern)
Description copied from interface: VariableRegistry
Gets a tree of recursive attribute infos, the original one at the index 0 and the non-recursive one at the last index.

Specified by:
getAttributeTree in interface VariableRegistry
Parameters:
info - the recursive attribute info.
pattern - an optional pattern.
Returns:
a tree of attribute infos.

getInstance

public Variable getInstance(String className)
                     throws ConstructionException
Description copied from interface: ObjectFactory
Gets an instance of a named class.

Specified by:
getInstance in interface ObjectFactory<Variable>
Parameters:
className - the name of the class.
Returns:
the instance.
Throws:
ConstructionException - if construction fails.

getInstance

public Variable getInstance(String className,
                            ObjectName loader)
                     throws ConstructionException
Description copied from interface: ObjectFactory
Gets an instance of a named class using a specified class loader.

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

Specified by:
getInstance in interface ObjectFactory<Variable>
Parameters:
className - the name of the class.
loader - the class loader.
Returns:
the instance.
Throws:
ConstructionException - if construction fails.

getInstance

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

Specified by:
getInstance in interface ObjectFactory<Variable>
Parameters:
className - the name of the class.
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.

getInstance

public Variable 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<Variable>
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.

isLoaderSupported

public boolean isLoaderSupported(String className)
Description copied from interface: ObjectFactory
Checks if specified class loaders are supported for a named class.

Specified by:
isLoaderSupported in interface ObjectFactory<Variable>
Parameters:
className - the name of the class.
Returns:
true if class loaders are supported, false otherwise.

getMBeanServer

protected MBeanServer getMBeanServer()
Gets the MBean server.

Returns:
the MBean server.


Copyright © 2004 The Norther Organization. All rights reserved.