下面列出了怎么用javax.management.OperationsException的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Invokes an operation on an MBean.
*
* @param onameStr The name of the MBean.
* @param operation The name of the operation to invoke.
* @param parameters An array of Strings containing the parameters to the
* operation. They will be converted to the appropriate types to
* call the requested operation.
* @return The value returned by the requested operation.
*/
private Object invokeOperationInternal(String onameStr, String operation, String[] parameters)
throws OperationsException, MBeanException, ReflectionException {
ObjectName oname = new ObjectName(onameStr);
MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation);
MBeanParameterInfo[] signature = methodInfo.getSignature();
String[] signatureTypes = new String[signature.length];
Object[] values = new Object[signature.length];
for (int i = 0; i < signature.length; i++) {
MBeanParameterInfo pi = signature[i];
signatureTypes[i] = pi.getType();
values[i] = registry.convertValue(pi.getType(), parameters[i]);
}
return mBeanServer.invoke(oname, operation, values, signatureTypes);
}
/**
* Sets an MBean attribute's value.
*/
private void setAttributeInternal(String onameStr, String attributeName, String value)
throws OperationsException, MBeanException, ReflectionException {
ObjectName oname = new ObjectName(onameStr);
String type = registry.getType(oname, attributeName);
Object valueObj = registry.convertValue(type, value);
mBeanServer.setAttribute(oname, new Attribute(attributeName, valueObj));
}
@Override
@Deprecated
public ObjectInputStream deserialize(ObjectName name, byte[] data)
throws OperationsException
{
return mbeanServer.deserialize(name, data);
}
@Override
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException
{
return mbeanServer.deserialize(className, data);
}
@Override
@Deprecated
public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data)
throws OperationsException, ReflectionException
{
return mbeanServer.deserialize(className, loaderName, data);
}
/**
* De-serializes a byte array in the context of a given MBean class loader.
* The class loader is the one that loaded the class with name "className".
*
* @param className The name of the class whose class loader should be
* used for the de-serialization.
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output
* related exceptions.
* @exception ReflectionException The specified class could not be
* loaded by the default loader repository
*
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
if (className == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException(),
"Null className passed in parameter");
}
/* Permission check */
// This call requires MBeanPermission 'getClassLoaderRepository'
final ClassLoaderRepository clr = getClassLoaderRepository();
Class<?> theClass;
try {
if (clr == null) throw new ClassNotFoundException(className);
theClass = clr.loadClass(className);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e,
"The given class could not be " +
"loaded by the default loader " +
"repository");
}
return instantiator.deserialize(theClass.getClassLoader(), data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(ObjectName name, byte[] data)
throws InstanceNotFoundException, OperationsException {
checkRead();
return getMBeanServer().deserialize(name, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className,
ObjectName loaderName,
byte[] data)
throws
InstanceNotFoundException,
OperationsException,
ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, loaderName, data);
}
/**
* De-serializes a byte array in the context of a given MBean class loader.
* The class loader is the one that loaded the class with name "className".
*
* @param className The name of the class whose class loader should be
* used for the de-serialization.
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output
* related exceptions.
* @exception ReflectionException The specified class could not be
* loaded by the default loader repository
*
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
if (className == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException(),
"Null className passed in parameter");
}
/* Permission check */
// This call requires MBeanPermission 'getClassLoaderRepository'
final ClassLoaderRepository clr = getClassLoaderRepository();
Class<?> theClass;
try {
if (clr == null) throw new ClassNotFoundException(className);
theClass = clr.loadClass(className);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e,
"The given class could not be " +
"loaded by the default loader " +
"repository");
}
return instantiator.deserialize(theClass.getClassLoader(), data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(ObjectName name, byte[] data)
throws InstanceNotFoundException, OperationsException {
checkRead();
return getMBeanServer().deserialize(name, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className,
ObjectName loaderName,
byte[] data)
throws
InstanceNotFoundException,
OperationsException,
ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, loaderName, data);
}
/**
* De-serializes a byte array in the context of a given MBean class loader.
* The class loader is the one that loaded the class with name "className".
*
* @param className The name of the class whose class loader should be
* used for the de-serialization.
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output
* related exceptions.
* @exception ReflectionException The specified class could not be
* loaded by the default loader repository
*
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
if (className == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException(),
"Null className passed in parameter");
}
/* Permission check */
// This call requires MBeanPermission 'getClassLoaderRepository'
final ClassLoaderRepository clr = getClassLoaderRepository();
Class<?> theClass;
try {
if (clr == null) throw new ClassNotFoundException(className);
theClass = clr.loadClass(className);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e,
"The given class could not be " +
"loaded by the default loader " +
"repository");
}
return instantiator.deserialize(theClass.getClassLoader(), data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(ObjectName name, byte[] data)
throws InstanceNotFoundException, OperationsException {
checkRead();
return getMBeanServer().deserialize(name, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className,
ObjectName loaderName,
byte[] data)
throws
InstanceNotFoundException,
OperationsException,
ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, loaderName, data);
}
/**
* De-serializes a byte array in the context of a given MBean class loader.
* The class loader is the one that loaded the class with name "className".
*
* @param className The name of the class whose class loader should be
* used for the de-serialization.
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output
* related exceptions.
* @exception ReflectionException The specified class could not be
* loaded by the default loader repository
*
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
if (className == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException(),
"Null className passed in parameter");
}
/* Permission check */
// This call requires MBeanPermission 'getClassLoaderRepository'
final ClassLoaderRepository clr = getClassLoaderRepository();
Class<?> theClass;
try {
if (clr == null) throw new ClassNotFoundException(className);
theClass = clr.loadClass(className);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e,
"The given class could not be " +
"loaded by the default loader " +
"repository");
}
return instantiator.deserialize(theClass.getClassLoader(), data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className,
ObjectName loaderName,
byte[] data)
throws
InstanceNotFoundException,
OperationsException,
ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, loaderName, data);
}
/**
* De-serializes a byte array in the context of a given MBean class loader.
* The class loader is the one that loaded the class with name "className".
*
* @param className The name of the class whose class loader should be
* used for the de-serialization.
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output
* related exceptions.
* @exception ReflectionException The specified class could not be
* loaded by the default loader repository
*
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
if (className == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException(),
"Null className passed in parameter");
}
/* Permission check */
// This call requires MBeanPermission 'getClassLoaderRepository'
final ClassLoaderRepository clr = getClassLoaderRepository();
Class<?> theClass;
try {
if (clr == null) throw new ClassNotFoundException(className);
theClass = clr.loadClass(className);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e,
"The given class could not be " +
"loaded by the default loader " +
"repository");
}
return instantiator.deserialize(theClass.getClassLoader(), data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(ObjectName name, byte[] data)
throws InstanceNotFoundException, OperationsException {
checkRead();
return getMBeanServer().deserialize(name, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className,
ObjectName loaderName,
byte[] data)
throws
InstanceNotFoundException,
OperationsException,
ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, loaderName, data);
}
/**
* De-serializes a byte array in the context of a given MBean class loader.
* The class loader is the one that loaded the class with name "className".
*
* @param className The name of the class whose class loader should be
* used for the de-serialization.
* @param data The byte array to be de-sererialized.
*
* @return The de-serialized object stream.
*
* @exception OperationsException Any of the usual Input/Output
* related exceptions.
* @exception ReflectionException The specified class could not be
* loaded by the default loader repository
*
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
if (className == null) {
throw new RuntimeOperationsException(
new IllegalArgumentException(),
"Null className passed in parameter");
}
/* Permission check */
// This call requires MBeanPermission 'getClassLoaderRepository'
final ClassLoaderRepository clr = getClassLoaderRepository();
Class<?> theClass;
try {
if (clr == null) throw new ClassNotFoundException(className);
theClass = clr.loadClass(className);
} catch (ClassNotFoundException e) {
throw new ReflectionException(e,
"The given class could not be " +
"loaded by the default loader " +
"repository");
}
return instantiator.deserialize(theClass.getClassLoader(), data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(ObjectName name, byte[] data)
throws InstanceNotFoundException, OperationsException {
checkRead();
return getMBeanServer().deserialize(name, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className, byte[] data)
throws OperationsException, ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, data);
}
/**
* Call <code>checkRead()</code>, then forward this method to the
* wrapped object.
*/
@Deprecated
public ObjectInputStream deserialize(String className,
ObjectName loaderName,
byte[] data)
throws
InstanceNotFoundException,
OperationsException,
ReflectionException {
checkRead();
return getMBeanServer().deserialize(className, loaderName, data);
}
/**
* This method should never be called.
* Usually hrows UnsupportedOperationException.
*/
@Deprecated
public ObjectInputStream deserialize(String className,
ObjectName loaderName, byte[] data)
throws InstanceNotFoundException, OperationsException,
ReflectionException;
public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException,
OperationsException {
throw new UnsupportedOperationException("Not supported yet.");
}