本文整理汇总了Java中javax.management.NotificationBroadcaster类的典型用法代码示例。如果您正苦于以下问题:Java NotificationBroadcaster类的具体用法?Java NotificationBroadcaster怎么用?Java NotificationBroadcaster使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotificationBroadcaster类属于javax.management包,在下文中一共展示了NotificationBroadcaster类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNotificationBroadcaster
import javax.management.NotificationBroadcaster; //导入依赖的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);
}
示例2: isDefinitelyImmutableInfo
import javax.management.NotificationBroadcaster; //导入依赖的package包/类
static boolean isDefinitelyImmutableInfo(Class<?> implClass) {
if (!NotificationBroadcaster.class.isAssignableFrom(implClass))
return true;
synchronized (definitelyImmutable) {
Boolean immutable = definitelyImmutable.get(implClass);
if (immutable == null) {
final Class<NotificationBroadcasterSupport> nbs =
NotificationBroadcasterSupport.class;
if (nbs.isAssignableFrom(implClass)) {
try {
Method m = implClass.getMethod("getNotificationInfo");
immutable = (m.getDeclaringClass() == nbs);
} catch (Exception e) {
// Too bad, we'll say no for now.
return false;
}
} else
immutable = false;
definitelyImmutable.put(implClass, immutable);
}
return immutable;
}
}
示例3: findNotifications
import javax.management.NotificationBroadcaster; //导入依赖的package包/类
static MBeanNotificationInfo[] findNotifications(Object moi) {
if (!(moi instanceof NotificationBroadcaster))
return null;
MBeanNotificationInfo[] mbn =
((NotificationBroadcaster) moi).getNotificationInfo();
if (mbn == null)
return null;
MBeanNotificationInfo[] result =
new MBeanNotificationInfo[mbn.length];
for (int i = 0; i < mbn.length; i++) {
MBeanNotificationInfo ni = mbn[i];
if (ni.getClass() != MBeanNotificationInfo.class)
ni = (MBeanNotificationInfo) ni.clone();
result[i] = ni;
}
return result;
}
示例4: MemoryTileCache
import javax.management.NotificationBroadcaster; //导入依赖的package包/类
public MemoryTileCache() {
log = Logger.getLogger(this.getClass());
hashtable = new Hashtable<String, CacheEntry>(cacheSize);
lruTiles = new CacheLinkedListElement();
cacheSize = 500;
MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
NotificationBroadcaster emitter = (NotificationBroadcaster) mbean;
emitter.addNotificationListener(this, null, null);
// Set-up each memory pool to notify if the free memory falls below 10%
for (MemoryPoolMXBean memPool : ManagementFactory.getMemoryPoolMXBeans()) {
if (memPool.isUsageThresholdSupported()) {
MemoryUsage memUsage = memPool.getUsage();
memPool.setUsageThreshold((long) (memUsage.getMax() * 0.95));
}
}
}
示例5: addNotificationListener
import javax.management.NotificationBroadcaster; //导入依赖的package包/类
public void addNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
throws InstanceNotFoundException {
// ------------------------------
// ------------------------------
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER,
DefaultMBeanServerInterceptor.class.getName(),
"addNotificationListener", "ObjectName = " + name);
}
DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, null, name, "addNotificationListener");
NotificationBroadcaster broadcaster =
getNotificationBroadcaster(name, instance,
NotificationBroadcaster.class);
// ------------------
// Check listener
// ------------------
if (listener == null) {
throw new RuntimeOperationsException(new
IllegalArgumentException("Null listener"),"Null listener");
}
NotificationListener listenerWrapper =
getListenerWrapper(listener, name, instance, true);
broadcaster.addNotificationListener(listenerWrapper, filter, handback);
}
示例6: addNotificationListener
import javax.management.NotificationBroadcaster; //导入依赖的package包/类
public void addNotificationListener(
ObjectName name, NotificationListener listener,
NotificationFilter filter, Object handback)
throws InstanceNotFoundException {
NotificationBroadcaster userMBean =
(NotificationBroadcaster) getUserMBean(name);
NotificationListener wrappedListener =
wrappedListener(name, userMBean, listener);
userMBean.addNotificationListener(wrappedListener, filter, handback);
}