org.norther.tammi.core.base
Class DefaultDomain

java.lang.Object
  extended by org.norther.tammi.core.base.Adaptee
      extended by org.norther.tammi.core.base.DefaultDomain
All Implemented Interfaces:
Serializable, Cloneable, NotificationBroadcaster, NotificationEmitter, Domain, Manageable, MBeanDelegate

public class DefaultDomain
extends Adaptee
implements Cloneable, Domain

A default implementation of Domain.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
protected static String MBEAN_CONST_DESCRIPTION
          The constructor description.
protected static String MBEAN_INFO_DESCRIPTION
          The adaptee description.
protected static String OBJECT_REFERENCE
          The object reference resource type.
 
Fields inherited from class org.norther.tammi.core.base.Adaptee
ADAPTEE_NOTIF_DESCRIPTION, ADAPTEE_NOTIFICATIONS
 
Fields inherited from interface org.norther.tammi.core.base.Domain
ANY_DOMAIN, HPUX, LINUX, MACOS, OS_NAME_PROPERTY, OS_TYPE_PROPERTY, SUNOS, UNKNOWN, WIN32
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
DefaultDomain()
          Constructs a new domain.
 
Method Summary
 ModelMBean adapt(Object object, String ifName)
          Adapts the specified object exposing the specified class or interface by applying the default model MBean and the domain MBean loader.
 ModelMBean adapt(Object object, String ifName, ObjectName loader)
          Adapts the specified object exposing the specified class or interface by applying the default model MBean and the named MBean loader.
 ModelMBean adapt(Object object, String ifName, ObjectName loader, MBeanServer server)
          Adapts the specified object exposing the specified class or interface by applying the named MBean loader in the given MBean server.
 ModelMBean adapt(Object object, String ifName, String modelName)
          Adapts the specified object exposing the specified class or interface by applying the specified model MBean and the domain MBean loader.
 ModelMBean adapt(Object object, String ifName, String modelName, ObjectName loader)
          Adapts the specified object exposing the specified class or interface by applying the specified model MBean and the named MBean loader.
 ModelMBean adapt(Object object, String ifName, String modelName, ObjectName loader, MBeanServer server)
          Adapts the specified object exposing the specified class or interface by applying the specified model MBean, the named MBean loader in the given MBean server.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName)
          Adapts a named MBean exposing the specified class or interface by applying the default model MBean and the domain MBean loader.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName, Object[] params, String[] signature)
          Adapts a named MBean exposing the specified class or interface with parameters by applying the default model MBean and the domain MBean loader.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName, ObjectName loader)
          Adapts a named MBean exposing the specified class or interface by applying the default model MBean and the named MBean loader.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName, ObjectName loader, Object[] params, String[] signature)
          Adapts a named MBean exposing the specified class or interface with parameters by applying the default model MBean and the named MBean loader.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName, String modelName)
          Adapts a named MBean exposing the specified class or interface by applying the specified model MBean and the domain MBean loader.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName, String modelName, Object[] params, String[] signature)
          Adapts a named MBean exposing the specified class or interface with parameters by applying the specified model MBean and the domain MBean loader.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName, String modelName, ObjectName loader)
          Adapts a named MBean exposing the specified class or interface by applying the specified model MBean and the named MBean loader.
 ObjectInstance adaptMBean(String className, ObjectName name, String ifName, String modelName, ObjectName loader, Object[] params, String[] signature)
          Adapts a named MBean exposing the specified class or interface with parameters by applying the specified model MBean and the named MBean loader.
 ObjectInstance createMBean(String className, ObjectName name)
          Creates a named MBean by applying the domain MBean loader.
 ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature)
          Creates a named MBean with parameters by applying the domain MBean loader.
 ObjectInstance createMBean(String className, ObjectName name, ObjectName loader)
          Creates a named MBean by applying the named MBean loader.
 ObjectInstance createMBean(String className, ObjectName name, ObjectName loader, Object[] params, String[] signature)
          Creates a named MBean with parameters by applying the named MBean loader.
 Broker getBroker()
          Gets the referent of the broker MBean.
 MBeanReference getBrokerMBean()
          Gets a reference to the broker MBean of this domain.
 ObjectName getBrokerName()
          Gets the broker of this domain.
 String getDefaultDomain()
          Gets the name with the default context of this domain.
 ObjectName getDefaultQuery()
          Gets a query to the default context of this domain.
 Domain getDomain()
          Gets the referent of the domain MBean.
 String getDomainName()
          Gets the name without the context of this domain.
 String[] getDomainNames()
          Gets the domain names without the contexts of this domain.
 Factory getFactory()
          Gets the referent of the factory MBean.
 MBeanReference getFactoryMBean()
          Gets a reference to the factory MBean of this domain.
 ObjectName getFactoryName()
          Gets the the factory of this domain.
 LoaderMBean getLoader()
          Gets the referent of the loader MBean.
 MBeanReference getLoaderMBean()
          Gets a reference to the loader MBean of this domain.
 ObjectName getLoaderName()
          Gets the loader of this domain.
 MBeanInfo getMBeanInfo(ObjectName name)
          Gets the MBean info the named MBean.
 String getModelMBeanClassName()
          Gets the model MBean class name.
 ObjectInstance getObjectInstance(ObjectName name)
          Gets the object instance the named MBean.
 ObjectName getObjectName(String name)
          Gets a string as an object name.
 ObjectName getObjectName(String domain, Hashtable table)
          Gets a hashtable as an object name using the specified domain.
 ObjectName getObjectName(String domain, String key, String value)
          Gets a key property as an object name using the given domain.
 String getOSName()
          Gets the OS name.
 String getOSType()
          Gets the OS type.
 String getProperty(String key)
          Gets the specified system property.
 String getProperty(String key, String def)
          Gets the specified system property with a default.
