public synchronized Integer
removeNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
throws ListenerNotFoundException, IOException {
if (logger.traceOn()) {
logger.trace("removeNotificationListener",
"Remove the listener "+listener+" from "+name);
}
beforeRemove();
Integer id = null;
List<ClientListenerInfo> values =
new ArrayList<ClientListenerInfo>(infoList.values());
for (int i=values.size()-1; i>=0; i--) {
ClientListenerInfo li = values.get(i);
if (li.sameAs(name, listener, filter, handback)) {
id=li.getListenerID();
infoList.remove(id);
break;
}
}
if (id == null)
throw new ListenerNotFoundException("Listener not found");
return id;
}
java类javax.management.NotificationFilter的实例源码
ClientNotifForwarder.java 文件源码
项目:OpenJSharp
阅读 22
收藏 0
点赞 0
评论 0
ServerNotifForwarder.java 文件源码
项目:OpenJSharp
阅读 22
收藏 0
点赞 0
评论 0
public void apply(List<TargetedNotification> targetedNotifs,
ObjectName source, Notification notif) {
// We proceed in two stages here, to avoid holding the listenerMap
// lock while invoking the filters (which are user code).
final IdAndFilter[] candidates;
synchronized (listenerMap) {
final Set<IdAndFilter> set = listenerMap.get(source);
if (set == null) {
logger.debug("bufferFilter", "no listeners for this name");
return;
}
candidates = new IdAndFilter[set.size()];
set.toArray(candidates);
}
// We don't synchronize on targetedNotifs, because it is a local
// variable of our caller and no other thread can see it.
for (IdAndFilter idaf : candidates) {
final NotificationFilter nf = idaf.getFilter();
if (nf == null || nf.isNotificationEnabled(notif)) {
logger.debug("bufferFilter", "filter matches");
final TargetedNotification tn =
new TargetedNotification(notif, idaf.getId());
if (allowNotificationEmission(source, tn))
targetedNotifs.add(tn);
}
}
}
ClientListenerInfo.java 文件源码
项目:OpenJSharp
阅读 22
收藏 0
点赞 0
评论 0
public ClientListenerInfo(Integer listenerID,
ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback,
Subject delegationSubject) {
this.listenerID = listenerID;
this.name = name;
this.listener = listener;
this.filter = filter;
this.handback = handback;
this.delegationSubject = delegationSubject;
}
OldMBeanServerTest.java 文件源码
项目:jdk8u-jdk
阅读 28
收藏 0
点赞 0
评论 0
public void addNotificationListener(
ObjectName name, ObjectName listener,
NotificationFilter filter, Object handback)
throws InstanceNotFoundException {
NotificationListener nl =
(NotificationListener) getUserMBean(listener);
addNotificationListener(name, nl, filter, handback);
}
NotificationSender.java 文件源码
项目:jdk8u-jdk
阅读 21
收藏 0
点赞 0
评论 0
public void removeNotificationListener(NotificationListener l,
NotificationFilter f,
Object h)
throws ListenerNotFoundException {
super.removeNotificationListener(l, f, h);
listenerCount--;
}
NotificationEmitterSupport.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
public void addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback) {
if (listener == null) {
throw new IllegalArgumentException ("Listener can't be null") ;
}
/* Adding a new listener takes O(n) time where n is the number
of existing listeners. If you have a very large number of
listeners performance could degrade. That's a fairly
surprising configuration, and it is hard to avoid this
behaviour while still retaining the property that the
listenerList is not synchronized while notifications are
being sent through it. If this becomes a problem, a
possible solution would be a multiple-readers single-writer
setup, so any number of sendNotification() calls could run
concurrently but they would exclude an
add/removeNotificationListener. A simpler but less
efficient solution would be to clone the listener list
every time a notification is sent. */
synchronized (listenerLock) {
List<ListenerInfo> newList = new ArrayList<>(listenerList.size() + 1);
newList.addAll(listenerList);
newList.add(new ListenerInfo(listener, filter, handback));
listenerList = newList;
}
}
DefaultMBeanServerInterceptor.java 文件源码
项目:jdk8u-jdk
阅读 25
收藏 0
点赞 0
评论 0
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);
}
JmxMBeanServer.java 文件源码
项目:openjdk-jdk10
阅读 19
收藏 0
点赞 0
评论 0
public void removeNotificationListener(ObjectName name,
ObjectName listener,
NotificationFilter filter,
Object handback)
throws InstanceNotFoundException, ListenerNotFoundException {
mbsInterceptor.removeNotificationListener(cloneObjectName(name),
listener, filter, handback);
}
RMIConnector.java 文件源码
项目:OpenJSharp
阅读 26
收藏 0
点赞 0
评论 0
public void
removeConnectionNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback)
throws ListenerNotFoundException {
if (listener == null)
throw new NullPointerException("listener");
connectionBroadcaster.removeNotificationListener(listener, filter,
handback);
}
NotificationSender.java 文件源码
项目:openjdk-jdk10
阅读 19
收藏 0
点赞 0
评论 0
public void removeNotificationListener(NotificationListener l,
NotificationFilter f,
Object h)
throws ListenerNotFoundException {
super.removeNotificationListener(l, f, h);
listenerCount--;
}