throw new MBeanException(new ServiceNotFoundException( "Could not find target")); method = realTarget.getClass().getMethod(methodName, params); } catch (NoSuchMethodException x) { throw new ReflectionException(x); return value; } catch (IllegalAccessException x) { throw new ReflectionException(x); } catch (IllegalArgumentException x) { throw new MBeanException(x); } catch (InvocationTargetException x) { Throwable t = x.getTargetException(); if (t instanceof Error) throw new MBeanException(new RuntimeErrorException((Error) t)); else throw new MBeanException((Exception) t);
logger.warn(e.getMessage(), e); } catch (InstanceNotFoundException e) { logger.warn(e.getMessage(), e); } catch (ReflectionException e) { logger.warn(e.getMessage(), e); } catch (MBeanException e) { logger.warn(e.getMessage(), e);
/** * get single value by key */ public String getValue(String key) throws Exception { Object val = null; for (ObjectName oname : hadoopObjectNames) { try { val = mbsc.getAttribute(oname, key); } catch (AttributeNotFoundException anfe) { /* just go to the next */ continue; } catch (ReflectionException re) { if (re.getCause() instanceof NoSuchMethodException) { continue; } } err("Info: key = " + key + "; val = " + (val == null ? "null" : val.getClass()) + ":" + val); break; } return (val == null) ? "" : val.toString(); }
@Override public Object getAttribute(String att) throws AttributeNotFoundException, MBeanException, ReflectionException { Field f = fields.get(att); if (f == null) { throw new AttributeNotFoundException(att); } try { return f.get(this); } catch (Exception e) { throw new ReflectionException(e, "error getting attribute " + att); } }
public Object invoke(String operationName, Object params[], String signature[]) throws MBeanException, ReflectionException { if (operationName == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Operation name cannot be null"), "Cannot invoke a null operation in " + dClassName); } // Check for a recognized operation name and call the corresponding operation if(operationName.equals("addLoggerMBean")) { return addLoggerMBean((String)params[0]); } else { throw new ReflectionException( new NoSuchMethodException(operationName), "Cannot find the operation " + operationName + " in " + dClassName); } }
@Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { String name = attribute.getName(); MAttribute a = this.attributes.get(name); if(null == a) { throw new AttributeNotFoundException("Attribute '" + name + "' not found in '" + bean.getClass() + "'"); } //todo : convert the value. try{ a.valued().setValue(bean, attribute.getValue()); }catch(ReflectException e) { throw new ReflectionException(e); }catch(Exception e) { throw new MBeanException(e); } }
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { // Another inconsistency if (attribute == null) throw new RuntimeOperationsException(new IllegalArgumentException("Null attribute")); try { super.setAttribute(attribute); } 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; } }
throws MBeanException, ReflectionException { if (method == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Method name cannot be null.")); if (arguments == null) throw new MBeanException(new ServiceNotFoundException( "ModelMBeanInfo is null")); if (logger.isEnabledFor(Logger.DEBUG)) throw new MBeanException(new ServiceNotFoundException( String.format("Cannot find ModelMBeanOperationInfo for operation %s", method))); throw new MBeanException(new ServiceNotFoundException( String.format("Operation descriptor for operation %s cannot be null", method))); } catch (ClassNotFoundException x) { logger.error("Cannot find operation's parameter classes", x); throw new ReflectionException(x);
public final Object getAttribute(final ObjectName objectName, final String attributeName) throws InstanceNotFoundException, AttributeNotFoundException, MBeanException, ReflectionException { if(objectName == null) throw new InstanceNotFoundException(); DynamicInterceptor.ReplicationInfo result = getInstance(objectName); if(!result.isTargetAnInstance()) return getDelegateMBeanServer().getAttribute( objectName, attributeName); try { return getInstanceConnection(result.getInstances().get(0)).getAttribute(objectName, attributeName); } catch (IOException ioex) { throw new ReflectionException(ioex); } }
Object result = null; try { result = repr.invoke(on, operation, param, signature); } catch (IOException ioe) { throw ioe; targetExc = ((MBeanException) e).getTargetException(); } else if (e instanceof ReflectionException) { targetExc = ((ReflectionException) e).getTargetException(); } else if (e instanceof RuntimeMBeanException) { targetExc = ((RuntimeMBeanException) e).getTargetException(); } else if (e instanceof RuntimeOperationsException) { targetExc = ((RuntimeOperationsException) e).getTargetException(); } else if (e instanceof RuntimeErrorException) { Error atargetExc = ((RuntimeErrorException) e).getTargetError();
@Override public Object invoke(String name, Object[] args, String[] sig) throws MBeanException, ReflectionException { throw new ReflectionException(new NoSuchMethodException(name)); }
public Object invoke( final ObjectName objectName, final String operationName, final Object[] params, final String[] signature) throws ReflectionException, InstanceNotFoundException, MBeanException { if(objectName == null) throw new InstanceNotFoundException(); DynamicInterceptor.ReplicationInfo result = getInstance(objectName); Object returnValue = null; try { for(String svr : result.getInstances()) { if("server".equals(svr)) { returnValue = getDelegateMBeanServer().invoke( objectName, operationName, params, signature ); } else { returnValue = getInstanceConnection(svr).invoke(objectName, operationName, params, signature); } } } catch (IOException ioex) { throw new ReflectionException(ioex); } return returnValue; }
public final MBeanInfo getMBeanInfo( final ObjectName objectName) throws InstanceNotFoundException, IntrospectionException, ReflectionException { if(objectName == null) throw new InstanceNotFoundException(); DynamicInterceptor.ReplicationInfo result = getInstance(objectName); try { if(result.isTargetAnInstance()) return getInstanceConnection(result.getInstances().get(0)).getMBeanInfo(objectName); else return getDelegateMBeanServer().getMBeanInfo( objectName ); } catch (IOException ioex) { throw new ReflectionException(ioex); } }
/** * Stop the application managed by this instance. * @throws MojoExecutionException if the JMX service could not be contacted * @throws IOException if an I/O error occurs * @throws InstanceNotFoundException if the lifecycle mbean cannot be found */ public void stop() throws MojoExecutionException, IOException, InstanceNotFoundException { try { this.connection.invoke(this.objectName, "shutdown", null, null); } catch (ReflectionException ex) { throw new MojoExecutionException("Shutdown failed", ex.getCause()); } catch (MBeanException ex) { throw new MojoExecutionException("Could not invoke shutdown operation", ex); } }
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { try { return super.getAttribute(name); } 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; } }
@Override public int getThreadCount() throws MonitoringException { int result = 0; final MBeanServer mbeanServer = MBeanUtil.getMBeanServer(); try { result = (Integer) mbeanServer.getAttribute(new ObjectName(JvmMBean.JVM_MBEAN_NAME), "ThreadCount"); } catch (final MalformedObjectNameException e) { throw new MonitoringException(e.getMessage(), e); } catch (final MBeanException e) { throw new MonitoringException(e.getMessage(), e); } catch (final ReflectionException e) { throw new MonitoringException(e.getMessage(), e); } catch (final AttributeNotFoundException e) { throw new MonitoringException(e.getMessage(), e); } catch (final javax.management.InstanceNotFoundException e) { throw new MonitoringException(e.getMessage(), e); } return result; }
/** * Check if the spring application managed by this instance is ready. Returns * {@code false} if the mbean is not yet deployed so this method should be repeatedly * called until a timeout is reached. * @return {@code true} if the application is ready to service requests * @throws org.springframework.jmx.JmxException if the JMX service could not be contacted */ public boolean isReady() { try { return (Boolean) this.connection.getAttribute(this.objectName, "Ready"); } catch (InstanceNotFoundException ex) { return false; // Instance not available yet } catch (AttributeNotFoundException ex) { throw new IllegalStateException( "Unexpected: attribute 'Ready' not available", ex); } catch (ReflectionException ex) { throw new JmxException("Failed to retrieve Ready attribute", ex.getCause()); } catch (MBeanException ex) { throw new JmxException(ex.getMessage(), ex); } catch (IOException ex) { throw new JmxException(ex.getMessage(), ex); } }
public void setAttribute(final ObjectName objectName, final Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, MBeanException, ReflectionException, InvalidAttributeValueException { if(objectName == null) throw new InstanceNotFoundException(); DynamicInterceptor.ReplicationInfo result = getInstance(objectName); try { if(result.isTargetAnInstance()) { getInstanceConnection(result.getInstances().get(0)).setAttribute(objectName, attribute); return; } for(String svr : result.getInstances()) { if("server".equals(svr)) getDelegateMBeanServer().setAttribute( objectName, attribute ); else getInstanceConnection(svr).setAttribute(objectName, attribute); } } catch (IOException ioex) { throw new ReflectionException(ioex); } }
public final AttributeList getAttributes(final ObjectName objectName, final String[] attrNames) throws InstanceNotFoundException, ReflectionException { if(objectName == null) throw new InstanceNotFoundException(); DynamicInterceptor.ReplicationInfo result = getInstance(objectName); try { if(result.isTargetAnInstance()) return getInstanceConnection(result.getInstances().get(0)).getAttributes(objectName, attrNames); else return getDelegateMBeanServer().getAttributes( objectName, attrNames ); } catch (IOException ioex) { throw new ReflectionException(ioex); } }
public PlainMBeanMirror(MBeanServerConnection mbsc, ObjectName objectName, ObjectName localObjectName) throws IOException, InstanceNotFoundException, IntrospectionException { this.mbsc = mbsc; this.objectName = objectName; this.localObjectName = localObjectName; try { this.mbeanInfo = mbsc.getMBeanInfo(objectName); } catch (ReflectionException e) { // Callers cannot possibly care about the difference between // IntrospectionException and ReflectionException IntrospectionException ie = new IntrospectionException(e.getMessage()); ie.initCause(e); throw ie; } }