use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class ModelMBeanAttributeInfo method validDescriptor.
/**
* Clones the passed in Descriptor, sets default values, and checks for validity.
* If the Descriptor is invalid (for instance by having the wrong "name"),
* this indicates programming error and a RuntimeOperationsException will be thrown.
*
* The following fields will be defaulted if they are not already set:
* displayName=this.getName(),name=this.getName(),descriptorType = "attribute"
*
* @param in Descriptor to be checked, or null which is equivalent to
* an empty Descriptor.
* @exception RuntimeOperationsException if Descriptor is invalid
*/
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone;
boolean defaulted = (in == null);
if (defaulted) {
clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
} else {
clone = (Descriptor) in.clone();
}
//Setting defaults.
if (defaulted && clone.getFieldValue("name") == null) {
clone.setField("name", this.getName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
}
if (defaulted && clone.getFieldValue("descriptorType") == null) {
clone.setField("descriptorType", "attribute");
MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"attribute\"");
}
if (clone.getFieldValue("displayName") == null) {
clone.setField("displayName", this.getName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
}
//Checking validity
if (!clone.isValid()) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The isValid() method of the Descriptor object itself returned false," + "one or more required fields are invalid. Descriptor:" + clone.toString());
}
if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"name\" field does not match the object described. " + " Expected: " + this.getName() + " , was: " + clone.getFieldValue("name"));
}
if (!"attribute".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"descriptorType\" field does not match the object described. " + " Expected: \"attribute\" ," + " was: " + clone.getFieldValue("descriptorType"));
}
return clone;
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class ModelMBeanConstructorInfo method validDescriptor.
/**
* Clones the passed in Descriptor, sets default values, and checks for validity.
* If the Descriptor is invalid (for instance by having the wrong "name"),
* this indicates programming error and a RuntimeOperationsException will be thrown.
*
* The following fields will be defaulted if they are not already set:
* displayName=this.getName(), name=this.getName(), descriptorType="operation",
* role="constructor"
*
*
* @param in Descriptor to be checked, or null which is equivalent to
* an empty Descriptor.
* @exception RuntimeOperationsException if Descriptor is invalid
*/
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone;
boolean defaulted = (in == null);
if (defaulted) {
clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
} else {
clone = (Descriptor) in.clone();
}
//Setting defaults.
if (defaulted && clone.getFieldValue("name") == null) {
clone.setField("name", this.getName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
}
if (defaulted && clone.getFieldValue("descriptorType") == null) {
clone.setField("descriptorType", "operation");
MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\"");
}
if (clone.getFieldValue("displayName") == null) {
clone.setField("displayName", this.getName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
}
if (clone.getFieldValue("role") == null) {
clone.setField("role", "constructor");
MODELMBEAN_LOGGER.finer("Defaulting Descriptor role field to \"constructor\"");
}
//Checking validity
if (!clone.isValid()) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The isValid() method of the Descriptor object itself returned false," + "one or more required fields are invalid. Descriptor:" + clone.toString());
}
if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"name\" field does not match the object described. " + " Expected: " + this.getName() + " , was: " + clone.getFieldValue("name"));
}
if (!"operation".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"descriptorType\" field does not match the object described. " + " Expected: \"operation\" ," + " was: " + clone.getFieldValue("descriptorType"));
}
if (!((String) clone.getFieldValue("role")).equalsIgnoreCase("constructor")) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"role\" field does not match the object described. " + " Expected: \"constructor\" ," + " was: " + clone.getFieldValue("role"));
}
return clone;
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class ModelMBeanInfoSupport method validDescriptor.
/**
* Clones the passed in Descriptor, sets default values, and checks for validity.
* If the Descriptor is invalid (for instance by having the wrong "name"),
* this indicates programming error and a RuntimeOperationsException will be thrown.
*
* The following fields will be defaulted if they are not already set:
* displayName=className,name=className,descriptorType="mbean",
* persistPolicy="never", log="F", visibility="1"
*
* @param in Descriptor to be checked, or null which is equivalent to
* an empty Descriptor.
* @exception RuntimeOperationsException if Descriptor is invalid
*/
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone;
boolean defaulted = (in == null);
if (defaulted) {
clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
} else {
clone = (Descriptor) in.clone();
}
//Setting defaults.
if (defaulted && clone.getFieldValue("name") == null) {
clone.setField("name", this.getClassName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getClassName());
}
if (defaulted && clone.getFieldValue("descriptorType") == null) {
clone.setField("descriptorType", MMB);
MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"" + MMB + "\"");
}
if (clone.getFieldValue("displayName") == null) {
clone.setField("displayName", this.getClassName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getClassName());
}
if (clone.getFieldValue("persistPolicy") == null) {
clone.setField("persistPolicy", "never");
MODELMBEAN_LOGGER.finer("Defaulting Descriptor persistPolicy to \"never\"");
}
if (clone.getFieldValue("log") == null) {
clone.setField("log", "F");
MODELMBEAN_LOGGER.finer("Defaulting Descriptor \"log\" field to \"F\"");
}
if (clone.getFieldValue("visibility") == null) {
clone.setField("visibility", "1");
MODELMBEAN_LOGGER.finer("Defaulting Descriptor visibility to 1");
}
//Checking validity
if (!clone.isValid()) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The isValid() method of the Descriptor object itself returned false," + "one or more required fields are invalid. Descriptor:" + clone.toString());
}
if (!((String) clone.getFieldValue("descriptorType")).equalsIgnoreCase(MMB)) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"descriptorType\" field does not match the object described. " + " Expected: " + MMB + " , was: " + clone.getFieldValue("descriptorType"));
}
return clone;
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class ModelMBeanNotificationInfo method validDescriptor.
/**
* Clones the passed in Descriptor, sets default values, and checks for validity.
* If the Descriptor is invalid (for instance by having the wrong "name"),
* this indicates programming error and a RuntimeOperationsException will be thrown.
*
* The following fields will be defaulted if they are not already set:
* descriptorType="notification",displayName=this.getName(),
* name=this.getName(),severity="6"
*
*
* @param in Descriptor to be checked, or null which is equivalent to an
* empty Descriptor.
* @exception RuntimeOperationsException if Descriptor is invalid
*/
private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
Descriptor clone;
boolean defaulted = (in == null);
if (defaulted) {
clone = new DescriptorSupport();
MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
} else {
clone = (Descriptor) in.clone();
}
//Setting defaults.
if (defaulted && clone.getFieldValue("name") == null) {
clone.setField("name", this.getName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
}
if (defaulted && clone.getFieldValue("descriptorType") == null) {
clone.setField("descriptorType", "notification");
MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"notification\"");
}
if (clone.getFieldValue("displayName") == null) {
clone.setField("displayName", this.getName());
MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
}
if (clone.getFieldValue("severity") == null) {
clone.setField("severity", "6");
MODELMBEAN_LOGGER.finer("Defaulting Descriptor severity field to 6");
}
//Checking validity
if (!clone.isValid()) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The isValid() method of the Descriptor object itself returned false," + "one or more required fields are invalid. Descriptor:" + clone.toString());
}
if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"name\" field does not match the object described. " + " Expected: " + this.getName() + " , was: " + clone.getFieldValue("name"));
}
if (!"notification".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"), "The Descriptor \"descriptorType\" field does not match the object described. " + " Expected: \"notification\" ," + " was: " + clone.getFieldValue("descriptorType"));
}
return clone;
}
use of javax.management.RuntimeOperationsException in project jdk8u_jdk by JetBrains.
the class RequiredModelMBean method invokeMethod.
/*
* Invoke the given method, and throw the somewhat unpredictable
* appropriate exception if the method itself gets an exception.
*/
private Object invokeMethod(String opName, final Method method, final Object targetObject, final Object[] opArgs) throws MBeanException, ReflectionException {
try {
final Throwable[] caughtException = new Throwable[1];
AccessControlContext stack = AccessController.getContext();
Object rslt = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Object>() {
@Override
public Object run() {
try {
ReflectUtil.checkPackageAccess(method.getDeclaringClass());
return MethodUtil.invoke(method, targetObject, opArgs);
} catch (InvocationTargetException e) {
caughtException[0] = e;
} catch (IllegalAccessException e) {
caughtException[0] = e;
}
return null;
}
}, stack, acc);
if (caughtException[0] != null) {
if (caughtException[0] instanceof Exception) {
throw (Exception) caughtException[0];
} else if (caughtException[0] instanceof Error) {
throw (Error) caughtException[0];
}
}
return rslt;
} catch (RuntimeErrorException ree) {
throw new RuntimeOperationsException(ree, "RuntimeException occurred in RequiredModelMBean " + "while trying to invoke operation " + opName);
} catch (RuntimeException re) {
throw new RuntimeOperationsException(re, "RuntimeException occurred in RequiredModelMBean " + "while trying to invoke operation " + opName);
} catch (IllegalAccessException iae) {
throw new ReflectionException(iae, "IllegalAccessException occurred in " + "RequiredModelMBean while trying to " + "invoke operation " + opName);
} catch (InvocationTargetException ite) {
Throwable mmbTargEx = ite.getTargetException();
if (mmbTargEx instanceof RuntimeException) {
throw new MBeanException((RuntimeException) mmbTargEx, "RuntimeException thrown in RequiredModelMBean " + "while trying to invoke operation " + opName);
} else if (mmbTargEx instanceof Error) {
throw new RuntimeErrorException((Error) mmbTargEx, "Error occurred in RequiredModelMBean while trying " + "to invoke operation " + opName);
} else if (mmbTargEx instanceof ReflectionException) {
throw (ReflectionException) mmbTargEx;
} else {
throw new MBeanException((Exception) mmbTargEx, "Exception thrown in RequiredModelMBean " + "while trying to invoke operation " + opName);
}
} catch (Error err) {
throw new RuntimeErrorException(err, "Error occurred in RequiredModelMBean while trying " + "to invoke operation " + opName);
} catch (Exception e) {
throw new ReflectionException(e, "Exception occurred in RequiredModelMBean while " + "trying to invoke operation " + opName);
}
}
Aggregations