コード例 #1
0
  /* ------------------------------------------------------------ */
  public AttributeList setAttributes(AttributeList attrs) {
    log.debug("setAttributes");

    AttributeList results = new AttributeList(attrs.size());
    Iterator iter = attrs.iterator();
    while (iter.hasNext()) {
      try {
        Attribute attr = (Attribute) iter.next();
        setAttribute(attr);
        results.add(new Attribute(attr.getName(), getAttribute(attr.getName())));
      } catch (Exception e) {
        log.warn(LogSupport.EXCEPTION, e);
      }
    }
    return results;
  }
コード例 #2
0
  /* ------------------------------------------------------------ */
  public void setAttribute(Attribute attr)
      throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException,
          ReflectionException {
    if (attr == null) return;

    if (log.isDebugEnabled()) log.debug("setAttribute " + attr.getName() + "=" + attr.getValue());
    Method setter = (Method) _setter.get(attr.getName());
    if (setter == null) throw new AttributeNotFoundException(attr.getName());
    try {
      Object o = _object;
      if (setter.getDeclaringClass().isInstance(this)) o = this;
      setter.invoke(o, new Object[] {attr.getValue()});
    } catch (IllegalAccessException e) {
      log.warn(LogSupport.EXCEPTION, e);
      throw new AttributeNotFoundException(e.toString());
    } catch (InvocationTargetException e) {
      log.warn(LogSupport.EXCEPTION, e);
      throw new ReflectionException((Exception) e.getTargetException());
    }
  }