List of usage examples for javax.management AttributeNotFoundException AttributeNotFoundException
public AttributeNotFoundException(String message)
From source file:org.jolokia.converter.json.CompositeDataExtractor.java
/** {@inheritDoc} */ @SuppressWarnings("PMD.PreserveStackTrace") public Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts, boolean jsonify) throws AttributeNotFoundException { CompositeData cd = (CompositeData) pValue; String pathPart = pPathParts.isEmpty() ? null : pPathParts.pop(); if (pathPart != null) { try {// ww w. ja v a 2 s .co m return pConverter.extractObject(cd.get(pathPart), pPathParts, jsonify); } catch (InvalidKeyException exp) { return pConverter.getValueFaultHandler() .handleException(new AttributeNotFoundException("Invalid path '" + pathPart + "'")); } } else { return jsonify ? extractCompleteCdAsJson(pConverter, cd, pPathParts) : cd; } }
From source file:org.cleverbus.core.throttling.JmxThrottlingConfiguration.java
@Override public Object getAttribute(String attrName) throws AttributeNotFoundException, MBeanException, ReflectionException { Assert.notNull(attrName, "attrName must not be null"); // attr name: systemName . serviceName String[] parts = StringUtils.split(attrName, ThrottleScope.THROTTLE_SEPARATOR); if (parts.length != 2) { throw new AttributeNotFoundException( "attribute name is not in expected format: 'systemName . serviceName'"); }//from w w w . j ava 2 s . c o m ThrottleScope throttleScope = new ThrottleScope(parts[0], parts[1]); ThrottleProps throttleProps = configuration.getProperties().get(throttleScope); if (throttleProps == null) { throw new AttributeNotFoundException("There is no throttling property for '" + throttleScope + "'"); } return throttleProps.toHumanString(); }
From source file:org.jolokia.converter.json.CollectionExtractor.java
private Object extractWithPath(ObjectToJsonConverter pConverter, Collection pCollection, Stack<String> pPathParts, boolean pJsonify, String pPathPart, int pLength) throws AttributeNotFoundException { try {//from w ww . j av a 2 s. co m int idx = Integer.parseInt(pPathPart); return pConverter.extractObject(getElement(pCollection, idx, pLength), pPathParts, pJsonify); } catch (NumberFormatException exp) { ValueFaultHandler faultHandler = pConverter.getValueFaultHandler(); return faultHandler.handleException( new AttributeNotFoundException("Index '" + pPathPart + "' is not numeric for accessing list")); } catch (IndexOutOfBoundsException exp) { ValueFaultHandler faultHandler = pConverter.getValueFaultHandler(); return faultHandler.handleException(new AttributeNotFoundException( "Index '" + pPathPart + "' is out-of-bound for a list of size " + pLength)); } }
From source file:org.hyperic.hq.plugin.weblogic.jmx.AttributeGetter.java
public Object getAttribute(MBeanServer server, String attrName) throws InstanceNotFoundException, ReflectionException, AttributeNotFoundException { long timeNow = System.currentTimeMillis(); if ((timeNow - this.timestamp) > this.expire) { AttributeList attrList;//ww w. jav a2 s .c o m if (log.isDebugEnabled()) { log.debug("server.getAttributes(" + this.name + ", " + Arrays.asList(this.attrs) + ")"); } attrList = server.getAttributes(this.name, this.attrs); if (attrList == null) { throw new AttributeNotFoundException(this.name.toString()); } for (Iterator it = attrList.iterator(); it.hasNext();) { Attribute attr = (Attribute) it.next(); this.values.put(attr.getName(), attr.getValue()); } this.timestamp = timeNow; } Object value = this.values.get(attrName); if (value == null) { throw new AttributeNotFoundException(attrName); } return value; }
From source file:org.cleverbus.core.alerts.AlertsJmxConfiguration.java
private AlertInfo getAlert(String attrName) throws AttributeNotFoundException { String alertId;/*w w w. ja va2 s.co m*/ if (StringUtils.endsWith(attrName, ENABLE_SUFFIX)) { alertId = StringUtils.substringBefore(attrName, ENABLE_SUFFIX); } else if (StringUtils.endsWith(attrName, LIMIT_SUFFIX)) { alertId = StringUtils.substringBefore(attrName, LIMIT_SUFFIX); } else { throw new AttributeNotFoundException("attribute name is not in expected format"); } AlertInfo alert = configuration.findAlert(alertId); if (alert == null) { throw new AttributeNotFoundException("There is no alert for id '" + alertId + "'"); } return alert; }
From source file:org.cleverbus.core.throttling.JmxThrottlingConfiguration.java
@Override public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { Assert.notNull(attribute, "attribute must not be null"); // attr name: systemName . serviceName String attrName = attribute.getName(); String[] nameParts = StringUtils.split(attrName, ThrottleScope.THROTTLE_SEPARATOR); if (nameParts.length != 2) { throw new AttributeNotFoundException( "attribute name is not in expected format: 'systemName . serviceName'"); }// w w w . ja v a 2 s . c o m // attr value: limit / interval String attrValue = (String) attribute.getValue(); String[] valueParts = StringUtils.split(attrValue, ThrottleProps.PROP_VALUE_SEPARATOR); if (valueParts.length != 2) { throw new InvalidAttributeValueException( "attribute value is not in expected format: 'limit / interval'"); } configuration.addProperty(nameParts[0], nameParts[1], Integer.valueOf(valueParts[1]), Integer.valueOf(valueParts[0])); }
From source file:com.zavakid.mushroom.impl.MetricsSourceAdapter.java
@Override public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { updateJmxCache();//from ww w. ja v a 2 s .c o m synchronized (this) { Attribute a = attrCache.get(attribute); if (a == null) { throw new AttributeNotFoundException(attribute + " not found"); } if (LOG.isDebugEnabled()) { LOG.debug(attribute + ": " + a.getName() + "=" + a.getValue()); } return a.getValue(); } }
From source file:org.jolokia.converter.json.simplifier.SimplifierExtractor.java
private Object extractWithPath(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts, boolean jsonify, String pPath, ValueFaultHandler pFaultHandler) throws AttributeNotFoundException { AttributeExtractor<T> extractor = extractorMap.get(pPath); if (extractor == null) { return pFaultHandler.handleException( new AttributeNotFoundException("Illegal path element " + pPath + " for object " + pValue)); }// w w w. ja v a2 s.c om try { Object attributeValue = extractor.extract((T) pValue); return pConverter.extractObject(attributeValue, pPathParts, jsonify); } catch (AttributeExtractor.SkipAttributeException e) { return pFaultHandler.handleException( new AttributeNotFoundException("Illegal path element " + pPath + " for object " + pValue)); } }
From source file:org.jolokia.converter.json.MapExtractor.java
private Object extractMapValueWithPath(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts, boolean jsonify, Map<Object, Object> pMap, String pPathParth) throws AttributeNotFoundException { for (Map.Entry entry : pMap.entrySet()) { // We dont access the map via a lookup since the key // are potentially object but we have to deal with string // representations if (pPathParth.equals(entry.getKey().toString())) { return pConverter.extractObject(entry.getValue(), pPathParts, jsonify); }/*from w w w. j av a2s. c o m*/ } ValueFaultHandler faultHandler = pConverter.getValueFaultHandler(); return faultHandler.handleException(new AttributeNotFoundException( "Map key '" + pPathParth + "' is unknown for map " + trimString(pValue.toString()))); }
From source file:com.joyent.manta.http.PoolStatsMBean.java
@Override public Object getAttribute(final String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { updatePoolStats();/*from w w w . j av a 2s .com*/ Integer result = getAttributeFromPoolStats(attribute, this.stats); if (result == null) { String msg = String.format("Can't find MBean attribute: %s", attribute); throw new AttributeNotFoundException(msg); } return result; }