org.norther.tammi.core.base
Class Referable

java.lang.Object
  extended by org.norther.tammi.core.base.Referable
All Implemented Interfaces:
Serializable, MBeanRegistration, NotificationBroadcaster, NotificationEmitter, Identifiable, MBeanDelegate, NamePattern, ReferableMBean
Direct Known Subclasses:
Chapter, Relation

public class Referable
extends Object
implements ReferableMBean, MBeanDelegate, NamePattern, Identifiable, MBeanRegistration, NotificationEmitter, Serializable

This is the default implementation and base class of referable MBeans maintaining their registration state and supporting direct references.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
static int ID_LENGTH
          The id length.
static ModelMBeanAttributeInfo[] REFERABLE_ATTRIBUTES
          Referable attributes.
static String REFERABLE_NOTIF_DESCRIPTION
          The notification description.
static ModelMBeanNotificationInfo[] REFERABLE_NOTIFICATIONS
          Referable notifications.
 
Fields inherited from interface org.norther.tammi.core.base.ReferableMBean
DEFAULT_ID, ID, MBEAN, MBEAN_DESCRIPTION, TYPE
 
Fields inherited from interface org.norther.tammi.core.base.MBeanDelegate
ARRAY_TYPE, OBJECT_TYPE, PRIMITIVE_TYPE, STRING_TYPE
 
Constructor Summary
Referable()
          Constructs a new referable MBean.
Referable(ReferableMBean adaptee)
          Constructs a new referable adapter.
 
Method Summary
 void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
           
 AttributeSupport getAttributeSupport()
          Gets the attribute support.
 Broker getBroker()
          Gets the referent of the broker MBean.
 String getCanonicalName()
          Gets the canonical object name of the MBean as a string.
 Domain getDomain()
          Gets the referent of the domain MBean.
 Factory getFactory()
          Gets the referent of the factory MBean.
 LoaderMBean getLoader()
          Gets the referent of the loader MBean.
 Log getLog()
          Gets an anonymous log.
 Log getLog(Object object)
          Gets an object specific log.
 MBeanReference getMBean()
          Gets a reference to the adapter MBean.
 MBeanServer getMBeanServer()
          Gets the MBean server.
 String getNamePattern()
          Gets the name pattern as a string.
 MBeanNotificationInfo[] getNotificationInfo()
           
 ObjectName getObjectName()
          Gets the object name.
 ObjectName getQueryPattern()
          Gets the name pattern as an object name query.
 long getRegistrationTime()
          Gets the registration time.
 long getSequenceNumber()
          Gets the notification sequence number.
protected  ObjectName getUniqueName(MBeanServer server)
          Gets a unique object name within the specified server.
 boolean hasListeners()
          Checks whether there are registered notification listeners.
protected  boolean isUnregistered()
          Checks whether this MBean is unregistered.
 void postDeregister()
          Allows the MBean to perform any operations needed after having been de-registered in the MBean server.
 void postRegister(Boolean done)
          Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
 void preDeregister()
          Allows the MBean to perform any operations it needs before being de-registered by the MBean server.
 ObjectName preRegister(MBeanServer server, ObjectName name)
          Allows the MBean to perform any operations it needs before being registered in the MBean server.
 void removeNotificationListener(NotificationListener listener)
           
 void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
           
 void sendNotification(Notification notif)
          Sends the specified notification.
 void sendNotification(String message)
          Sends a generic notification.
 void sendNotification(String message, Object data)
          Sends a generic notification with data.
 void sendNotification(String message, String name, String type, Object oldValue, Object newValue)
          Sends a modification notification with values for object attributes.
 void setCanonicalName(String name)
          Sets the canonical object name of the MBean as a string.
 void setMBeanServer(MBeanServer server)
          Sets the MBean server.
 void setNamePattern(String pattern)
          Sets the name pattern as a string.
 void setObjectName(ObjectName name)
          Sets the object name.
 void setQueryPattern(ObjectName pattern)
          Sets the name pattern as an object name query.
 void unregister()
          Unregisters this MBean if it is still registered.
protected  void unregistered()
          Marks this MBean as potentially unregistered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REFERABLE_NOTIF_DESCRIPTION

public static final String REFERABLE_NOTIF_DESCRIPTION
The notification description.

See Also:
Constant Field Values

REFERABLE_NOTIFICATIONS