protected  void introspect(RequiredModelMBean model, Object adaptee, Class clazz)
          Instrospects the public methods of the managed class.
 boolean isInstanceOf(ObjectName name, String className)
          Checks the class of the named MBean.
 boolean isRegistered(ObjectName name)
          Checks registration of the named MBean.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 void premanaged(MBeanDelegate adapter)
          This method is called when the implementing adaptee is trying to be managed either during pre-registration of the corresponding adapter MBean or just before it is explicitly added to the adapter MBean during run-time.
 Properties properties()
          Gets the current map of system properties.
 Set queryDefaultNames()
          Queries for a set of object names of MBeans in the default context of this domain.
 Set queryDefaultNames(QueryExp exp)
          Queries for a set of object names of MBeans in the default context of this domain with a query expression.
 Set queryDefaultNames(String className)
          Queries for a set of object names of MBeans in the default context of this domain of the specified class.
 Set queryObjectNames()
          Queries for a set of object names of MBeans in any of the contexts of this domain.
 Set queryObjectNames(QueryExp exp)
          Queries for a set of object names of MBeans in any of the contexts of this domain with a query expression.
 Set queryObjectNames(String className)
          Queries for a set of object names of MBeans in any of the contexts of this domain of the specified class.
 ObjectInstance registerMBean(Object object, ObjectName name)
          Registers the named MBean.
 ObjectInstance registerMBean(Object object, ObjectName name, String ifName)
          Registers the named MBean exposing the specified class or interface by applying the default model MBean.
 ObjectInstance registerMBean(Object object, ObjectName name, String ifName, String modelName)
          Registers the named MBean exposing the specified class or interface by applying the specified model MBean.
 void setBrokerName(ObjectName broker)
          Sets the broker of this domain.
 void setFactoryName(ObjectName logger)
          Sets the factory of this domain.
 void setLoaderName(ObjectName loader)
          Sets the loader of this domain.
 void setModelMBeanClassName(String className)
          Sets the model MBean class name.
 void setProperty(String key, String value)
          Sets the specified system property.
 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.
 void unregisterMBean(ObjectName name)
          Unregisters the named MBean.
 
Methods inherited from class org.norther.tammi.core.base.Adaptee
addAdaptee, addNotificationListener, getAttributeSupport, getCanonicalName, getLog, getLog, getMBean, getMBeanServer, getNotificationInfo, getObjectName, getRegistrationTime, getSequenceNumber, hasListeners, isRegistered, 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
 

