Package org.springframework.jmx.export.metadata

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


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


    }

    @SuppressWarnings("unchecked")
    @Override
    public ManagedResource getManagedResource(Class beanClass) throws InvalidMetadataException {
        ManagedResource resource = super.getManagedResource(beanClass);
        if (resource != null && appName != null) {
            String objectName = resource.getObjectName();
            objectName += "." + appName;
            resource.setObjectName(objectName);
        }
        return resource;
    }
View Full Code Here

   * Reads managed resource description from the source level metadata.
   * Returns an empty {@code String} 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 persistPeriod}, {@code persistLocation}
   * and {@code persistName} 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

    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

   * with the managed resource's {@code Class}.
   */
  @Override
  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.
   */
  @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

    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);
    if (!"".equals(ann.value()) && !StringUtils.hasLength(managedResource.getObjectName())) {
      managedResource.setObjectName(ann.value());
    }
    return managedResource;
  }
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

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.