当前位置: 首页>>代码示例>>Java>>正文


Java ManagedResource类代码示例

本文整理汇总了Java中org.springframework.jmx.export.metadata.ManagedResource的典型用法代码示例。如果您正苦于以下问题:Java ManagedResource类的具体用法?Java ManagedResource怎么用?Java ManagedResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ManagedResource类属于org.springframework.jmx.export.metadata包,在下文中一共展示了ManagedResource类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getObjectName

import org.springframework.jmx.export.metadata.ManagedResource; //导入依赖的package包/类
/**
 * Reads the {@code ObjectName} from the source-level metadata associated
 * 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);
		}
		catch (MalformedObjectNameException ex) {
			String domain = this.defaultDomain;
			if (domain == null) {
				domain = ClassUtils.getPackageName(managedClass);
			}
			Hashtable<String, String> properties = new Hashtable<String, String>();
			properties.put("type", ClassUtils.getShortName(managedClass));
			properties.put("name", beanKey);
			return ObjectNameManager.getInstance(domain, properties);
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:MetadataNamingStrategy.java

示例2: getObjectName

import org.springframework.jmx.export.metadata.ManagedResource; //导入依赖的package包/类
/**
 * Reads the {@code ObjectName} from the source-level metadata associated
 * with the managed resource's {@code Class}.
 */
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);
		}
		catch (MalformedObjectNameException ex) {
			String domain = this.defaultDomain;
			if (domain == null) {
				domain = ClassUtils.getPackageName(managedClass);
			}
			Hashtable<String, String> properties = new Hashtable<String, String>();
			properties.put("type", ClassUtils.getShortName(managedClass));
			properties.put("name", beanKey);
			return ObjectNameManager.getInstance(domain, properties);
		}
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:29,代码来源:MetadataNamingStrategy.java

示例3: populateMBeanDescriptor

import org.springframework.jmx.export.metadata.ManagedResource; //导入依赖的package包/类
/**
 * Adds descriptor fields from the {@code ManagedResource} attribute
 * to the MBean descriptor. Specifically, adds the {@code currencyTimeLimit},
 * {@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());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:MetadataMBeanInfoAssembler.java

示例4: getManagedResource

import org.springframework.jmx.export.metadata.ManagedResource; //导入依赖的package包/类
@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;
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:12,代码来源:AnnotationJmxAttributeSource.java

示例5: getDescription

import org.springframework.jmx.export.metadata.ManagedResource; //导入依赖的package包/类
/**
 * 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() : "");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MetadataMBeanInfoAssembler.java


注:本文中的org.springframework.jmx.export.metadata.ManagedResource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。