Field Detail

MBEAN_INFO_DESCRIPTION

protected static final String MBEAN_INFO_DESCRIPTION
The adaptee description.

See Also:
Constant Field Values

MBEAN_CONST_DESCRIPTION

protected static final String MBEAN_CONST_DESCRIPTION
The constructor description.

See Also:
Constant Field Values

OBJECT_REFERENCE

protected static final String OBJECT_REFERENCE
The object reference resource type.

See Also:
Constant Field Values
Constructor Detail

DefaultDomain

public DefaultDomain()
Constructs a new domain.

Method Detail

premanaged

public void premanaged(MBeanDelegate adapter)
                throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is trying to be managed either during pre-registration of the corresponding adapter MBean or just before it is explicitly added to the adapter MBean during run-time.

Specified by:
premanaged in interface Manageable
Overrides:
premanaged in class Adaptee
Parameters:
adapter - the managing adapter.
Throws:
Exception - if the adaptee refused to be managed.

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable
Overrides:
postmanaged in class Adaptee

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.

getOSType

public String getOSType()
Description copied from interface: Domain
Gets the OS type.

Specified by:
getOSType in interface Domain
Returns:
the OS type.

getOSName

public String getOSName()
Description copied from interface: Domain
Gets the OS name.

Specified by:
getOSName in interface Domain
Returns:
the OS name.

getDefaultDomain

public String getDefaultDomain()
Description copied from interface: Domain
Gets the name with the default context of this domain.

Specified by:
getDefaultDomain in interface Domain
Returns:
the default context.

getDomainName

public String getDomainName()
Description copied from interface: Domain
Gets the name without the context of this domain.

Specified by:
getDomainName in interface Domain
Returns:
the domain name.

getDomainNames

public String[] getDomainNames()
Description copied from interface: Domain
Gets the domain names without the contexts of this domain.

Specified by:
getDomainNames in interface Domain
Returns:
an array of domain names.

getDefaultQuery

public ObjectName getDefaultQuery()
Description copied from interface: Domain
Gets a query to the default context of this domain.

Specified by:
getDefaultQuery in interface Domain
Returns:
the default query.

queryDefaultNames

public Set queryDefaultNames()
Description copied from interface: Domain
Queries for a set of object names of MBeans in the default context of this domain.

Specified by:
queryDefaultNames in interface Domain
Returns:
a set of found object names or an empty set.

queryDefaultNames

public Set queryDefaultNames(QueryExp exp)
Description copied from interface: Domain
Queries for a set of object names of MBeans in the default context of this domain with a query expression.

Specified by:
queryDefaultNames in interface Domain
Parameters:
exp - an optional query expression.
Returns:
a set of found object names or an empty set.

queryDefaultNames

public Set queryDefaultNames(String className)
Description copied from interface: Domain
Queries for a set of object names of MBeans in the default context of this domain of the specified class.

Specified by:
queryDefaultNames in interface Domain
Parameters:
className - a class or interface, null for any.
Returns:
a set of found object names or an empty set.

queryObjectNames

public Set queryObjectNames()
Description copied from interface: Domain
Queries for a set of object names of MBeans in any of the contexts of this domain.

Specified by:
queryObjectNames in interface Domain
Returns:
a set of found object names or an empty set.

queryObjectNames

public Set queryObjectNames(QueryExp exp)
Description copied from interface: Domain
Queries for a set of object names of MBeans in any of the contexts of this domain with a query expression.

Specified by:
queryObjectNames in interface Domain
Parameters:
exp - an optional query expression.
Returns:
a set of found object names or an empty set.

queryObjectNames

public Set queryObjectNames(String className)
Description copied from interface: Domain
Queries for a set of object names of MBeans in any of the contexts of this domain of the specified class.

Specified by:
queryObjectNames in interface Domain
Parameters:
className - a class or interface, null for any.
Returns:
a set of found object names or an empty set.

getProperty

public String getProperty(String key)
Description copied from interface: Domain
Gets the specified system property.

