/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class is the MBean implementation of the MBeanServerDelegate.
*
* @since 1.5
*/
final class MBeanServerDelegateImpl
extends MBeanServerDelegate
implements DynamicMBean, MBeanRegistration {
"MBeanServerId",
"SpecificationName",
"SpecificationVersion",
"SpecificationVendor",
"ImplementationName",
"ImplementationVersion",
"ImplementationVendor"
};
new MBeanAttributeInfo[] {
"The MBean server agent identification",
true,false,false),
"The full name of the JMX specification "+
"implemented by this product.",
true,false,false),
"The version of the JMX specification "+
"implemented by this product.",
true,false,false),
"The vendor of the JMX specification "+
"implemented by this product.",
true,false,false),
"The JMX implementation name "+
"(the name of this product)",
true,false,false),
"The JMX implementation version "+
"(the version of this product).",
true,false,false),
"the JMX implementation vendor "+
"(the vendor of this product).",
true,false,false)
};
public MBeanServerDelegateImpl () {
super();
new MBeanInfo("javax.management.MBeanServerDelegate",
"Represents the MBean server from the management "+
"point of view.",
}
else return name;
}
}
final public void preDeregister()
throw new IllegalArgumentException(
"The MBeanServerDelegate MBean cannot be unregistered");
}
final public void postDeregister() {
}
/**
* Obtains the value of a specific attribute of the MBeanServerDelegate.
*
* @param attribute The name of the attribute to be retrieved
*
* @return The value of the attribute retrieved.
*
* @exception AttributeNotFoundException
* @exception MBeanException
* Wraps a <CODE>java.lang.Exception</CODE> thrown by the
* MBean's getter.
*/
throws AttributeNotFoundException,
try {
// attribute must not be null
//
throw new AttributeNotFoundException("null");
// Extract the requested attribute from file
//
return getMBeanServerId();
return getSpecificationName();
return getSpecificationVersion();
return getSpecificationVendor();
return getImplementationName();
return getImplementationVersion();
return getImplementationVendor();
// Unknown attribute
//
else
throw new AttributeNotFoundException("null");
} catch (AttributeNotFoundException x) {
throw x;
} catch (JMRuntimeException j) {
throw j;
} catch (SecurityException s) {
throw s;
} catch (Exception x) {
}
}
/**
* This method always fail since all MBeanServerDelegateMBean attributes
* are read-only.
*
* @param attribute The identification of the attribute to
* be set and the value it is to be set to.
*
* @exception AttributeNotFoundException
*/
// Now we will always fail:
// Either because the attribute is null or because it is not
// accessible (or does not exist).
//
final RuntimeException r =
new IllegalArgumentException("Attribute name cannot be null");
throw new RuntimeOperationsException(r,
"Exception occurred trying to invoke the setter on the MBean");
}
// This is a hack: we call getAttribute in order to generate an
// AttributeNotFoundException if the attribute does not exist.
//
// If we reach this point, we know that the requested attribute
// exists. However, since all attributes are read-only, we throw
// an AttributeNotFoundException.
//
}
/**
* Makes it possible to get the values of several attributes of
* the MBeanServerDelegate.
*
* @param attributes A list of the attributes to be retrieved.
*
* @return The list of attributes retrieved.
*
*/
// If attributes is null, the get all attributes.
//
// Prepare the result list.
//
// Get each requested attribute.
//
for (int i=0;i<len;i++) {
try {
final Attribute a =
} catch (Exception x) {
// Skip the attribute that couldn't be obtained.
//
MBeanServerDelegateImpl.class.getName(),
"getAttributes",
}
}
}
// Finally return the result.
//
return list;
}
/**
* This method always return an empty list since all
* MBeanServerDelegateMBean attributes are read-only.
*
* @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 fact, this method always return an empty list since all
* MBeanServerDelegateMBean attributes are read-only.
*/
return new AttributeList(0);
}
/**
* Always fails since the MBeanServerDelegate MBean has no operation.
*
* @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.
*
* @return The object returned by the action, which represents
* the result of invoking the action on the MBean specified.
*
* @exception MBeanException Wraps a <CODE>java.lang.Exception</CODE>
* thrown by the MBean's invoked method.
* @exception ReflectionException Wraps a
* <CODE>java.lang.Exception</CODE> thrown while trying to invoke
* the method.
*/
throws MBeanException, ReflectionException {
// Check that operation name is not null.
//
if (actionName == null) {
final RuntimeException r =
new IllegalArgumentException("Operation name cannot be null");
throw new RuntimeOperationsException(r,
"Exception occurred trying to invoke the operation on the MBean");
}
throw new ReflectionException(
"The operation with name " + actionName +
" could not be found");
}
/**
* Provides the MBeanInfo describing the MBeanServerDelegate.
*
* @return The MBeanInfo describing the MBeanServerDelegate.
*
*/
return delegateInfo;
}
}