本文整理汇总了Java中javax.management.NotificationFilter类的典型用法代码示例。如果您正苦于以下问题:Java NotificationFilter类的具体用法?Java NotificationFilter怎么用?Java NotificationFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotificationFilter类属于javax.management包,在下文中一共展示了NotificationFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
public void removeNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback)
throws ListenerNotFoundException {
if (listener == null)
throw new ListenerNotFoundException(
"Notification listener is null");
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
}
if (generalBroadcaster == null)
throw new ListenerNotFoundException(
"No notification listeners registered");
generalBroadcaster.removeNotificationListener(listener,filter,
handback);
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
}
}
示例2: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
public void addNotificationListener(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
throws InstanceNotFoundException,
IOException {
final boolean debug = logger.debugOn();
if (debug)
logger.debug("addNotificationListener" +
"(ObjectName,NotificationListener,"+
"NotificationFilter,Object)",
"name=" + name
+ ", listener=" + listener
+ ", filter=" + filter
+ ", handback=" + handback);
final Integer listenerID =
addListenerWithSubject(name,
new MarshalledObject<NotificationFilter>(filter),
delegationSubject,true);
rmiNotifClient.addNotificationListener(listenerID, name, listener,
filter, handback,
delegationSubject);
}
示例3: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
public synchronized void addNotificationListener(Integer listenerID,
ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback,
Subject delegationSubject)
throws IOException, InstanceNotFoundException {
if (logger.traceOn()) {
logger.trace("addNotificationListener",
"Add the listener "+listener+" at "+name);
}
infoList.put(listenerID,
new ClientListenerInfo(listenerID,
name,
listener,
filter,
handback,
delegationSubject));
init(false);
}
示例4: getListenerId
import javax.management.NotificationFilter; //导入依赖的package包/类
public synchronized Integer
getListenerId(ObjectName name,
NotificationListener listener,
NotificationFilter filter,
Object handback)
throws ListenerNotFoundException, IOException {
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();
break;
}
}
if (id == null)
throw new ListenerNotFoundException("Listener not found");
return id;
}
示例5: Listener1
import javax.management.NotificationFilter; //导入依赖的package包/类
public Listener1(ObjectName name,
ObjectName listener, NotificationFilter filter, Object handback) {
this.name = name;
this.listener = listener;
this.filter = filter;
this.handback = handback;
HashCode hc = new HashCode();
hc.add(name);
hc.add(listener);
hc.add(filter);
hc.add(handback);
this.hashCode = hc.getHash();
}
示例6: Listener2
import javax.management.NotificationFilter; //导入依赖的package包/类
public Listener2(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) {
this.name = name;
this.listener = listener;
this.filter = filter;
this.handback = handback;
HashCode hc = new HashCode();
hc.add(name);
hc.add(listener);
hc.add(filter);
hc.add(handback);
this.hashCode = hc.getHash();
}
示例7: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
@Override
public synchronized void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter,
Object handback) throws InstanceNotFoundException {
mbs.addNotificationListener(name, listener, filter, handback);
Listener2 l = new Listener2(name, listener, filter, handback);
listeners.add(l);
listeners2.add(l);
}
示例8: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的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);
}
示例9: apply
import javax.management.NotificationFilter; //导入依赖的package包/类
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);
}
}
}
示例10: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
/**
* Add a notification event listener to this MBean.
*
* @param listener Listener that will receive event notifications
* @param filter Filter object used to filter event notifications
* actually delivered, or <code>null</code> for no filtering
* @param handback Handback object to be sent along with event
* notifications
*
* @exception IllegalArgumentException if the listener parameter is null
*/
@Override
public void addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback)
throws IllegalArgumentException {
if (listener == null)
throw new IllegalArgumentException("Listener is null");
if( log.isDebugEnabled() ) log.debug("addNotificationListener " + listener);
if (generalBroadcaster == null)
generalBroadcaster = new BaseNotificationBroadcaster();
generalBroadcaster.addNotificationListener
(listener, filter, handback);
// We'll send the attribute change notifications to all listeners ( who care )
// The normal filtering can be used.
// The problem is that there is no other way to add attribute change listeners
// to a model mbean ( AFAIK ). I suppose the spec should be fixed.
if (attributeBroadcaster == null)
attributeBroadcaster = new BaseNotificationBroadcaster();
if( log.isDebugEnabled() )
log.debug("addAttributeNotificationListener " + listener);
attributeBroadcaster.addNotificationListener
(listener, filter, handback);
}
示例11: removeNotificationListener
import javax.management.NotificationFilter; //导入依赖的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);
}
}
示例12: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
/**
* MBean Notification support
* You shouldn't update these methods
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
public void addNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback)
throws IllegalArgumentException {
broadcaster.addNotificationListener(listener, filter, handback);
}
示例13: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
/**
* Add a notification event listener to this MBean.
*
* @param listener
* Listener that will receive event notifications
* @param filter
* Filter object used to filter event notifications actually
* delivered, or <code>null</code> for no filtering
* @param handback
* Handback object to be sent along with event notifications
*
* @exception IllegalArgumentException
* if the listener parameter is null
*/
@Override
public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback)
throws IllegalArgumentException {
synchronized (entries) {
// Optimization to coalesce attribute name filters
if (filter instanceof BaseAttributeFilter) {
BaseAttributeFilter newFilter = (BaseAttributeFilter) filter;
Iterator<BaseNotificationBroadcasterEntry> items = entries.iterator();
while (items.hasNext()) {
BaseNotificationBroadcasterEntry item = items.next();
if ((item.listener == listener) && (item.filter != null)
&& (item.filter instanceof BaseAttributeFilter) && (item.handback == handback)) {
BaseAttributeFilter oldFilter = (BaseAttributeFilter) item.filter;
String newNames[] = newFilter.getNames();
String oldNames[] = oldFilter.getNames();
if (newNames.length == 0) {
oldFilter.clear();
} else {
if (oldNames.length != 0) {
for (int i = 0; i < newNames.length; i++)
oldFilter.addAttribute(newNames[i]);
}
}
return;
}
}
}
// General purpose addition of a new entry
entries.add(new BaseNotificationBroadcasterEntry(listener, filter, handback));
}
}
示例14: addNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
/**
* Enable to add an SNMP entry listener to this
* <CODE>SnmpMibTable</CODE>.
*
* <p>
* @param listener The listener object which will handle the
* notifications emitted by the registered MBean.
*
* @param filter The filter object. If filter is null, no filtering
* will be performed before handling notifications.
*
* @param handback The context to be sent to the listener when a
* notification is emitted.
*
* @exception IllegalArgumentException Listener parameter is null.
*/
@Override
public synchronized void
addNotificationListener(NotificationListener listener,
NotificationFilter filter, Object handback) {
// Check listener
//
if (listener == null) {
throw new java.lang.IllegalArgumentException
("Listener can't be null") ;
}
// looking for listener in handbackTable
//
Vector<Object> handbackList = handbackTable.get(listener) ;
Vector<NotificationFilter> filterList = filterTable.get(listener) ;
if ( handbackList == null ) {
handbackList = new Vector<>() ;
filterList = new Vector<>() ;
handbackTable.put(listener, handbackList) ;
filterTable.put(listener, filterList) ;
}
// Add the handback and the filter
//
handbackList.addElement(handback) ;
filterList.addElement(filter) ;
}
示例15: removeNotificationListener
import javax.management.NotificationFilter; //导入依赖的package包/类
public synchronized void removeNotificationListener(NotificationListener listener,
NotificationFilter filter,
Object handback)
throws ListenerNotFoundException
{
boolean before = hasListeners();
super.removeNotificationListener(listener,filter,handback);
boolean after = hasListeners();
if (before && !after) {
setNotificationEnabled(this,false);
}
}