public Object getAttribute(String attribute)
      throws ReflectionException, MBeanException, AttributeNotFoundException {
    Object value = null;
    if (attribute.compareToIgnoreCase("capacity") == 0) {
      value = new Integer(capacity);
    } else if (attribute.compareToIgnoreCase("length") == 0) {
      value = new Integer(queue.size());
    } else {
      throw new AttributeNotFoundException(attribute);
    }
    return value;
  }

  public AttributeList getAttributes(java.lang.String[] attributes) {
    AttributeList result = new AttributeList();
    for (int i = 0; i < attributes.length; i++) {
      try {
        result.add(getAttribute(attributes[i]));
      } catch (AttributeNotFoundException x) {
        System.out.println("No such attribute: " + attributes[i]);
      } catch (Exception x) {
        x.printStackTrace();
        System.exit(-1);
      }
    }
    return result;
  }


  public void setAttribute(Attribute attribute) 
      throws ReflectionException, MBeanException, InvalidAttributeValueException, AttributeNotFoundException {
    if (attribute.getName().compareToIgnoreCase("capacity") == 0) {
      capacity = ((Integer) attribute.getValue()).intValue();
    } else if (attribute.getName().compareToIgnoreCase("length") == 0) {
      throw new MBeanException(new IllegalArgumentException("Attribute size is read-only"));
    } else {
      throw new AttributeNotFoundException(attribute.getName());
    }
  }

  public AttributeList setAttributes(AttributeList attributes) {
    AttributeList attributesSet = new AttributeList();
    ListIterator li = attributes.listIterator();
    while (li.hasNext()) {
      try {
        Attribute a = (Attribute) li.next();
        setAttribute(a);
        attributesSet.add(a);
      } catch (AttributeNotFoundException x) {
        System.out.println();
      } catch (MBeanException x) {
        System.out.println();
      } catch (Exception x) {
        x.printStackTrace();
        System.exit(-1);
      }
    }
    return attributesSet;
  }