本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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());
}
}
示例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;
}
示例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() : "");
}