throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name"); log.debug("Called getAttribute with ["+attributeName+"]."); return new ObjectName("log4j:"+val); } catch(JMException e) { log.error("Could not create ObjectName" + val); } catch(RuntimeException e) { log.error("Could not create ObjectName" + val); throw(new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
throw new RuntimeOperationsException( new IllegalArgumentException("Attribute cannot be null"), "Cannot invoke a setter of " + dClassName + " with null attribute"); String name = attribute.getName(); Object value = attribute.getValue(); throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name cannot be null"), "Cannot invoke the setter of "+dClassName+ MethodUnion mu = (MethodUnion) dynamicProps.get(name); value = OptionConverter.toLevel((String) value, (Level) getAttribute(name)); Thread.currentThread().interrupt(); cat.error("FIXME", e); } catch(IllegalAccessException e) { cat.error("FIXME", e); } catch(RuntimeException e) { cat.error("FIXME", e); throw(new AttributeNotFoundException("Attribute " + name + " not found in " + this.getClass().getName()));
throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name"); return logger.getName(); } else if(attributeName.equals("priority")) { Level l = logger.getLevel(); if(l == null) { return null; return new ObjectName("log4j:"+attributeName ); } catch(MalformedObjectNameException e) { cat.error("Could not create ObjectName" + attributeName); } catch(RuntimeException e) { cat.error("Could not create ObjectName" + attributeName); throw(new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name"); MethodUnion mu = (MethodUnion) dynamicProps.get(attributeName); cat.debug("----name="+attributeName+", mu="+mu); throw(new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name"); if(attributeName.startsWith("appender="+appender.getName()+",layout")) { try { return new ObjectName("log4j:"+attributeName ); } catch(Exception e) { cat.error("attributeName", e); MethodUnion mu = (MethodUnion) dynamicProps.get(attributeName); throw(new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
@Override public double getSystemLoadAverage() throws MonitoringException { double result = 0; final MBeanServer mbeanServer = MBeanUtil.getMBeanServer(); try { result = (Double) mbeanServer.getAttribute(new ObjectName(JvmMBean.JVM_MBEAN_NAME), "SystemLoadAverage"); } 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; }
public Object getAttribute(String attributeName) throws AttributeNotFoundException, MBeanException, ReflectionException { // Check attributeName is not null to avoid NullPointerException later on if (attributeName == null) { throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name"); } MethodUnion mu = (MethodUnion) dynamicProps.get(attributeName); cat.debug("----name="+attributeName+", mu="+mu); if(mu != null && mu.readMethod != null) { try { return mu.readMethod.invoke(layout, null); } catch(Exception e) { return null; } } // If attributeName has not been recognized throw an AttributeNotFoundException throw(new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName)); }
/** * Sets the value of an attribute. * * @see DynamicMBean#setAttribute(Attribute) */ public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { // Set a logger's new level logging.trace("setAttribute(" + attribute + ")"); Log4jConfigurator cnf = Log4jConfigurator.getInstance(); try { cnf.setLoggerLevel(attribute.getName(), (String) attribute.getValue()); } catch (IllegalArgumentException e) { String msg = "Unknown attribute '" + attribute + "'"; logging.warn(msg, e); throw new AttributeNotFoundException(msg); } catch (ClassCastException e) { String msg = "Unexpected type of attribute value; expected " + String.class.getName() + " but got " + attribute.getValue().getClass().getName(); logging.warn(msg, e); throw new MBeanException(e, msg); } }
throw new RuntimeOperationsException( new IllegalArgumentException("Attribute cannot be null"), "Cannot invoke a setter of " + dClassName + " with null attribute"); String name = attribute.getName(); Object value = attribute.getValue(); throw new RuntimeOperationsException( new IllegalArgumentException("Attribute name cannot be null"), "Cannot invoke the setter of "+dClassName+ if (value instanceof String) { String s = (String) value; Level p = logger.getLevel(); if(s.equalsIgnoreCase("NULL")) { p = null; } else { p = OptionConverter.toLevel(s, p); logger.setLevel(p); throw(new AttributeNotFoundException("Attribute " + name + " not found in " + this.getClass().getName()));
@Override public synchronized void setAttribute(Attribute attribute) throws InvalidAttributeValueException, MBeanException, AttributeNotFoundException { try { switch (attribute.getName()) { case "enabled": middleware.enabled = (Boolean) attribute.getValue(); break; default: throw new AttributeNotFoundException("No such property: " + attribute.getName()); } } catch (RuntimeException e) { throw new MBeanException(e); } }
public Object getAttribute(String attributeName) throws AttributeNotFoundException, MBeanException, ReflectionException { // Check attributeName is not null to avoid NullPointerException later on if (attributeName == null) { throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute name cannot be null"), "Cannot invoke a getter of " + dClassName + " with null attribute name"); } log.debug("Called getAttribute with ["+attributeName+"]."); // Check for a recognized attributeName and call the corresponding getter if (attributeName.equals(THRESHOLD)) { return hierarchy.getThreshold(); } else if(attributeName.startsWith("logger")) { int k = attributeName.indexOf("%3D"); String val = attributeName; if(k > 0) { val = attributeName.substring(0, k)+'='+ attributeName.substring(k+3); } try { return new ObjectName("log4j:"+val); } catch(Exception e) { log.error("Could not create ObjectName" + val); } } // If attributeName has not been recognized throw an AttributeNotFoundException throw(new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName)); }
throw new AttributeNotFoundException( "ModelMBeanInfo is null"); if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("ModelMBeanInfo is: " + info); String attrName = attribute.getName(); Object attrValue = attribute.getValue(); throw new AttributeNotFoundException( String.format("Cannot find ModelMBeanAttributeInfo for attribute %s", attrName)); throw new AttributeNotFoundException( String.format("Attribute %s is not writable", attrName)); throw new AttributeNotFoundException( "MBean descriptor cannot be null"); if (logger.isEnabledFor(Logger.DEBUG)) throw new AttributeNotFoundException( String.format("Attribute descriptor for attribute %s cannot be null", attrName)); sendAttributeChangeNotification(new Attribute(attrName, oldValue), attribute); throw (MBeanException) x; else throw new MBeanException(x);
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { Interceptor interceptor = setters.get(attribute.getName()); if (interceptor == null) { throw new AttributeNotFoundException(attribute.getName()); } invoke(interceptor, new Object[]{attribute.getValue()}); }
/** {@inheritDoc} */ public void setAttribute(Attribute pAttribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { try { if (!attributeInfoMap.containsKey(pAttribute.getName())) { jolokiaMBeanServer.setAttribute(objectName, pAttribute); } else { String name = pAttribute.getName(); MBeanAttributeInfo info = attributeInfoMap.get(name); Object value; if (info instanceof OpenMBeanAttributeInfo) { value = fromJson(((OpenMBeanAttributeInfo) info).getOpenType(), (String) pAttribute.getValue()); } else { value = fromJson(info.getType(), (String) pAttribute.getValue()); } Attribute attr = new Attribute(name, value); jolokiaMBeanServer.setAttribute(objectName, attr); } } catch (InstanceNotFoundException e) { AttributeNotFoundException exp = new AttributeNotFoundException("MBean " + objectName + " not found for attribute " + pAttribute); exp.initCause(e); throw exp; } }
@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); } }
@Override public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { updateJmxCache(); synchronized(this) { Attribute a = attrCache.get(attribute); if (a == null) { throw new AttributeNotFoundException(attribute +" not found"); } if (LOG.isDebugEnabled()) { LOG.debug(attribute +": "+ a); } return a.getValue(); } }
/** Subclasses should override this to handle setAttribute( attr ). It will be called if no appropriate setter is found. */ protected void setAttributeManually(final Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException { throw new AttributeNotFoundException(attr.getName()); }
public void testSetAttribute() throws Exception { Map options = new HashMap(); options.put("foo", "bar"); MysqldResourceI mysqld = new MysqldResourceTestImpl(options); SimpleMysqldDynamicMBean myBean = new SimpleMysqldDynamicMBean(mysqld); try { myBean.setAttribute(new Attribute("bogus", "werid")); fail(); } catch (AttributeNotFoundException e) { assertTrue(e.getMessage(), e.getMessage().indexOf("bogus") >= 0); } }
@Override public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { MAttribute a = this.attributes.get(name); if(null == a) { throw new AttributeNotFoundException("Attribute '" + name + "' not found in '" + bean.getClass() + "'"); } try{ Object value = a.valued().getValue(bean); if(a.isOpen()) { value = MConverts.convert(value, a.getOpenType()); } return value; }catch(ReflectException e) { throw new ReflectionException(e); }catch(Exception e) { throw new MBeanException(e); } }
@Override public final AttributeNotFoundException invalidMBeanAttribute(final String attrName) { final AttributeNotFoundException result = new AttributeNotFoundException(String.format(invalidMBeanAttribute$str(), attrName)); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String filePasswordUsageMessage = "PBOX00102: Write a password in opaque form to a file for use with the FilePassword accessor\n\nUsage: FilePassword salt count password password-file\n salt : an 8 char sequence for PBEKeySpec\n count : iteration count for PBEKeySpec\n password : the clear text password to write\n password-file : the path to the file to write the password to\n";