本文整理汇总了Java中javax.management.NotificationEmitter.removeNotificationListener方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationEmitter.removeNotificationListener方法的具体用法?Java NotificationEmitter.removeNotificationListener怎么用?Java NotificationEmitter.removeNotificationListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.NotificationEmitter
的用法示例。
在下文中一共展示了NotificationEmitter.removeNotificationListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: exitImpl
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
private synchronized void exitImpl(int exitCode) {
if (exitHandler != null) {
try {
exitHandler.invoke(null, exitCode);
} catch (Throwable ignored) {
}
}
disabled = true;
if (timer != null) {
timer.cancel();
}
if (memoryListener != null && memoryMBean != null) {
NotificationEmitter emitter = (NotificationEmitter) memoryMBean;
try {
emitter.removeNotificationListener(memoryListener);
} catch (ListenerNotFoundException lnfe) {}
}
if (threadPool != null) {
threadPool.shutdownNow();
}
send(new ExitCommand(exitCode));
}
示例2: stopMonitoring
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
/**
* Stops all three mechanisms from monitoring heap usage.
*/
@Override
public void stopMonitoring() {
synchronized (this) {
if (!this.started) {
return;
}
// Stop the poller
this.resourceManager.stopExecutor(this.pollerExecutor);
// Stop the JVM threshold listener
NotificationEmitter emitter = (NotificationEmitter) ManagementFactory.getMemoryMXBean();
try {
emitter.removeNotificationListener(this, null, null);
this.cache.getLoggerI18n().fine("Removed Memory MXBean notification listener" + this);
} catch (ListenerNotFoundException e) {
this.cache.getLoggerI18n().fine(
"This instance '" + toString() + "' was not registered as a Memory MXBean listener");
}
// Stop the stats listener
final GemFireStatSampler sampler = this.cache.getDistributedSystem().getStatSampler();
if (sampler != null) {
sampler.removeLocalStatListener(this.statListener);
}
this.started = false;
}
}
示例3: removeNotificationListener
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
public void removeNotificationListener(
ObjectName name, NotificationListener listener,
NotificationFilter filter, Object handback)
throws InstanceNotFoundException, ListenerNotFoundException {
NotificationEmitter userMBean =
(NotificationEmitter) getMBean(name);
NotificationListener wrappedListener =
wrappedListener(name, userMBean, listener);
userMBean.removeNotificationListener(wrappedListener, filter, handback);
}
示例4: removeNotificationListener
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
private void removeNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback,
boolean removeAll)
throws InstanceNotFoundException, ListenerNotFoundException {
if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name);
}
DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, null, name, "removeNotificationListener");
/* We could simplify the code by assigning broadcaster after
assigning listenerWrapper, but that would change the error
behavior when both the broadcaster and the listener are
erroneous. */
Class<? extends NotificationBroadcaster> reqClass =
removeAll ? NotificationBroadcaster.class : NotificationEmitter.class;
NotificationBroadcaster broadcaster =
getNotificationBroadcaster(name, instance, reqClass);
NotificationListener listenerWrapper =
getListenerWrapper(listener, name, instance, false);
if (listenerWrapper == null)
throw new ListenerNotFoundException("Unknown listener");
if (removeAll)
broadcaster.removeNotificationListener(listenerWrapper);
else {
NotificationEmitter emitter = (NotificationEmitter) broadcaster;
emitter.removeNotificationListener(listenerWrapper,
filter,
handback);
}
}
示例5: stopMonitoring
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
/**
* Stops all three mechanisms from monitoring heap usage.
*/
@Override
public void stopMonitoring() {
synchronized (this) {
if (!this.started) {
return;
}
// Stop the poller
this.resourceManager.stopExecutor(this.pollerExecutor);
// Stop the JVM threshold listener
NotificationEmitter emitter = (NotificationEmitter) ManagementFactory.getMemoryMXBean();
try {
emitter.removeNotificationListener(this, null, null);
this.cache.getLoggerI18n().fine("Removed Memory MXBean notification listener" + this);
} catch (ListenerNotFoundException e) {
this.cache.getLoggerI18n().fine("This instance '" + toString() + "' was not registered as a Memory MXBean listener");
}
// Stop the stats listener
final GemFireStatSampler sampler = this.cache.getDistributedSystem().getStatSampler();
if (sampler != null) {
sampler.removeLocalStatListener(this.statListener);
}
this.started = false;
}
}
示例6: shutdown
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
public void shutdown() {
if (gcLogTailer != null) {
gcLogTailer.stop();
}
for (GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMXBeans) {
if (NotificationEmitter.class.isInstance(garbageCollectorMXBean)) {
NotificationEmitter emitter = NotificationEmitter.class.cast(garbageCollectorMXBean);
try {
emitter.removeNotificationListener(gcEventListener);
} catch (ListenerNotFoundException ignore) {
}
}
}
}
示例7: removeMemoryWarnings
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
public void removeMemoryWarnings() {
try {
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
NotificationEmitter emitter = (NotificationEmitter) memoryBean;
emitter.removeNotificationListener(this);
} catch (ListenerNotFoundException e) {
// do nothing
}
}
示例8: removeMemoryWarnings
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
public void removeMemoryWarnings() {
try {
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
NotificationEmitter emitter = (NotificationEmitter) memoryBean;
emitter.removeNotificationListener(this);
} catch (ListenerNotFoundException e) {
// do nothing
}
}
示例9: terminate
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
@Override
public void terminate() {
List<GarbageCollectorMXBean> gcMxBeans = java.lang.management.ManagementFactory.getGarbageCollectorMXBeans();
for (GarbageCollectorMXBean gcMxBean : gcMxBeans) {
NotificationEmitter emitter = (NotificationEmitter)gcMxBean;
try {
emitter.removeNotificationListener(listener);
} catch (ListenerNotFoundException e) {
//
}
}
}
示例10: stop
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
/** Stop collecting GC events. */
public synchronized void stop() {
Preconditions.checkState(notifListener != null, "logger has not been started");
for (GarbageCollectorMXBean mbean : ManagementFactory.getGarbageCollectorMXBeans()) {
if (mbean instanceof NotificationEmitter) {
final NotificationEmitter emitter = (NotificationEmitter) mbean;
try {
emitter.removeNotificationListener(notifListener);
} catch (ListenerNotFoundException e) {
LOGGER.warn("could not remove gc listener", e);
}
}
}
notifListener = null;
}
示例11: destroy
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
@Override
public void destroy() {
memoryMXBean = ManagementFactory.getMemoryMXBean();
NotificationEmitter emitter = (NotificationEmitter)memoryMXBean;
List<MemoryPoolMXBean> memPools = ManagementFactory.getMemoryPoolMXBeans();
for (MemoryPoolMXBean memoryPoolMXBean : memPools) {
try {
emitter.removeNotificationListener(this, null, memoryPoolMXBean);
} catch (Exception e) { }
}
}
示例12: removeNL
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
private void removeNL(NotificationEmitter b, NotificationFilter f, Object o) {
try {
b.removeNotificationListener(this, f, o);
} catch (ListenerNotFoundException e) {
fail(e);
}
}
示例13: close
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
@Override
public void close() throws IOException {
try {
// Remove notification listener
final NotificationEmitter notificationEmitter = (NotificationEmitter) ManagementFactory.getMemoryMXBean();
notificationEmitter.removeNotificationListener(this);
} catch (final ListenerNotFoundException ex) {
log.warn("Somebody else already removed the notification listener from the MemoryMXBean.", ex);
}
}
示例14: removeNotificationListener
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
private void removeNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback,
boolean removeAll)
throws InstanceNotFoundException, ListenerNotFoundException {
if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
MBEANSERVER_LOGGER.logp(Level.FINER,
DefaultMBeanServerInterceptor.class.getName(),
"removeNotificationListener", "ObjectName = " + name);
}
DynamicMBean instance = getMBean(name);
checkMBeanPermission(instance, null, name, "removeNotificationListener");
/* We could simplify the code by assigning broadcaster after
assigning listenerWrapper, but that would change the error
behavior when both the broadcaster and the listener are
erroneous. */
Class<? extends NotificationBroadcaster> reqClass =
removeAll ? NotificationBroadcaster.class : NotificationEmitter.class;
NotificationBroadcaster broadcaster =
getNotificationBroadcaster(name, instance, reqClass);
NotificationListener listenerWrapper =
getListenerWrapper(listener, name, instance, false);
if (listenerWrapper == null)
throw new ListenerNotFoundException("Unknown listener");
if (removeAll)
broadcaster.removeNotificationListener(listenerWrapper);
else {
NotificationEmitter emitter = (NotificationEmitter) broadcaster;
emitter.removeNotificationListener(listenerWrapper,
filter,
handback);
}
}
示例15: removeNotificationListener
import javax.management.NotificationEmitter; //导入方法依赖的package包/类
/**
* Removes the specified listener from the list of recipients
* of notifications from the supplied bean. Only the first instance with
* the supplied filter and passback object is removed.
* <code>null</code> is used as a valid value for these parameters,
* rather than as a way to remove all registration instances for
* the specified listener; for this behaviour instead, see
* {@link #removeNotificationListener(ObjectName, NotificationListener)}.
*
* @param name the name of the management bean from which the
* listener should be removed.
* @param listener the listener to remove.
* @param filter the filter of the listener to remove.
* @param passback the passback object of the listener to remove.
* @throws InstanceNotFoundException if the bean can not be found.
* @throws ListenerNotFoundException if the specified listener
* is not registered with the bean.
* @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,
* "removeNotificationListener")</code>}.
* @see #addNotificationListener(ObjectName, NotificationListener,
* NotificationFilter, Object)
* @see NotificationEmitter#removeNotificationListener(NotificationListener,
* NotificationFilter,
* Object)
*/
public void removeNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object passback)
throws InstanceNotFoundException, ListenerNotFoundException
{
Object bean = getBean(name);
checkSecurity(name, null, "removeNotificationListener");
if (bean instanceof NotificationEmitter)
{
NotificationEmitter bbean = (NotificationEmitter) bean;
bbean.removeNotificationListener(listener, filter, passback);
LazyListenersHolder.listeners.remove(listener);
}
}