Package org.springframework.jmx.export.metadata

Examples of org.springframework.jmx.export.metadata.ManagedResource


    org.springframework.jmx.export.annotation.ManagedResource ann =
        beanClass.getAnnotation(org.springframework.jmx.export.annotation.ManagedResource.class);
    if (ann == null) {
      return null;
    }
    ManagedResource managedResource = new ManagedResource();
    AnnotationBeanUtils.copyPropertiesToBean(ann, managedResource, this.embeddedValueResolver);
    if (!"".equals(ann.value()) && !StringUtils.hasLength(managedResource.getObjectName())) {
      String value = ann.value();
      if (this.embeddedValueResolver != null) {
        value = this.embeddedValueResolver.resolveStringValue(value);
      }
      managedResource.setObjectName(value);
    }
    return managedResource;
  }
View Full Code Here


   * Reads managed resource description from the source level metadata.
   * Returns an empty <code>String</code> if no description can be found.
   */
  @Override
  protected String getDescription(Object managedBean, String beanKey) {
    ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean));
    return (mr != null ? mr.getDescription() : "");
  }
View Full Code Here

   * <code>persistPolicy</code>, <code>persistPeriod</code>, <code>persistLocation</code>
   * and <code>persistName</code> descriptor fields if they are present in the metadata.
   */
  @Override
  protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) {
    ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean));
    if (mr == null) {
      throw new InvalidMetadataException(
          "No ManagedResource attribute found for class: " + getClassToExpose(managedBean));
    }

    applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit());

    if (mr.isLog()) {
      desc.setField(FIELD_LOG, "true");
    }
    if (StringUtils.hasLength(mr.getLogFile())) {
      desc.setField(FIELD_LOG_FILE, mr.getLogFile());
    }

    if (StringUtils.hasLength(mr.getPersistPolicy())) {
      desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy());
    }
    if (mr.getPersistPeriod() >= 0) {
      desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod()));
    }
    if (StringUtils.hasLength(mr.getPersistName())) {
      desc.setField(FIELD_PERSIST_NAME, mr.getPersistName());
    }
    if (StringUtils.hasLength(mr.getPersistLocation())) {
      desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation());
    }
  }
View Full Code Here

      throw new IllegalArgumentException(
              "MetadataNamingStrategy does not support JDK dynamic proxies - " +
                      "export the target beans directly or use CGLIB proxies instead");
    }
    Class managedClass = JmxUtils.getClassToExpose(managedBean);
    ManagedResource mr = this.attributeSource.getManagedResource(managedClass);

    // Check that the managed resource attribute has been specified.
    if (mr == null) {
      throw new MalformedObjectNameException("Your bean class [" + managedBean.getClass().getName() +
          "] must be marked with a valid ManagedResource attribute when using MetadataNamingStrategy");
    }

    // Check that an object name has been specified.
    String objectName = mr.getObjectName();

    if (!StringUtils.hasText(objectName)) {
      throw new MalformedObjectNameException(
          "You must specify an ObjectName for class [" + managedBean.getClass().getName() + "]");
    }
View Full Code Here

  public ManagedResource getManagedResource(Class beanClass) throws InvalidMetadataException {
    Annotation ann = beanClass.getAnnotation(org.springframework.jmx.export.annotation.ManagedResource.class);
    if (ann == null) {
      return null;
    }
    ManagedResource managedResource = new ManagedResource();
    AnnotationBeanUtils.copyPropertiesToBean(ann, managedResource);
    return managedResource;
  }
View Full Code Here

  /**
   * Reads managed resource description from the source level metadata.
   * Returns an empty <code>String</code> if no description can be found.
   */
  protected String getDescription(Object managedBean, String beanKey) {
    ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean));
    return (mr != null ? mr.getDescription() : "");
  }
View Full Code Here

   * to the MBean descriptor. Specifically, adds the <code>currencyTimeLimit</code>,
   * <code>persistPolicy</code>, <code>persistPeriod</code>, <code>persistLocation</code>
   * and <code>persistName</code> descriptor fields if they are present in the metadata.
   */
  protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) {
    ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean));
    if (mr == null) {
      throw new InvalidMetadataException(
          "No ManagedResource attribute found for class: " + getClassToExpose(managedBean));
    }

    applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit());

    // Do not use Boolean.toString(boolean) here, to preserve JDK 1.3 compatibility!
    if (mr.isLog()) {
      desc.setField(FIELD_LOG, "true");
    }
    if (StringUtils.hasLength(mr.getLogFile())) {
      desc.setField(FIELD_LOG_FILE, mr.getLogFile());
    }

    if (StringUtils.hasLength(mr.getPersistPolicy())) {
      desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy());
    }
    if (mr.getPersistPeriod() >= 0) {
      desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod()));
    }
    if (StringUtils.hasLength(mr.getPersistName())) {
      desc.setField(FIELD_PERSIST_NAME, mr.getPersistName());
    }
    if (StringUtils.hasLength(mr.getPersistLocation())) {
      desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation());
    }
  }
View Full Code Here

   * Reads the <code>ObjectName</code> from the source-level metadata associated
   * with the managed resource's <code>Class</code>.
   */
  public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException {
    Class managedClass = AopUtils.getTargetClass(managedBean);
    ManagedResource mr = this.attributeSource.getManagedResource(managedClass);

    // Check that an object name has been specified.
    if (mr != null && StringUtils.hasText(mr.getObjectName())) {
      return ObjectNameManager.getInstance(mr.getObjectName());
    }
    else {
      try {
        return ObjectNameManager.getInstance(beanKey);
      }
View Full Code Here

  /**
   * Reads managed resource description from the source level metadata.
   * Returns an empty <code>String</code> if no description can be found.
   */
  protected String getDescription(Object managedBean, String beanKey) {
    ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean));
    return (mr != null ? mr.getDescription() : "");
  }
View Full Code Here

   * to the MBean descriptor. Specifically, adds the <code>currencyTimeLimit</code>,
   * <code>persistPolicy</code>, <code>persistPeriod</code>, <code>persistLocation</code>
   * and <code>persistName</code> descriptor fields if they are present in the metadata.
   */
  protected void populateMBeanDescriptor(Descriptor desc, Object managedBean, String beanKey) {
    ManagedResource mr = this.attributeSource.getManagedResource(getClassToExpose(managedBean));
    if (mr == null) {
      throw new InvalidMetadataException(
          "No ManagedResource attribute found for class: " + getClassToExpose(managedBean));
    }

    applyCurrencyTimeLimit(desc, mr.getCurrencyTimeLimit());

    if (mr.isLog()) {
      desc.setField(FIELD_LOG, "true");
    }
    if (StringUtils.hasLength(mr.getLogFile())) {
      desc.setField(FIELD_LOG_FILE, mr.getLogFile());
    }

    if (StringUtils.hasLength(mr.getPersistPolicy())) {
      desc.setField(FIELD_PERSIST_POLICY, mr.getPersistPolicy());
    }
    if (mr.getPersistPeriod() >= 0) {
      desc.setField(FIELD_PERSIST_PERIOD, Integer.toString(mr.getPersistPeriod()));
    }
    if (StringUtils.hasLength(mr.getPersistName())) {
      desc.setField(FIELD_PERSIST_NAME, mr.getPersistName());
    }
    if (StringUtils.hasLength(mr.getPersistLocation())) {
      desc.setField(FIELD_PERSIST_LOCATION, mr.getPersistLocation());
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.jmx.export.metadata.ManagedResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.