Specified by:
getProperty in interface Domain
Parameters:
key - the key of the system property.
Returns:
the value of the system property or null.

getProperty

public String getProperty(String key,
                          String def)
Description copied from interface: Domain
Gets the specified system property with a default.

Specified by:
getProperty in interface Domain
Parameters:
key - the key of the system property.
def - the default value.
Returns:
the value of the system property or the default.

setProperty

public void setProperty(String key,
                        String value)
Description copied from interface: Domain
Sets the specified system property.

Specified by:
setProperty in interface Domain
Parameters:
key - the key of the system property.
value - the value of the system property.

properties

public Properties properties()
Description copied from interface: Domain
Gets the current map of system properties.

Specified by:
properties in interface Domain
Returns:
the map of system properties.

getModelMBeanClassName

public String getModelMBeanClassName()
Description copied from interface: Domain
Gets the model MBean class name.

Specified by:
getModelMBeanClassName in interface Domain
Returns:
the model MBean class name.

setModelMBeanClassName

public void setModelMBeanClassName(String className)
Description copied from interface: Domain
Sets the model MBean class name.

Specified by:
setModelMBeanClassName in interface Domain
Parameters:
className - the model MBean class name.

getMBeanInfo

public MBeanInfo getMBeanInfo(ObjectName name)
                       throws RegistrationException
Description copied from interface: Domain
Gets the MBean info the named MBean.

Specified by:
getMBeanInfo in interface Domain
Parameters:
name - the object name of the MBean.
Returns:
the MBean info.
Throws:
RegistrationException - if not registered.

getObjectInstance

public ObjectInstance getObjectInstance(ObjectName name)
                                 throws RegistrationException
Description copied from interface: Domain
Gets the object instance the named MBean.

Specified by:
getObjectInstance in interface Domain
Parameters:
name - the object name of the MBean.
Returns:
the MBean info.
Throws:
RegistrationException - if not registered.

isInstanceOf

public boolean isInstanceOf(ObjectName name,
                            String className)
                     throws RegistrationException
Description copied from interface: Domain
Checks the class of the named MBean.

Specified by:
isInstanceOf in interface Domain
Parameters:
name - the object name of the MBean.
className - the class name to check.
Returns:
true if registered, false otherwise.
Throws:
RegistrationException - if not registered.

adapt

public ModelMBean adapt(Object object,
                        String ifName)
                 throws ConstructionException,
                        AdaptationException
Description copied from interface: Domain
Adapts the specified object exposing the specified class or interface by applying the default model MBean and the domain MBean loader.

Specified by:
adapt in interface Domain
Parameters:
object - the object instance to adapt.
ifName - the exposed interface of the MBean.
Returns:
the model MBean adapter for the object.
Throws:
ConstructionException - if construction fails.
AdaptationException - if adaptation fails.

adapt

public ModelMBean adapt(Object object,
                        String ifName,
                        String modelName)
                 throws ConstructionException,
                        AdaptationException
Description copied from interface: Domain
Adapts the specified object exposing the specified class or interface by applying the specified model MBean and the domain MBean loader.

Specified by:
adapt in interface Domain
Parameters:
object - the object instance to adapt.
ifName - the exposed interface of the MBean.
modelName - the model MBean adapter to apply.
Returns:
the model MBean adapter for the object.
Throws:
ConstructionException - if construction fails.
AdaptationException - if adaptation fails.

adapt

public ModelMBean adapt(Object object,
                        String ifName,
                        ObjectName loader)
                 throws ConstructionException,
                        AdaptationException
Description copied from interface: Domain
Adapts the specified object exposing the specified class or interface by applying the default model MBean and the named MBean loader.

Specified by:
adapt in interface Domain
Parameters:
object - the object instance to adapt.
ifName - the exposed interface of the MBean.
loader - the object name of the loader.
Returns:
the model MBean adapter for the object.
Throws:
ConstructionException - if construction fails.
AdaptationException - if adaptation fails.

adapt

public ModelMBean adapt(Object object,
                        String ifName,
                        String modelName,
                        ObjectName loader)
                 throws ConstructionException,
                        AdaptationException
