org.logicalcobwebs.proxool.admin.jmx
Class ConnectionPoolMBean

java.lang.Object
  extended by org.logicalcobwebs.proxool.admin.jmx.ConnectionPoolMBean
All Implemented Interfaces:
javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, ConfigurationListenerIF, ProxoolListenerIF

public class ConnectionPoolMBean
extends java.lang.Object
implements javax.management.DynamicMBean, javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, ProxoolListenerIF, ConfigurationListenerIF

JMX DynamicMBean adapter for a Proxool connection pool.
See the configuration documentation to learn how to activate a pool for JMX. No programming is necessary to do this.

Attributes

Operations

Notifications

Since:
Proxool 0.8
Version:
$Revision: 1.14 $, $Date: 2003/10/20 07:37:07 $
Author:
Christian Nedregaard (christian_nedregaard@email.com), $Author: chr32 $ (current maintainer)

Field Summary
private  boolean active
           
private static java.util.ResourceBundle ATTRIBUTE_DESCRIPTIONS_RESOURCE
           
private static java.lang.String CLASS_NAME
           
private  long definitionUpdatedSequence
           
private static java.util.ResourceBundle JMX_RESOURCE
           
private static Log LOG
           
private  javax.management.MBeanInfo mBeanInfo
           
private static javax.management.MBeanNotificationInfo[] NOTIFICATION_INFOS
           
static java.lang.String NOTIFICATION_TYPE_DEFINITION_UPDATED
          Notification type emitted when the pool definition is updated.
private  javax.management.NotificationBroadcasterSupport notificationHelper
           
private static java.lang.String OPERATION_NAME_SHUTDOWN
           
private  ConnectionPoolDefinitionIF poolDefinition
           
private  java.util.Properties poolProperties
           
private static java.lang.String RECOURCE_NAME_MBEAN_NOTIFICATION_DEF_UPDATED
           
private static java.lang.String RECOURCE_NAME_MBEAN_NOTIFICATION_DESCRIPTION
           
private static java.lang.String RECOURCE_NAME_MBEAN_POOL_DESCRIPTION
           
 
Constructor Summary
ConnectionPoolMBean(java.lang.String alias, java.util.Properties poolProperties)
           
 
Method Summary
 void addNotificationListener(javax.management.NotificationListener notificationListener, javax.management.NotificationFilter notificationFilter, java.lang.Object handBack)
           
private  void checkAssignable(java.lang.String name, java.lang.Class clazz, java.lang.Object value)
           
private static java.util.ResourceBundle createAttributeDescriptionsResource()
           
private static java.util.ResourceBundle createJMXResource()
           
private static javax.management.MBeanAttributeInfo createProxoolAttribute(java.lang.String attributeName, java.lang.Class type)
           
private static javax.management.MBeanAttributeInfo createProxoolAttribute(java.lang.String attributeName, java.lang.Class type, boolean writable)
           
 void definitionUpdated(ConnectionPoolDefinitionIF connectionPoolDefinition, java.util.Properties completeInfo, java.util.Properties changedInfo)
          Update the attributes of this MBean and emit a NOTIFICATION_TYPE_DEFINITION_UPDATED event.
private  boolean equalsProperty(java.lang.String beanAttribute, java.lang.String proxoolProperty)
           
 java.lang.Object getAttribute(java.lang.String attributeName)
           
private static java.lang.String getAttributeDescription(java.lang.String attributeName)
           
 javax.management.AttributeList getAttributes(java.lang.String[] attributeNames)
           
private  java.lang.String getDelegatePropertiesAsString(java.util.Properties properties)
           
private  javax.management.MBeanInfo getDynamicMBeanInfo(java.lang.String alias)
           
private static java.lang.String getJMXText(java.lang.String key)
           
 javax.management.MBeanInfo getMBeanInfo()
           
 javax.management.MBeanNotificationInfo[] getNotificationInfo()
           
private static javax.management.MBeanNotificationInfo[] getNotificationInfos()
           
private  java.lang.String getValueOrEmpty(java.lang.String property)
           
 java.lang.Object invoke(java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)
           
private  boolean isEqualProperties(java.lang.String property1, java.lang.String property2)
           
private  boolean notEmpty(java.lang.Object object)
           
private  boolean notEmptyOrZero(java.lang.Integer integer)
           
 void onRegistration(ConnectionPoolDefinitionIF connectionPoolDefinition, java.util.Properties completeInfo)
          Not used.
 void onShutdown(java.lang.String alias)
          If the given alias equals this pools alias: Unregister this JMX bean.
 void postDeregister()
           
 void postRegister(java.lang.Boolean success)
           
 void preDeregister()
           
 javax.management.ObjectName preRegister(javax.management.MBeanServer mBeanServer, javax.management.ObjectName objectName)
           
 void removeNotificationListener(javax.management.NotificationListener notificationListener)
           
 void setAttribute(javax.management.Attribute attribute)
           
 javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
           