public static final ModelMBeanNotificationInfo[] REFERABLE_NOTIFICATIONS
Referable notifications.


REFERABLE_ATTRIBUTES

public static final ModelMBeanAttributeInfo[] REFERABLE_ATTRIBUTES
Referable attributes.


ID_LENGTH

public static final int ID_LENGTH
The id length.

See Also:
Constant Field Values
Constructor Detail

Referable

public Referable()
Constructs a new referable MBean.


Referable

public Referable(ReferableMBean adaptee)
Constructs a new referable adapter.

Parameters:
adaptee - the adaptee MBean.
Method Detail

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Allows the MBean to perform any operations it needs before being registered in the MBean server. The referable MBean provides a default name, if the name of the MBean is not specified. It also sends a registration notification for any client MBeans. If any exception is raised, the MBean will not be registered in the MBean server. Any subclasses must redirect their preRegister method to super MBean.

Specified by:
preRegister in interface MBeanRegistration
Parameters:
server - the MBean server in which the MBean will be registered.
name - the object name of the MBean (may be null).
Returns:
the name of the registered MBean.
Throws:
Exception - for errors.

postRegister

public void postRegister(Boolean done)
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.

Specified by:
postRegister in interface MBeanRegistration
Parameters:
done - indicates whether or not the MBean has been registered.

preDeregister

public void preDeregister()
                   throws Exception
Allows the MBean to perform any operations it needs before being de-registered by the MBean server. The configurable MBean sends an unregistration notifitation for any referencing MBeans.

Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception - on errors.

postDeregister

public void postDeregister()
Allows the MBean to perform any operations needed after having been de-registered in the MBean server.

Specified by:
postDeregister in interface MBeanRegistration

getMBean

public MBeanReference getMBean()
Description copied from interface: MBeanDelegate
Gets a reference to the adapter MBean.

Specified by:
getMBean in interface MBeanDelegate
Specified by:
getMBean in interface ReferableMBean
Returns:
a reference to the adapter MBean.

getDomain

public Domain getDomain()
Description copied from interface: MBeanDelegate
Gets the referent of the domain MBean.

Specified by:
getDomain in interface MBeanDelegate
Returns:
the domain MBean referent.

getLoader

public LoaderMBean getLoader()
Description copied from interface: MBeanDelegate
Gets the referent of the loader MBean.

Specified by:
getLoader in interface MBeanDelegate
Returns:
the loader MBean referent.

getBroker

public Broker getBroker()
Description copied from interface: MBeanDelegate
Gets the referent of the broker MBean.

Specified by:
getBroker in interface MBeanDelegate
Returns:
the broker MBean referent.

getFactory

public Factory getFactory()
Description copied from interface: MBeanDelegate
Gets the referent of the factory MBean.

Specified by:
getFactory in interface MBeanDelegate
Returns:
the factory MBean referent.

getLog

public Log getLog(Object object)
Description copied from interface: MBeanDelegate
Gets an object specific log.

Specified by:
getLog in interface MBeanDelegate
Parameters:
object - the object.
Returns:
an object specific log.

getLog

public Log getLog()
Description copied from interface: MBeanDelegate
Gets an anonymous log.

Specified by:
getLog in interface MBeanDelegate
Returns:
an anonymous log.

getRegistrationTime

public long getRegistrationTime()
Description copied from interface: MBeanDelegate
Gets the registration time.

Specified by:
getRegistrationTime in interface MBeanDelegate
Returns:
the registration time in msecs.

unregister

public void unregister()
Description copied from interface: MBeanDelegate
Unregisters this MBean if it is still registered.

Specified by:
unregister in interface MBeanDelegate

getSequenceNumber

public long getSequenceNumber()
Description copied from interface: MBeanDelegate
Gets the notification sequence number.

Specified by:
getSequenceNumber in interface MBeanDelegate
Returns:
the sequence number.

sendNotification

public void sendNotification(Notification notif)
Description copied from interface: MBeanDelegate
Sends the specified notification.

Specified by:
sendNotification in interface MBeanDelegate
Parameters:
notif - the notification to send.

sendNotification

public void sendNotification(String message)
Description copied from interface: MBeanDelegate
Sends a generic notification.

Specified by:
sendNotification in interface MBeanDelegate
Parameters:
message - the notification message.

sendNotification

public void sendNotification(String message,
                             Object data)
