List of usage examples for javax.management AttributeNotFoundException AttributeNotFoundException
public AttributeNotFoundException(String message)
From source file:net.lightbody.bmp.proxy.jetty.util.jmx.ModelMBeanImpl.java
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { if (log.isDebugEnabled()) log.debug("getAttribute " + name); Method getter = (Method) _getter.get(name); if (getter == null) throw new AttributeNotFoundException(name); try {/* w ww . ja va 2s .co m*/ Object o = _object; if (getter.getDeclaringClass().isInstance(this)) o = this; return getter.invoke(o, (java.lang.Object[]) null); } 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()); } }
From source file:net.lightbody.bmp.proxy.jetty.util.jmx.ModelMBeanImpl.java
public void setAttribute(Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { if (attr == null) return;//from w w w .j ava 2s. c o m 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()); } }
From source file:org.archive.crawler.admin.CrawlJob.java
public Object getAttribute(String attribute_name) throws AttributeNotFoundException { if (attribute_name == null) { throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name cannot be null"), "Cannot call getAttribute with null attribute name"); }//ww w . ja v a 2 s . com // If no controller, we can't do any work in here. if (this.controller == null) { throw new RuntimeOperationsException(new NullPointerException("Controller is null"), "Controller is null"); } // Is it a bdbje attribute? if (this.bdbjeAttributeNameList.contains(attribute_name)) { try { return this.bdbjeMBeanHelper.getAttribute(this.controller.getBdbEnvironment(), attribute_name); } catch (MBeanException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } } // Is it a crawl-order attribute? if (attribute_name.startsWith(this.controller.getOrder().getAbsoluteName())) { return getCrawlOrderAttribute(attribute_name); } if (!ATTRIBUTE_LIST.contains(attribute_name)) { throw new AttributeNotFoundException("Attribute " + attribute_name + " is unimplemented."); } // The pattern in the below is to match an attribute and when found // do a return out of if clause. Doing it this way, I can fall // on to the AttributeNotFoundException for case where we've an // attribute but no handler. if (attribute_name.equals(STATUS_ATTR)) { return getCrawlStatus(); } if (attribute_name.equals(NAME_ATTR)) { return getJobName(); } if (attribute_name.equals(UID_ATTR)) { return getUID(); } if (attribute_name.equals(TOTAL_DATA_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().totalBytesCrawled()); } if (attribute_name.equals(CRAWL_TIME_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().getCrawlerTotalElapsedTime() / 1000); } if (attribute_name.equals(CURRENT_DOC_RATE_ATTR)) { return new Double(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().currentProcessedDocsPerSec()); } if (attribute_name.equals(DOC_RATE_ATTR)) { return new Double(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().processedDocsPerSec()); } if (attribute_name.equals(KB_RATE_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().currentProcessedKBPerSec()); } if (attribute_name.equals(CURRENT_KB_RATE_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().processedKBPerSec()); } if (attribute_name.equals(THREAD_COUNT_ATTR)) { return new Integer(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().activeThreadCount()); } if (attribute_name.equals(FRONTIER_SHORT_REPORT_ATTR)) { return getFrontierOneLine(); } if (attribute_name.equals(THREADS_SHORT_REPORT_ATTR)) { return getThreadOneLine(); } if (attribute_name.equals(DISCOVERED_COUNT_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().totalCount()); } if (attribute_name.equals(DOWNLOAD_COUNT_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().successfullyFetchedCount()); } throw new AttributeNotFoundException("Attribute " + attribute_name + " not found."); }
From source file:com.cyberway.issue.crawler.admin.CrawlJob.java
public Object getAttribute(String attribute_name) throws AttributeNotFoundException { if (attribute_name == null) { throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name cannot be null"), "Cannot call getAttribute with null attribute name"); }// w ww .ja v a 2 s . c o m // If no controller, we can't do any work in here. if (this.controller == null) { throw new RuntimeOperationsException(new NullPointerException("Controller is null"), "Controller is null"); } // Is it a bdbje attribute? if (this.bdbjeAttributeNameList.contains(attribute_name)) { try { return this.bdbjeMBeanHelper.getAttribute(this.controller.getBdbEnvironment(), attribute_name); } catch (MBeanException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } } // Is it a crawl-order attribute? if (attribute_name.startsWith(this.controller.getOrder().getAbsoluteName())) { return getCrawlOrderAttribute(attribute_name); } if (!ATTRIBUTE_LIST.contains(attribute_name)) { throw new AttributeNotFoundException("Attribute " + attribute_name + " is unimplemented."); } // The pattern in the below is to match an attribute and when found // do a return out of if clause. Doing it this way, I can fall // on to the AttributeNotFoundException for case where we've an // attribute but no handler. if (attribute_name.equals(STATUS_ATTR)) { return getCrawlStatus(); } if (attribute_name.equals(NAME_ATTR)) { return getJobName(); } if (attribute_name.equals(UID_ATTR)) { return getUID(); } if (attribute_name.equals(TOTAL_DATA_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().totalBytesWritten()); } if (attribute_name.equals(CRAWL_TIME_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().getCrawlerTotalElapsedTime() / 1000); } if (attribute_name.equals(CURRENT_DOC_RATE_ATTR)) { return new Double(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().currentProcessedDocsPerSec()); } if (attribute_name.equals(DOC_RATE_ATTR)) { return new Double(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().processedDocsPerSec()); } if (attribute_name.equals(KB_RATE_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().currentProcessedKBPerSec()); } if (attribute_name.equals(CURRENT_KB_RATE_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().processedKBPerSec()); } if (attribute_name.equals(THREAD_COUNT_ATTR)) { return new Integer(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().activeThreadCount()); } if (attribute_name.equals(FRONTIER_SHORT_REPORT_ATTR)) { return getFrontierOneLine(); } if (attribute_name.equals(THREADS_SHORT_REPORT_ATTR)) { return getThreadOneLine(); } if (attribute_name.equals(DISCOVERED_COUNT_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().totalCount()); } if (attribute_name.equals(DOWNLOAD_COUNT_ATTR)) { return new Long(this.controller == null && this.controller.getStatistics() != null ? 0 : this.controller.getStatistics().successfullyFetchedCount()); } throw new AttributeNotFoundException("Attribute " + attribute_name + " not found."); }
From source file:org.archive.crawler.admin.CrawlJob.java
protected void setAttributeInternal(Attribute attribute) throws AttributeNotFoundException { // Is it a crawl order attribute? CrawlOrder order = this.getController().getOrder(); String attName = attribute.getName(); if (attName.startsWith(order.getAbsoluteName())) { try {/*from w w w. j a v a 2s. c om*/ setCrawlOrderAttribute(attribute.getName().substring(order.getAbsoluteName().length()), order, attribute); } catch (NullPointerException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (AttributeNotFoundException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (MBeanException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (ReflectionException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (InvalidAttributeValueException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } return; } // Is it a bdbje attribute? if (this.bdbjeAttributeNameList.contains(attName)) { try { this.bdbjeMBeanHelper.setAttribute(this.controller.getBdbEnvironment(), attribute); } catch (AttributeNotFoundException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } catch (InvalidAttributeValueException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } return; } // Else, we don't know how to handle this attribute. throw new AttributeNotFoundException("Attribute " + attName + " can not be set."); }
From source file:com.cyberway.issue.crawler.admin.CrawlJob.java
public void setAttribute(Attribute attribute) throws AttributeNotFoundException { // Is it a crawl order attribute? CrawlOrder order = this.getController().getOrder(); String attName = attribute.getName(); if (attName.startsWith(order.getAbsoluteName())) { try {// w w w .j a va 2 s . com setCrawlOrderAttribute(attribute.getName().substring(order.getAbsoluteName().length()), order, attribute); } catch (NullPointerException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (AttributeNotFoundException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (MBeanException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (ReflectionException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } catch (InvalidAttributeValueException e) { logger.log(Level.SEVERE, "Failed set of " + attName, e); } return; } // Is it a bdbje attribute? if (this.bdbjeAttributeNameList.contains(attName)) { try { this.bdbjeMBeanHelper.setAttribute(this.controller.getBdbEnvironment(), attribute); } catch (AttributeNotFoundException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } catch (InvalidAttributeValueException e) { throw new RuntimeOperationsException(new RuntimeException(e)); } return; } // Else, we don't know how to handle this attribute. throw new AttributeNotFoundException("Attribute " + attName + " can not be set."); }
From source file:com.cyberway.issue.crawler.Heritrix.java
public Object getAttribute(String attribute_name) throws AttributeNotFoundException { if (attribute_name == null) { throw new RuntimeOperationsException(new IllegalArgumentException("Attribute name cannot be null"), "Cannot call getAttribute with null attribute name"); }//from w w w .j av a 2 s.c o m if (!Heritrix.ATTRIBUTE_LIST.contains(attribute_name)) { throw new AttributeNotFoundException("Attribute " + attribute_name + " is unimplemented."); } // The pattern in the below is to match an attribute and when found // do a return out of if clause. Doing it this way, I can fall // on to the AttributeNotFoundException for case where we've an // attribute but no handler. if (attribute_name.equals(STATUS_ATTR)) { return getStatus(); } if (attribute_name.equals(VERSION_ATTR)) { return getVersion(); } if (attribute_name.equals(ISRUNNING_ATTR)) { return new Boolean(this.getJobHandler().isRunning()); } if (attribute_name.equals(ISCRAWLING_ATTR)) { return new Boolean(this.getJobHandler().isCrawling()); } if (attribute_name.equals(ALERTCOUNT_ATTR)) { return new Integer(getAlertsCount()); } if (attribute_name.equals(NEWALERTCOUNT_ATTR)) { return new Integer(getNewAlertsCount()); } if (attribute_name.equals(CURRENTJOB_ATTR)) { if (this.getJobHandler().isCrawling()) { return this.getJobHandler().getCurrentJob().getJmxJobName(); } return null; } throw new AttributeNotFoundException("Attribute " + attribute_name + " not found."); }
From source file:com.cyberway.issue.crawler.Heritrix.java
public void setAttribute(Attribute attribute) throws AttributeNotFoundException { throw new AttributeNotFoundException("No attribute can be set in " + "this MBean"); }