private  void setDelegateProperties(java.util.Properties properties, java.lang.String propertyString)
           
private  void setIntegerAttribute(java.lang.String attributeName, java.lang.String propertyName, java.lang.Object value, int defaultValue, java.util.Properties properties, javax.management.AttributeList resultList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NOTIFICATION_TYPE_DEFINITION_UPDATED

public static final java.lang.String NOTIFICATION_TYPE_DEFINITION_UPDATED
Notification type emitted when the pool definition is updated.

See Also:
Constant Field Values

LOG

private static final Log LOG

CLASS_NAME

private static final java.lang.String CLASS_NAME

RECOURCE_NAME_MBEAN_POOL_DESCRIPTION

private static final java.lang.String RECOURCE_NAME_MBEAN_POOL_DESCRIPTION
See Also:
Constant Field Values

RECOURCE_NAME_MBEAN_NOTIFICATION_DESCRIPTION

private static final java.lang.String RECOURCE_NAME_MBEAN_NOTIFICATION_DESCRIPTION
See Also:
Constant Field Values

RECOURCE_NAME_MBEAN_NOTIFICATION_DEF_UPDATED

private static final java.lang.String RECOURCE_NAME_MBEAN_NOTIFICATION_DEF_UPDATED
See Also:
Constant Field Values

OPERATION_NAME_SHUTDOWN

private static final java.lang.String OPERATION_NAME_SHUTDOWN
See Also:
Constant Field Values

ATTRIBUTE_DESCRIPTIONS_RESOURCE

private static final java.util.ResourceBundle ATTRIBUTE_DESCRIPTIONS_RESOURCE

JMX_RESOURCE

private static final java.util.ResourceBundle JMX_RESOURCE

NOTIFICATION_INFOS

private static final javax.management.MBeanNotificationInfo[] NOTIFICATION_INFOS

mBeanInfo

private javax.management.MBeanInfo mBeanInfo

poolDefinition

private ConnectionPoolDefinitionIF poolDefinition

poolProperties

private java.util.Properties poolProperties

definitionUpdatedSequence

private long definitionUpdatedSequence

notificationHelper

private javax.management.NotificationBroadcasterSupport notificationHelper

active

private boolean active
Constructor Detail

ConnectionPoolMBean

public ConnectionPoolMBean(java.lang.String alias,
                           java.util.Properties poolProperties)
                    throws ProxoolException
Throws:
ProxoolException
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String attributeName)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException
Specified by:
getAttribute in interface javax.management.DynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.MBeanException
javax.management.ReflectionException
See Also:
DynamicMBean.getAttribute(java.lang.String)

setAttribute

public void setAttribute(javax.management.Attribute attribute)
                  throws javax.management.AttributeNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.MBeanException,
                         javax.management.ReflectionException
Specified by:
setAttribute in interface javax.management.DynamicMBean
Throws:
javax.management.AttributeNotFoundException
javax.management.InvalidAttributeValueException
javax.management.MBeanException
javax.management.ReflectionException
See Also:
DynamicMBean.setAttribute(javax.management.Attribute)

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String[] attributeNames)
Specified by:
getAttributes in interface javax.management.DynamicMBean
See Also:
DynamicMBean.getAttributes(java.lang.String[])

setAttributes

public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)
Specified by:
setAttributes in interface javax.management.DynamicMBean
See Also:
DynamicMBean.setAttributes(javax.management.AttributeList)

invoke

