本文整理汇总了Java中javax.management.NotificationBroadcaster.addNotificationListener方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationBroadcaster.addNotificationListener方法的具体用法?Java NotificationBroadcaster.addNotificationListener怎么用?Java NotificationBroadcaster.addNotificationListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.NotificationBroadcaster
的用法示例。
在下文中一共展示了NotificationBroadcaster.addNotificationListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
}
}
示例2: 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);
}
示例3: 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);
}
示例4: addNotificationListener
import javax.management.NotificationBroadcaster; //导入方法依赖的package包/类
public void addNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
throws InstanceNotFoundException {
// ------------------------------
// ------------------------------
if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
MBEANSERVER_LOGGER.log(Level.TRACE, "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);
}
示例5: addNotificationListener
import javax.management.NotificationBroadcaster; //导入方法依赖的package包/类
/**
* Registers the supplied listener with the specified management
* bean. Notifications emitted by the management bean are forwarded
* to the listener via the server, which will convert an MBean
* references in the source to a portable {@link ObjectName}
* instance. The notification is otherwise unchanged.
*
* @param name the name of the management bean with which the listener
* should be registered.
* @param listener the listener which will handle notifications from
* the bean.
* @param filter the filter to apply to incoming notifications, or
* <code>null</code> if no filtering should be applied.
* @param passback an object to be passed to the listener when a
* notification is emitted.
* @throws InstanceNotFoundException if the name of the management bean
* could not be resolved.
* @throws SecurityException if a security manager exists and the
* caller's permissions don't imply {@link
* MBeanPermission(String,String,ObjectName,String)
* <code>MBeanPermission(className, null, name,
* "addNotificationListener")</code>}.
* @see #removeNotificationListener(ObjectName, NotificationListener)
* @see #removeNotificationListener(ObjectName, NotificationListener,
* NotificationFilter, Object)
* @see NotificationBroadcaster#addNotificationListener(NotificationListener,
* NotificationFilter,
* Object)
*/
public void addNotificationListener(ObjectName name, NotificationListener listener,
NotificationFilter filter, Object passback)
throws InstanceNotFoundException
{
Object bean = getBean(name);
checkSecurity(name, null, "addNotificationListener");
if (bean instanceof NotificationBroadcaster)
{
NotificationBroadcaster bbean = (NotificationBroadcaster) bean;
NotificationListener indirection = new ServerNotificationListener(bean, name,
listener);
bbean.addNotificationListener(indirection, filter, passback);
LazyListenersHolder.listeners.put(listener, indirection);
}
}
示例6: addNotificationListener
import javax.management.NotificationBroadcaster; //导入方法依赖的package包/类
/**
* Registers the supplied listener with the specified management
* bean. Notifications emitted by the management bean are forwarded
* to the listener via the server, which will convert an MBean
* references in the source to a portable {@link ObjectName}
* instance. The notification is otherwise unchanged.
*
* @param name the name of the management bean with which the listener
* should be registered.
* @param listener the listener which will handle notifications from
* the bean.
* @param filter the filter to apply to incoming notifications, or
* <code>null</code> if no filtering should be applied.
* @param passback an object to be passed to the listener when a
* notification is emitted.
* @throws InstanceNotFoundException if the name of the management bean
* could not be resolved.
* @throws SecurityException if a security manager exists and the
* caller's permissions don't imply {@link
* MBeanPermission(String,String,ObjectName,String)
* <code>MBeanPermission(className, null, name,
* "addNotificationListener")</code>}.
* @see #removeNotificationListener(ObjectName, NotificationListener)
* @see #removeNotificationListener(ObjectName, NotificationListener,
* NotificationFilter, Object)
* @see NotificationBroadcaster#addNotificationListener(NotificationListener,
* NotificationFilter,
* Object)
*/
public void addNotificationListener(ObjectName name, NotificationListener listener,
NotificationFilter filter, Object passback)
throws InstanceNotFoundException
{
Object bean = getBean(name);
checkSecurity(name, null, "addNotificationListener");
if (bean instanceof NotificationBroadcaster)
{
NotificationBroadcaster bbean = (NotificationBroadcaster) bean;
NotificationListener indirection = new ServerNotificationListener(bean, name,
listener);
bbean.addNotificationListener(indirection, filter, passback);
LazyListenersHolder.listeners.put(listener, indirection);
}
}