List of usage examples for javax.management InvalidAttributeValueException InvalidAttributeValueException
public InvalidAttributeValueException()
From source file:org.echocat.jemoni.jmx.support.CacheDynamicMBean.java
@Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { final String attributeName = attribute.getName(); final Object value = attribute.getValue(); if ("maximumLifetime".equals(attributeName)) { if (value != null && !(value instanceof String)) { throw new InvalidAttributeValueException(); }//ww w .j av a 2s . com cast(LimitedCache.class).setMaximumLifetime( value != null && !value.toString().trim().isEmpty() ? new Duration(value.toString()) : null); } else if ("capacity".equals(attributeName)) { if (value != null && !(value instanceof Number)) { throw new InvalidAttributeValueException(); } cast(LimitedCache.class).setCapacity(value != null ? ((Number) value).longValue() : null); } else if ("producingType".equals(attributeName)) { if (value != null && !(value instanceof String)) { throw new InvalidAttributeValueException(); } final ProducingType producingType; if (value == null || value.toString().trim().isEmpty()) { producingType = ProducingType.DEFAULT; } else { try { producingType = ProducingType.valueOf(value.toString().trim()); } catch (IllegalArgumentException ignored) { throw new InvalidAttributeValueException("Illegal value: " + value + ". Possible values: " + StringUtils.join(ProducingType.values(), ", ")); } } cast(ProducingTypeEnabledCache.class).setProducingType(producingType); } else { throw new AttributeNotFoundException(); } }