本文整理汇总了Java中javax.management.ObjectName.getCanonicalName方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectName.getCanonicalName方法的具体用法?Java ObjectName.getCanonicalName怎么用?Java ObjectName.getCanonicalName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.ObjectName
的用法示例。
在下文中一共展示了ObjectName.getCanonicalName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getListener
import javax.management.ObjectName; //导入方法依赖的package包/类
private NotificationListener getListener(ObjectName listener)
throws ListenerNotFoundException {
// ----------------
// Get listener object
// ----------------
DynamicMBean instance;
try {
instance = getMBean(listener);
} catch (InstanceNotFoundException e) {
throw EnvHelp.initCause(
new ListenerNotFoundException(e.getMessage()), e);
}
Object resource = getResource(instance);
if (!(resource instanceof NotificationListener)) {
final RuntimeException exc =
new IllegalArgumentException(listener.getCanonicalName());
final String msg =
"MBean " + listener.getCanonicalName() + " does not " +
"implement " + NotificationListener.class.getName();
throw new RuntimeOperationsException(exc, msg);
}
return (NotificationListener) resource;
}
示例2: getNotificationBroadcaster
import javax.management.ObjectName; //导入方法依赖的package包/类
private static <T extends NotificationBroadcaster>
T getNotificationBroadcaster(ObjectName name, Object instance,
Class<T> reqClass) {
if (reqClass.isInstance(instance))
return reqClass.cast(instance);
if (instance instanceof DynamicMBean2)
instance = ((DynamicMBean2) instance).getResource();
if (reqClass.isInstance(instance))
return reqClass.cast(instance);
final RuntimeException exc =
new IllegalArgumentException(name.getCanonicalName());
final String msg =
"MBean " + name.getCanonicalName() + " does not " +
"implement " + reqClass.getName();
throw new RuntimeOperationsException(exc, msg);
}
示例3: findObjectName
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Find the first MBean with given canonical name and type.
* @param mbs MBeanServerConnection to corresponding server
* @param canonicalNamePart canonical name you are looking for
* @param type given type for the object
* @return ObjectName or null (default)
*/
public static ObjectName findObjectName(final MBeanServerConnection mbs, final String canonicalNamePart, final String type){
try{
for(final ObjectName on: mbs.queryNames(null,null)){
final String fullObjectName = on.getCanonicalName();
if(fullObjectName.contains(canonicalNamePart)){ //check if the canonicalNamePart is ok
if(fullObjectName.contains(":type")){//make sure its a "valid" objectname
if(fullObjectName.split(":type")[1].contains(type)){//found your type
return on;
}
}
}
}
} catch (final IOException e) {
log.log(Level.WARNING, "IO Exception during browse for ObjectNames with canonicalNamePart and given type. \n"
+ "See Stacktrace for more Information",e);
}
return null;
}
示例4: registerMBean
import javax.management.ObjectName; //导入方法依赖的package包/类
@SuppressWarnings({
"unchecked", "rawtypes"
})
public static String registerMBean(final Object object) throws JMException {
final ObjectName objectName = generateMBeanName(object.getClass());
final MBeanServer context = ManagementFactory.getPlatformMBeanServer();
final String mbeanName = object.getClass().getName() + "MBean";
for (final Class c : object.getClass().getInterfaces()) {
if (mbeanName.equals(c.getName())) {
context.registerMBean(new AnnotatedStandardMBean(object, c), objectName);
return objectName.getCanonicalName();
}
}
context.registerMBean(object, objectName);
return objectName.getCanonicalName();
}
示例5: addNotificationListener
import javax.management.ObjectName; //导入方法依赖的package包/类
public void addNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object handback)
throws InstanceNotFoundException {
// ------------------------------
// ------------------------------
// ----------------
// Get listener object
// ----------------
DynamicMBean instance = getMBean(listener);
Object resource = getResource(instance);
if (!(resource instanceof NotificationListener)) {
throw new RuntimeOperationsException(new
IllegalArgumentException(listener.getCanonicalName()),
"The MBean " + listener.getCanonicalName() +
"does not implement the NotificationListener interface") ;
}
// ----------------
// Add a listener on an MBean
// ----------------
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER,
DefaultMBeanServerInterceptor.class.getName(),
"addNotificationListener",
"ObjectName = " + name + ", Listener = " + listener);
}
server.addNotificationListener(name,(NotificationListener) resource,
filter, handback) ;
}
示例6: addNotificationListener
import javax.management.ObjectName; //导入方法依赖的package包/类
public void addNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object handback)
throws InstanceNotFoundException {
// ------------------------------
// ------------------------------
// ----------------
// Get listener object
// ----------------
DynamicMBean instance = getMBean(listener);
Object resource = getResource(instance);
if (!(resource instanceof NotificationListener)) {
throw new RuntimeOperationsException(new
IllegalArgumentException(listener.getCanonicalName()),
"The MBean " + listener.getCanonicalName() +
" does not implement the NotificationListener interface") ;
}
// ----------------
// Add a listener on an MBean
// ----------------
if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
MBEANSERVER_LOGGER.log(Level.TRACE,
"ObjectName = " + name + ", Listener = " + listener);
}
server.addNotificationListener(name,(NotificationListener) resource,
filter, handback) ;
}