public Object invoke(String name,
Object[] args,
String[] signature) throws MBeanException, ReflectionException {
Object value;
if (name == null)
throw new RuntimeOperationsException(new IllegalArgumentException("Null operation"));
else if( name.equals("getNotificationInfo") )
value = mbean.getNotificationInfo();
else
{
try
{
value = super.invoke(name, args, signature);
}
catch (RuntimeMBeanException e)
{
// For some reason (not mentioned in the spec) these have to
// be wrapped in MBeanExceptions for RMM
throw new MBeanException(e.getTargetException(), e.getMessage());
}
catch (ReflectionException e)
{
// Another inconsistency
Exception ex = e.getTargetException();
if ((ex instanceof ClassNotFoundException) == false &&
(ex instanceof NoSuchMethodException) == false)
{
log.debug("Rewrapping reflection exception: ", e);
throw new MBeanException(new ServiceNotFoundException(ex.getMessage()), e.getMessage());
}
else
throw e;
}
}
return value;
}
|