public java.lang.Object invoke(java.lang.String operationName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException,
                               javax.management.ReflectionException
Specified by:
invoke in interface javax.management.DynamicMBean
Throws:
javax.management.MBeanException
javax.management.ReflectionException
See Also:
DynamicMBean.invoke(java.lang.String, java.lang.Object[], java.lang.String[])

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo()
Specified by:
getMBeanInfo in interface javax.management.DynamicMBean
See Also:
DynamicMBean.getMBeanInfo()

getDynamicMBeanInfo

private javax.management.MBeanInfo getDynamicMBeanInfo(java.lang.String alias)

getAttributeDescription

private static java.lang.String getAttributeDescription(java.lang.String attributeName)

getJMXText

private static java.lang.String getJMXText(java.lang.String key)

createAttributeDescriptionsResource

private static java.util.ResourceBundle createAttributeDescriptionsResource()

createJMXResource

private static java.util.ResourceBundle createJMXResource()

createProxoolAttribute

private static javax.management.MBeanAttributeInfo createProxoolAttribute(java.lang.String attributeName,
                                                                          java.lang.Class type)

createProxoolAttribute

private static javax.management.MBeanAttributeInfo createProxoolAttribute(java.lang.String attributeName,
                                                                          java.lang.Class type,
                                                                          boolean writable)

checkAssignable

private void checkAssignable(java.lang.String name,
                             java.lang.Class clazz,
                             java.lang.Object value)
                      throws javax.management.InvalidAttributeValueException
Throws:
javax.management.InvalidAttributeValueException

equalsProperty

private boolean equalsProperty(java.lang.String beanAttribute,
                               java.lang.String proxoolProperty)

setDelegateProperties

private void setDelegateProperties(java.util.Properties properties,
                                   java.lang.String propertyString)
                            throws javax.management.InvalidAttributeValueException
Throws:
javax.management.InvalidAttributeValueException

getDelegatePropertiesAsString

private java.lang.String getDelegatePropertiesAsString(java.util.Properties properties)

notEmpty

private boolean notEmpty(java.lang.Object object)

notEmptyOrZero

private boolean notEmptyOrZero(java.lang.Integer integer)

getValueOrEmpty

private java.lang.String getValueOrEmpty(java.lang.String property)

setIntegerAttribute

private void setIntegerAttribute(java.lang.String attributeName,
                                 java.lang.String propertyName,
                                 java.lang.Object value,
                                 int defaultValue,
                                 java.util.Properties properties,
                                 javax.management.AttributeList resultList)
                          throws javax.management.InvalidAttributeValueException
Throws:
javax.management.InvalidAttributeValueException

isEqualProperties

private boolean isEqualProperties(java.lang.String property1,
                                  java.lang.String property2)

getNotificationInfos

private static javax.management.MBeanNotificationInfo[] getNotificationInfos()

onRegistration

public void onRegistration(ConnectionPoolDefinitionIF connectionPoolDefinition,
                           java.util.Properties completeInfo)
Not used.

Specified by:
onRegistration in interface ProxoolListenerIF
Parameters:
connectionPoolDefinition - the new definition.
completeInfo - the properties that could be used to create this definition.
See Also:
ProxoolListenerIF.onRegistration(org.logicalcobwebs.proxool.ConnectionPoolDefinitionIF, java.util.Properties)

onShutdown

public void onShutdown(java.lang.String alias)
If the given alias equals this pools alias: Unregister this JMX bean.

Specified by:
onShutdown in interface ProxoolListenerIF
Parameters:
alias - the alias of the pool about to be shut down.
See Also:
ProxoolListenerIF.onShutdown(java.lang.String)

definitionUpdated

public void definitionUpdated(ConnectionPoolDefinitionIF connectionPoolDefinition,
                              java.util.Properties completeInfo,
                              java.util.Properties changedInfo)
Update the attributes of this MBean and emit a NOTIFICATION_TYPE_DEFINITION_UPDATED event.

Specified by:
definitionUpdated in interface ConfigurationListenerIF
Parameters:
connectionPoolDefinition - the new definition
completeInfo - the properties that could be used to create this definition
changedInfo - only the properties that have changed since the pool was registered, or this method was las called.
See Also:
ConfigurationListenerIF.definitionUpdated(org.logicalcobwebs.proxool.ConnectionPoolDefinitionIF, java.util.Properties, java.util.Properties)

addNotificationListener

public void addNotificationListener(javax.management.NotificationListener notificationListener,
                                    javax.management.NotificationFilter notificationFilter,
                                    java.lang.Object handBack)
                             throws java.lang.IllegalArgumentException
Specified by:
addNotificationListener in interface javax.management.NotificationBroadcaster
Throws:
java.lang.IllegalArgumentException
See Also:
NotificationBroadcaster.addNotificationListener(javax.management.NotificationListener, javax.management.NotificationFilter, java.lang.Object)

removeNotificationListener

public void removeNotificationListener(javax.management.NotificationListener notificationListener)
                                throws javax.management.ListenerNotFoundException
Specified by:
removeNotificationListener in interface javax.management.NotificationBroadcaster
Throws:
javax.management.ListenerNotFoundException
See Also:
NotificationBroadcaster.removeNotificationListener(javax.management.NotificationListener)

getNotificationInfo

public javax.management.MBeanNotificationInfo[] getNotificationInfo()
Specified by:
getNotificationInfo in interface javax.management.NotificationBroadcaster
See Also:
NotificationBroadcaster.getNotificationInfo()

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer mBeanServer,
                                               javax.management.ObjectName objectName)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception
See Also:
MBeanRegistration.preRegister(javax.management.MBeanServer, javax.management.ObjectName)

postRegister

public void postRegister(java.lang.Boolean success)
Specified by:
postRegister in interface javax.management.MBeanRegistration
See Also:
MBeanRegistration.postRegister(java.lang.Boolean)

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception
See Also:
MBeanRegistration.preDeregister()

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration
See Also:
MBeanRegistration.postDeregister()