Description copied from interface: Domain
Adapts the specified object exposing the specified class or interface by applying the specified model MBean and the named MBean loader.

Specified by:
adapt in interface Domain
Parameters:
object - the object instance to adapt.
ifName - the exposed interface of the MBean.
modelName - the model MBean adapter to apply.
loader - the object name of the loader.
Returns:
the model MBean adapter for the object.
Throws:
ConstructionException - if construction fails.
AdaptationException - if adaptation fails.

adapt

public ModelMBean adapt(Object object,
                        String ifName,
                        ObjectName loader,
                        MBeanServer server)
                 throws ConstructionException,
                        AdaptationException
Description copied from interface: Domain
Adapts the specified object exposing the specified class or interface by applying the named MBean loader in the given MBean server.

This method can be applied to adapt objects even when the domain is not yet registered; especially the domain itself may be adapted.

Specified by:
adapt in interface Domain
Parameters:
object - the object instance to adapt.
ifName - the exposed interface of the MBean.
loader - the object name of the loader.
server - the MBean server to apply.
Returns:
the model MBean adapter for the object.
Throws:
ConstructionException - if construction fails.
AdaptationException - if adaptation fails.

adapt

public ModelMBean adapt(Object object,
                        String ifName,
                        String modelName,
                        ObjectName loader,
                        MBeanServer server)
                 throws ConstructionException,
                        AdaptationException
Description copied from interface: Domain
Adapts the specified object exposing the specified class or interface by applying the specified model MBean, the named MBean loader in the given MBean server.

This method can be applied to adapt objects even when the domain is not yet registered; especially the domain itself may be adapted.

Specified by:
adapt in interface Domain
Parameters:
object - the object instance to adapt.
ifName - the exposed interface of the MBean.
modelName - the model MBean adapter to apply.
loader - the object name of the loader.
server - the MBean server to apply.
Returns:
the model MBean adapter for the object.
Throws:
ConstructionException - if construction fails.
AdaptationException - if adaptation fails.

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name)
                           throws ConstructionException,
                                  RegistrationException
Description copied from interface: Domain
Creates a named MBean by applying the domain MBean loader.

Specified by:
createMBean in interface Domain
Parameters:
className - the class name of the MBean.
name - the object name of the MBean.
Returns:
the object instance of the MBean.
Throws:
ConstructionException - if construction fails.
RegistrationException - if registration fails.

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  Object[] params,
                                  String[] signature)
                           throws ConstructionException,
                                  RegistrationException
Description copied from interface: Domain
Creates a named MBean with parameters by applying the domain MBean loader.

Specified by:
createMBean in interface Domain
Parameters:
className - the class name of the MBean.
name - the object name of the MBean.
params - an array of parameters.
signature - the signature.
Returns:
the object instance of the MBean.
Throws:
ConstructionException - if construction fails.
RegistrationException - if registration fails.

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loader)
                           throws ConstructionException,
                                  RegistrationException
Description copied from interface: Domain
Creates a named MBean by applying the named MBean loader.

Specified by:
createMBean in interface Domain
Parameters:
className - the class name of the MBean.
name - the object name of the MBean.
loader - the object name of the loader.
Returns:
the object instance of the MBean.
Throws:
ConstructionException - if construction fails.
RegistrationException - if registration fails.

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName name,
                                  ObjectName loader,
                                  Object[] params,
                                  String[] signature)
                           throws ConstructionException,
                                  RegistrationException
Description copied from interface: Domain
Creates a named MBean with parameters by applying the named MBean loader.

Specified by:
createMBean in interface Domain
Parameters:
className - the class name of the MBean.
name - the object name of the MBean.
loader - the object name of the loader.
params - an array of parameters.
signature - the signature.
Returns:
the object instance of the MBean.
Throws:
ConstructionException - if construction fails.
RegistrationException - if registration fails.

adaptMBean

public ObjectInstance adaptMBean(String className,
                                 ObjectName name,
                                 String ifName)
                          throws ConstructionException,
                                 AdaptationException,
                                 RegistrationException
Description copied from interface: