JMXMBean.java revision 407bb81fb935e713a4a1ae1b9189b81488a944d5
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2006-2007-2008 Sun Microsystems, Inc.
* Portions Copyright 2013-2014 ForgeRock AS
*/
/**
* This class defines a JMX MBean that can be registered with the Directory
* read-write access to the configuration, and provide notifications and alerts
*/
mayInstantiate=true,
mayExtend=false,
mayInvoke=true)
public final class JMXMBean
implements DynamicMBean, DirectoryServerMBean
{
/**
* The fully-qualified name of this class.
*/
/** The set of alert generators for this MBean. */
/** The set of invokable components for this MBean. */
/** The set of monitor providers for this MBean. */
/** The DN of the configuration entry with which this MBean is associated. */
private DN configEntryDN;
/** The object name for this MBean. */
private ObjectName objectName;
/**
* Creates a JMX object name string based on a DN.
*
* @param configEntryDN The DN of the configuration entry with which
* this ObjectName is associated.
*
* @return The string representation of the JMX Object Name
* associated with the input DN.
*/
{
try
{
{
{
{
{
} else
{
switch (c)
{
case ' ':
break;
case '=':
}
}
}
}
}
} catch (Exception e)
{
logger.traceException(e);
}
return nameStr ;
}
/**
* Creates a new dynamic JMX MBean for use with the Directory Server.
*
* @param configEntryDN The DN of the configuration entry with which this
* MBean is associated.
*/
{
this.configEntryDN = configEntryDN;
? extends MonitorProviderCfg>>();
if (mBeanServer != null)
{
try
{
try
{
{
}
}
catch(Exception e)
{
logger.traceException(e);
}
}
catch (Exception e)
{
logger.traceException(e);
}
}
}
/**
* Retrieves the JMX object name for this JMX MBean.
*
* @return The JMX object name for this JMX MBean.
*/
public ObjectName getObjectName()
{
return objectName;
}
/**
* Retrieves the set of alert generators for this JMX MBean.
*
* @return The set of alert generators for this JMX MBean.
*/
{
return alertGenerators;
}
/**
* Adds the provided alert generator to the set of alert generators associated
* with this JMX MBean.
*
* @param generator The alert generator to add to the set of alert
* generators for this JMX MBean.
*/
{
synchronized (alertGenerators)
{
{
}
}
}
/**
* Removes the provided alert generator from the set of alert generators
* associated with this JMX MBean.
*
* @param generator The alert generator to remove from the set of alert
* generators for this JMX MBean.
*
* @return <CODE>true</CODE> if the alert generator was removed, or
* <CODE>false</CODE> if it was not associated with this MBean.
*/
{
synchronized (alertGenerators)
{
}
}
/**
* Retrieves the set of invokable components associated with this JMX MBean.
*
* @return The set of invokable components associated with this JMX MBean.
*/
{
return invokableComponents;
}
/**
* Adds the provided invokable component to the set of components associated
* with this JMX MBean.
*
* @param component The component to add to the set of invokable components
* for this JMX MBean.
*/
{
synchronized (invokableComponents)
{
{
}
}
}
/**
* Removes the provided invokable component from the set of components
* associated with this JMX MBean.
*
* @param component The component to remove from the set of invokable
* components for this JMX MBean.
*
* @return <CODE>true</CODE> if the specified component was successfully
* removed, or <CODE>false</CODE> if not.
*/
{
synchronized (invokableComponents)
{
}
}
/**
* Retrieves the set of monitor providers associated with this JMX MBean.
*
* @return The set of monitor providers associated with this JMX MBean.
*/
{
return monitorProviders;
}
/**
* Adds the given monitor provider to the set of components associated with
* this JMX MBean.
*
* @param component The component to add to the set of monitor providers
* for this JMX MBean.
*/
{
synchronized (monitorProviders)
{
{
}
}
}
/**
* Removes the given monitor provider from the set of components associated
* with this JMX MBean.
*
* @param component The component to remove from the set of monitor
* providers for this JMX MBean.
*
* @return <CODE>true</CODE> if the specified component was successfully
* removed, or <CODE>false</CODE> if not.
*/
{
synchronized (monitorProviders)
{
}
}
/**
* Retrieves the specified configuration attribute.
*
* @param name The name of the configuration attribute to retrieve.
*
* @return The specified configuration attribute, or <CODE>null</CODE> if
* there is no such attribute.
*/
{
// It's possible that this is a monitor attribute rather than a configurable
// one. Check all of those.
{
}
{
{
{
if (a.isEmpty())
{
continue;
}
{
{
}
}
else
{
}
}
}
}
return null;
}
/**
* Obtain the value of a specific attribute of the Dynamic MBean.
*
* @param attributeName The name of the attribute to be retrieved.
*
* @return The requested attribute.
*
* @throws AttributeNotFoundException If the specified attribute is not
* associated with this MBean.
*/
throws AttributeNotFoundException
{
//
// Get the jmx Client connection
if (clientConnection == null)
{
return null;
}
//
// prepare the ldap search
try
{
//
// Perform the Ldap operation for
// - ACI Check
// - Loggin purpose
if (clientConnection instanceof JmxClientConnection) {
}
else if (clientConnection instanceof InternalClientConnection) {
}
// BUG : op may be null
}
return getJmxAttribute(attributeName);
}
catch (AttributeNotFoundException e)
{
throw e;
}
catch (Exception e)
{
logger.traceException(e);
}
}
/**
* Set the value of a specific attribute of the Dynamic MBean. In this case,
* it will always throw {@code InvalidAttributeValueException} because setting
* attribute values over JMX is currently not allowed.
*
* @param attribute The identification of the attribute to be set and the
* value it is to be set to.
*
* @throws AttributeNotFoundException If the specified attribute is not
* associated with this MBean.
*
* @throws InvalidAttributeValueException If the provided value is not
* acceptable for this MBean.
*/
{
throw new InvalidAttributeValueException();
}
/**
* Get the values of several attributes of the Dynamic MBean.
*
* @param attributes A list of the attributes to be retrieved.
*
* @return The list of attributes retrieved.
*/
{
//
// Get the jmx Client connection
if (clientConnection == null)
{
return null;
}
//
// Perform the Ldap operation for
// - ACI Check
// - Loggin purpose
if (clientConnection instanceof JmxClientConnection) {
}
else if (clientConnection instanceof InternalClientConnection) {
}
{
return null;
}
{
return null;
}
{
try
{
{
continue;
}
}
catch (Exception e)
{
logger.traceException(e);
}
// It's possible that this is a monitor attribute rather than a
// configurable one. Check all of those.
{
}
{
{
{
if (a.isEmpty())
{
continue;
}
{
{
}
break monitorLoop;
}
else
{
break monitorLoop;
}
}
}
}
}
return attrList;
}
/**
* Sets the values of several attributes of the Dynamic MBean.
*
* @param attributes A list of attributes: The identification of the
* attributes to be set and the values they are to be set
* to.
*
* @return The list of attributes that were set with their new values. In
* this case, the list will always be empty because we do not support
* setting attribute values over JMX.
*/
{
return new AttributeList();
}
/**
* Allows an action to be invoked on the Dynamic MBean.
*
* @param actionName The name of the action to be invoked.
* @param params An array containing the parameters to be set when the
* action is invoked.
* @param signature An array containing the signature of the action. The
* class objects will be loaded through the same class
* loader as the one used for loading the MBean on which
* action is invoked.
*
* @return The object returned by the action, which represents the result of
* invoking the action on the MBean specified.
*
* @throws MBeanException If a problem is encountered while invoking the
* method.
*/
throws MBeanException
{
{
{
{
try
{
}
catch (MBeanException me)
{
throw me;
}
catch (Exception e)
{
logger.traceException(e);
throw new MBeanException(e);
}
}
}
}
// If we've gotten here, then there is no such method so throw an exception.
{
{
}
}
throw new MBeanException(
}
/**
* Provides the exposed attributes and actions of the Dynamic MBean using an
* MBeanInfo object.
*
* @return An instance of <CODE>MBeanInfo</CODE> allowing all attributes and
* actions exposed by this Dynamic MBean to be retrieved.
*/
public MBeanInfo getMBeanInfo()
{
if (clientConnection == null)
{
}
{
{
null, true, false, false));
}
}
new ArrayList<MBeanNotificationInfo>();
{
{
description));
}
}
{
{
}
}
return new MBeanInfo(CLASS_NAME,
"Configurable Attributes for " +
}
/**
* Get the client JMX connection to use. Returns null if an Exception is
* caught or if the AccessControlContext subject is null.
*
* @return The JmxClientConnection.
*/
private ClientConnection getClientConnection()
{
.getContext();
try
{
.getSubject(acc);
{
}
}
catch (Exception e)
{
}
return clientConnection;
}
}