Description copied from interface: MBeanDelegate
Sends a generic notification with data.

Specified by:
sendNotification in interface MBeanDelegate
Parameters:
message - the notification message.
data - a user data object of any type.

sendNotification

public void sendNotification(String message,
                             String name,
                             String type,
                             Object oldValue,
                             Object newValue)
Description copied from interface: MBeanDelegate
Sends a modification notification with values for object attributes.

Not that values may be nulls when applicable, e.g. for complicated attributes and primitives. Null type is replaced with java.lang.Object.

Specified by:
sendNotification in interface MBeanDelegate
Parameters:
message - the notification message.
name - the attribute name.
type - the attribute type.
oldValue - the old value.
newValue - the new value.

hasListeners

public boolean hasListeners()
Description copied from interface: MBeanDelegate
Checks whether there are registered notification listeners.

Specified by:
hasListeners in interface MBeanDelegate
Returns:
true if notications can be send, otherwise false.

getCanonicalName

public String getCanonicalName()
Description copied from interface: Identifiable
Gets the canonical object name of the MBean as a string.

Specified by:
getCanonicalName in interface Identifiable
Returns:
the canonical object name as a string or null.

setCanonicalName

public void setCanonicalName(String name)
                      throws MalformedObjectNameException
Description copied from interface: Identifiable
Sets the canonical object name of the MBean as a string. The canonical object name can be used by persistence mechanisms to store the identity of the MBean.

Specified by:
setCanonicalName in interface Identifiable
Parameters:
name - the canonical object name as a string.
Throws:
MalformedObjectNameException - for an invalid name.

getNamePattern

public String getNamePattern()
Description copied from interface: NamePattern
Gets the name pattern as a string.

Specified by:
getNamePattern in interface NamePattern
Returns:
the name pattern or null.

setNamePattern

public void setNamePattern(String pattern)
                    throws MalformedObjectNameException
Description copied from interface: NamePattern
Sets the name pattern as a string.

Specified by:
setNamePattern in interface NamePattern
Parameters:
pattern - the name pattern.
Throws:
MalformedObjectNameException - for an invalid name.

getQueryPattern

public ObjectName getQueryPattern()
Description copied from interface: NamePattern
Gets the name pattern as an object name query.

Specified by:
getQueryPattern in interface NamePattern
Returns:
the query pattern or null.

setQueryPattern

public void setQueryPattern(ObjectName pattern)
Description copied from interface: NamePattern
Sets the name pattern as an object name query. The name pattern is applied when generating a unique name during registration of an unnamed MBean.

Specified by:
setQueryPattern in interface NamePattern
Parameters:
pattern - the query pattern.

addNotificationListener

public void addNotificationListener(NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
Specified by:
addNotificationListener in interface NotificationBroadcaster

removeNotificationListener

public void removeNotificationListener(NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws ListenerNotFoundException
Specified by:
removeNotificationListener in interface NotificationEmitter
Throws:
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(NotificationListener listener)
                                throws ListenerNotFoundException
Specified by:
removeNotificationListener in interface NotificationBroadcaster
Throws:
ListenerNotFoundException

getNotificationInfo

public MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface NotificationBroadcaster

getObjectName

public ObjectName getObjectName()
Gets the object name.

Returns:
the object name.

setObjectName

public void setObjectName(ObjectName name)
Sets the object name.

Parameters:
name - the object name.
Throws:
IllegalStateException - if already registered.

getMBeanServer

public MBeanServer getMBeanServer()
Gets the MBean server.

Returns:
the MBean server.

setMBeanServer

public void setMBeanServer(MBeanServer server)
Sets the MBean server.

Parameters:
server - the MBean server.
Throws:
IllegalStateException - if already registered.

getAttributeSupport

public AttributeSupport getAttributeSupport()
Gets the attribute support.

Returns:
the attribute support.

unregistered

protected void unregistered()
Marks this MBean as potentially unregistered.


isUnregistered

protected boolean isUnregistered()
Checks whether this MBean is unregistered.

Returns:
true if unregistered, otherwise false.

getUniqueName

protected ObjectName getUniqueName(MBeanServer server)
                            throws MalformedObjectNameException
Gets a unique object name within the specified server.

Parameters:
server - the MBean server.
Returns:
the default object name.
Throws:
MalformedObjectNameException - on errors.


Copyright © 2004 The Norther Organization. All rights reserved.