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+ Level l = OptionConverter.toLevel((String) value, hierarchy.getThreshold()); hierarchy.setThreshold(l);
throw ex.getTargetException(); throw ex.getTargetError(); RuntimeException rex = ex.getTargetException(); if (rex instanceof RuntimeMBeanException) { throw ((RuntimeMBeanException) rex).getTargetException(); throw ((RuntimeErrorException) rex).getTargetError();
return; } catch (RuntimeOperationsException e) { logger.warn(e.getMessage(), e);// failed to send notification
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 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));
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)); }
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()));
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)); }
/** * Enables the to get the values of several attributes of the Dynamic MBean. */ public AttributeList getAttributes(String[] attributeNames) { // Check attributeNames is not null to avoid NullPointerException later on if (attributeNames == null) { throw new RuntimeOperationsException( new IllegalArgumentException("attributeNames[] cannot be null"), "Cannot invoke a getter of " + dClassName); } AttributeList resultList = new AttributeList(); // if attributeNames is empty, return an empty result list if (attributeNames.length == 0) return resultList; // build the result attribute list for (int i=0 ; i<attributeNames.length ; i++){ try { Object value = getAttribute((String) attributeNames[i]); resultList.add(new Attribute(attributeNames[i],value)); } catch (JMException e) { e.printStackTrace(); } catch (RuntimeException e) { e.printStackTrace(); } } return(resultList); }
throw new RuntimeOperationsException( new IllegalArgumentException("AttributeList attributes cannot be null"), "Cannot invoke a setter of " + dClassName); AttributeList resultList = new AttributeList(); if (attributes.isEmpty()) return resultList; for (Iterator i = attributes.iterator(); i.hasNext();) { Attribute attr = (Attribute) i.next(); try { setAttribute(attr); String name = attr.getName(); Object value = getAttribute(name); resultList.add(new Attribute(name,value)); } catch(JMException e) { e.printStackTrace();
ObjectName loaderName = new ObjectName("DefaultDomain:service=JMXPatchedClassLoader"); Object agentInstance = agentType.newInstance(); String compositeName = new String(adminProps.getProperty("name", "Adaptor:name=html") + ",port=" + adminProps.getProperty("port", "8082")); ObjectName agentName = new ObjectName(compositeName); server.registerMBean(agentInstance, agentName); java.lang.reflect.Method startMethod = agentType.getMethod("start", null); throw e.getTargetException(); } catch (MBeanException e) { throw e.getTargetException(); } catch (RuntimeMBeanException e) { throw e.getTargetException(); } catch (javax.management.RuntimeErrorException e) { throw e.getTargetError(); } catch (Exception e) { throw e;
ObjectName mBeanName = new ObjectName(mBean); " from the UI list due to: " + e.getMessage()); } catch (AttributeNotFoundException e) { log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: " + e.getMessage()); } catch (UnmarshalException e) { log.error("Removed the attribute " + info.getName() + " of " + mBean + } catch (RuntimeOperationsException e) { log.error("Removed the attribute " + info.getName() + " of " + mBean + " from the UI list due to: " + e.getMessage());
ObjectName containerName = new ObjectName(":service=Container,jndiName="+jndiName); Class homeClass = (Class) server.invoke(containerName, "getHome", null, null); buffer.append("\nHome class = "+homeClass); e = roe.getTargetException();
@Override public AttributeList setAttributes(AttributeList attributes) { if (attributes == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute list cannot be null.")); Logger logger = getLogger(); AttributeList list = new AttributeList(); for (Iterator i = attributes.iterator(); i.hasNext();) { Attribute attribute = (Attribute) i.next(); String name = attribute.getName(); try { setAttribute(attribute); list.add(attribute); } catch (Exception x) { if (logger.isEnabledFor(Logger.TRACE)) logger.trace("setAttribute for attribute " + name + " failed", x); // And go on with the next one } } return list; }
throw new RuntimeOperationsException(new IllegalArgumentException("attribute cannot be null")); try m = attributes[resolver.lookup(attribute.getName()).intValue()].setter; m.invoke(resource, new Object[]{attribute.getValue()}); throw new AttributeNotFoundException("Writable attribute '" + attribute.getName() + "' not found"); throw new AttributeNotFoundException("Writable attribute '" + attribute.getName() + "' not found"); throw new MBeanException((Exception) t, "Exception in MBean when setting attribute '" + attribute.getName() + "'"); throw new RuntimeErrorException((Error) t, "Error in MBean when setting attribute '" + attribute.getName() + "'"); throw new RuntimeErrorException(e, "Error in AttributeProvider for setting '" + attribute.getName() + "'");
InvalidAttributeValueException, MBeanException, ReflectionException { if (attribute == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute cannot be null.")); 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)); sendAttributeChangeNotification(new Attribute(attrName, oldValue), attribute); throw (MBeanException) x; else throw new MBeanException(x);
@Override public AttributeList setAttributes(AttributeList attributes) { // validation from javax.management.modelmbean.RequiredModelMBean if (attributes == null) throw new RuntimeOperationsException(new IllegalArgumentException("attributes must not be null"), "Exception occurred trying to set attributes of a " + getClass().getSimpleName()); AttributeList list = new AttributeList(); for (Attribute attribute : attributes.asList()) { try { JmxAttribute attr = getJmxMetadata().getAttribute(attribute.getName()); attr.set(getManagedResource(), attribute.getValue()); list.add(attribute); } catch (AttributeNotFoundException ignored) { } catch (ReflectionException ignored) { } catch (InvalidAttributeValueException ignored) { } } return list; }
@Override public void sendAttributeChangeNotification(Attribute oldAttribute, Attribute newAttribute) throws MBeanException, RuntimeOperationsException { if (oldAttribute == null || newAttribute == null) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute cannot be null.")); if (!oldAttribute.getName().equals(newAttribute.getName())) throw new RuntimeOperationsException(new IllegalArgumentException( "Attribute names cannot be different.")); // TODO: the source must be the object name of the MBean if the listener was registered through // MBeanServer Object oldValue = oldAttribute.getValue(); AttributeChangeNotification n = new AttributeChangeNotification(this, 1, System.currentTimeMillis(), "Attribute value changed", oldAttribute.getName(), oldValue == null ? null : oldValue.getClass().getName(), oldValue, newAttribute.getValue()); sendAttributeChangeNotification(n); }