本文整理匯總了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) ;
}