Java Code Examples for javax.management.NotificationListener
The following examples show how to use
javax.management.NotificationListener. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tomcatsrc Source File: BaseModelMBean.java License: Apache License 2.0 | 6 votes |
/** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ @Override public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { if (listener == null) throw new IllegalArgumentException("Listener is null"); if (generalBroadcaster != null) { generalBroadcaster.removeNotificationListener(listener); } if (attributeBroadcaster != null) { attributeBroadcaster.removeNotificationListener(listener); } }
Example 2
Source Project: openjdk-jdk9 Source File: OldMBeanServerTest.java License: GNU General Public License v2.0 | 6 votes |
private NotificationListener wrappedListener( ObjectName name, Object userMBean, NotificationListener userListener) throws InstanceNotFoundException { ListenerTable table = new ListenerTable(); ListenerTable oldTable = listenerMap.putIfAbsent(name, table); if (oldTable != null) table = oldTable; NotificationListener identityListener = new IdentityListener(userListener); synchronized (table) { NotificationListener rewriteListener = null; WeakReference<NotificationListener> wr = table.get(identityListener); if (wr != null) rewriteListener = wr.get(); if (rewriteListener == null) { rewriteListener = new RewriteListener( name, userMBean, identityListener); wr = new WeakReference<NotificationListener>(rewriteListener); table.put(identityListener, wr); } return rewriteListener; } }
Example 3
Source Project: Tomcat8-Source-Read Source File: BaseModelMBean.java License: MIT License | 6 votes |
/** * Remove a notification event listener from this MBean. * * @param listener The listener to be removed (any and all registrations * for this listener will be eliminated) * * @exception ListenerNotFoundException if this listener is not * registered in the MBean */ @Override public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { if (listener == null) throw new IllegalArgumentException("Listener is null"); if (generalBroadcaster != null) { generalBroadcaster.removeNotificationListener(listener); } if (attributeBroadcaster != null) { attributeBroadcaster.removeNotificationListener(listener); } }
Example 4
Source Project: openjdk-jdk8u-backup Source File: DefaultMBeanServerInterceptor.java License: GNU General Public License v2.0 | 6 votes |
private NotificationListener getListener(ObjectName listener) throws ListenerNotFoundException { // ---------------- // Get listener object // ---------------- DynamicMBean instance; try { instance = getMBean(listener); } catch (InstanceNotFoundException e) { throw EnvHelp.initCause( new ListenerNotFoundException(e.getMessage()), e); } Object resource = getResource(instance); if (!(resource instanceof NotificationListener)) { final RuntimeException exc = new IllegalArgumentException(listener.getCanonicalName()); final String msg = "MBean " + listener.getCanonicalName() + " does not " + "implement " + NotificationListener.class.getName(); throw new RuntimeOperationsException(exc, msg); } return (NotificationListener) resource; }
Example 5
Source Project: dragonwell8_jdk Source File: RequiredModelMBean.java License: GNU General Public License v2.0 | 6 votes |
/** * Removes a listener for Notifications from the RequiredModelMBean. * * @param listener The listener name which was handling notifications * emitted by the registered MBean. * This method will remove all information related to this listener. * * @exception ListenerNotFoundException The listener is not registered * in the MBean or is null. * * @see #addNotificationListener **/ public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { if (listener == null) throw new ListenerNotFoundException( "Notification listener is null"); final String mth="removeNotificationListener(NotificationListener)"; if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), mth, "Entry"); } if (generalBroadcaster == null) throw new ListenerNotFoundException( "No notification listeners registered"); generalBroadcaster.removeNotificationListener(listener); if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) { MODELMBEAN_LOGGER.logp(Level.FINER, RequiredModelMBean.class.getName(), mth, "Exit"); } }
Example 6
Source Project: TencentKona-8 Source File: OldMBeanServerTest.java License: GNU General Public License v2.0 | 6 votes |
private NotificationListener wrappedListener( ObjectName name, Object userMBean, NotificationListener userListener) throws InstanceNotFoundException { ListenerTable table = new ListenerTable(); ListenerTable oldTable = listenerMap.putIfAbsent(name, table); if (oldTable != null) table = oldTable; NotificationListener identityListener = new IdentityListener(userListener); synchronized (table) { NotificationListener rewriteListener = null; WeakReference<NotificationListener> wr = table.get(identityListener); if (wr != null) rewriteListener = wr.get(); if (rewriteListener == null) { rewriteListener = new RewriteListener( name, userMBean, identityListener); wr = new WeakReference<NotificationListener>(rewriteListener); table.put(identityListener, wr); } return rewriteListener; } }
Example 7
Source Project: openjdk-jdk8u-backup Source File: DefaultMBeanServerInterceptor.java License: GNU General Public License v2.0 | 6 votes |
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener instance = getListener(listener); if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "removeNotificationListener", "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance, filter, handback); }
Example 8
Source Project: jdk8u-jdk Source File: RMIConnector.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 9
Source Project: dragonwell8_jdk Source File: DefaultMBeanServerInterceptor.java License: GNU General Public License v2.0 | 6 votes |
private NotificationListener getListenerWrapper(NotificationListener l, ObjectName name, DynamicMBean mbean, boolean create) { Object resource = getResource(mbean); ListenerWrapper wrapper = new ListenerWrapper(l, name, resource); synchronized (listenerWrappers) { WeakReference<ListenerWrapper> ref = listenerWrappers.get(wrapper); if (ref != null) { NotificationListener existing = ref.get(); if (existing != null) return existing; } if (create) { ref = new WeakReference<ListenerWrapper>(wrapper); listenerWrappers.put(wrapper, ref); return wrapper; } else return null; } }
Example 10
Source Project: jdk8u60 Source File: DefaultMBeanServerInterceptor.java License: GNU General Public License v2.0 | 6 votes |
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener instance = getListener(listener); if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "removeNotificationListener", "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance, filter, handback); }
Example 11
Source Project: openjdk-jdk8u Source File: RMIConnector.java License: GNU General Public License v2.0 | 6 votes |
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); }
Example 12
Source Project: jdk8u_jdk Source File: DefaultMBeanServerInterceptor.java License: GNU General Public License v2.0 | 6 votes |
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener instance = getListener(listener); if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "removeNotificationListener", "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance, filter, handback); }
Example 13
Source Project: Tomcat7.0.67 Source File: BaseModelMBean.java License: Apache License 2.0 | 6 votes |
/** * Add an attribute change notification event listener to this MBean. * * @param listener Listener that will receive event notifications * @param name Name of the attribute of interest, or <code>null</code> * to indicate interest in all attributes * @param handback Handback object to be sent along with event * notifications * * @exception IllegalArgumentException if the listener parameter is null */ @Override public void addAttributeChangeNotificationListener (NotificationListener listener, String name, Object handback) throws IllegalArgumentException { if (listener == null) throw new IllegalArgumentException("Listener is null"); if (attributeBroadcaster == null) attributeBroadcaster = new BaseNotificationBroadcaster(); if( log.isDebugEnabled() ) log.debug("addAttributeNotificationListener " + listener); BaseAttributeFilter filter = new BaseAttributeFilter(name); attributeBroadcaster.addNotificationListener (listener, filter, handback); }
Example 14
Source Project: dragonwell8_jdk Source File: SnmpMibTable.java License: GNU General Public License v2.0 | 6 votes |
/** * Enable to remove an SNMP entry listener from this * <CODE>SnmpMibTable</CODE>. * * @param listener The listener object which will handle the * notifications emitted by the registered MBean. * This method will remove all the information related to this * listener. * * @exception ListenerNotFoundException The listener is not registered * in the MBean. */ @Override public synchronized void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { // looking for listener in handbackTable // java.util.Vector<?> handbackList = handbackTable.get(listener) ; if ( handbackList == null ) { throw new ListenerNotFoundException("listener"); } // If handback is null, remove the listener entry // handbackTable.remove(listener) ; filterTable.remove(listener) ; }
Example 15
Source Project: jdk8u_jdk Source File: MBeanServerAccessController.java License: GNU General Public License v2.0 | 5 votes |
/** * Call <code>checkRead()</code>, then forward this method to the * wrapped object. */ public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { checkRead(); getMBeanServer().removeNotificationListener(name, listener, filter, handback); }
Example 16
Source Project: dragonwell8_jdk Source File: NotificationEmitterSupport.java License: GNU General Public License v2.0 | 5 votes |
public ListenerInfo(NotificationListener listener, NotificationFilter filter, Object handback) { this.listener = listener; this.filter = filter; this.handback = handback; }
Example 17
Source Project: gemfirexd-oss Source File: MX4JModelMBean.java License: Apache License 2.0 | 5 votes |
public void removeAttributeChangeNotificationListener(NotificationListener listener, String attributeName) throws RuntimeOperationsException, ListenerNotFoundException { try { removeAttributeChangeNotificationListener(listener, attributeName, null); } catch (MBeanException e) { throw new RuntimeOperationsException(new RuntimeException(e.getMessage())); } }
Example 18
Source Project: openjdk-jdk8u-backup Source File: Basic.java License: GNU General Public License v2.0 | 5 votes |
/** * 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); }
Example 19
Source Project: openjdk-jdk8u Source File: OldMBeanServerTest.java License: GNU General Public License v2.0 | 5 votes |
public void removeNotificationListener( ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener nl = (NotificationListener) getUserMBean(listener); removeNotificationListener(name, nl, filter, handback); }
Example 20
Source Project: Tomcat8-Source-Read Source File: BaseModelMBean.java License: MIT License | 5 votes |
/** * 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); }
Example 21
Source Project: openjdk-jdk8u-backup Source File: RMIConnector.java License: GNU General Public License v2.0 | 5 votes |
public void addConnectionNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) { if (listener == null) throw new NullPointerException("listener"); connectionBroadcaster.addNotificationListener(listener, filter, handback); }
Example 22
Source Project: openjdk-jdk9 Source File: DefaultMBeanServerInterceptor.java License: GNU General Public License v2.0 | 5 votes |
public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException { // ------------------------------ // ------------------------------ // ---------------- // Get listener object // ---------------- DynamicMBean instance = getMBean(listener); Object resource = getResource(instance); if (!(resource instanceof NotificationListener)) { throw new RuntimeOperationsException(new IllegalArgumentException(listener.getCanonicalName()), "The MBean " + listener.getCanonicalName() + " does not implement the NotificationListener interface") ; } // ---------------- // Add a listener on an MBean // ---------------- if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name + ", Listener = " + listener); } server.addNotificationListener(name,(NotificationListener) resource, filter, handback) ; }
Example 23
Source Project: openjdk-jdk9 Source File: NotificationEmitterSupport.java License: GNU General Public License v2.0 | 5 votes |
public ListenerInfo(NotificationListener listener, NotificationFilter filter, Object handback) { this.listener = listener; this.filter = filter; this.handback = handback; }
Example 24
Source Project: openjdk-jdk9 Source File: GarbageCollectorExtImpl.java License: GNU General Public License v2.0 | 5 votes |
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); } }
Example 25
Source Project: hottub Source File: ClientNotifForwarder.java License: GNU General Public License v2.0 | 5 votes |
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; }
Example 26
Source Project: openjdk-jdk8u Source File: ClientNotifForwarder.java License: GNU General Public License v2.0 | 5 votes |
public synchronized Integer[] removeNotificationListener(ObjectName name, NotificationListener listener) throws ListenerNotFoundException, IOException { beforeRemove(); if (logger.traceOn()) { logger.trace("removeNotificationListener", "Remove the listener "+listener+" from "+name); } List<Integer> ids = new ArrayList<Integer>(); 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)) { ids.add(li.getListenerID()); infoList.remove(li.getListenerID()); } } if (ids.isEmpty()) throw new ListenerNotFoundException("Listener not found"); return ids.toArray(new Integer[0]); }
Example 27
Source Project: dragonwell8_jdk Source File: DefaultMBeanServerInterceptor.java License: GNU General Public License v2.0 | 5 votes |
public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException { // ------------------------------ // ------------------------------ // ---------------- // Get listener object // ---------------- DynamicMBean instance = getMBean(listener); Object resource = getResource(instance); if (!(resource instanceof NotificationListener)) { throw new RuntimeOperationsException(new IllegalArgumentException(listener.getCanonicalName()), "The MBean " + listener.getCanonicalName() + "does not implement the NotificationListener interface") ; } // ---------------- // Add a listener on an MBean // ---------------- if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "addNotificationListener", "ObjectName = " + name + ", Listener = " + listener); } server.addNotificationListener(name,(NotificationListener) resource, filter, handback) ; }
Example 28
Source Project: openjdk-jdk8u Source File: OldMBeanServerTest.java License: GNU General Public License v2.0 | 5 votes |
public void removeNotificationListener( ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException { NotificationBroadcaster userMBean = (NotificationBroadcaster) getUserMBean(name); NotificationListener wrappedListener = wrappedListener(name, userMBean, listener); userMBean.removeNotificationListener(wrappedListener); }
Example 29
Source Project: jdk8u60 Source File: CommunicatorServer.java License: GNU General Public License v2.0 | 5 votes |
/** * Removes the specified listener from this CommunicatorServer. * Note that if the listener has been registered with different * handback objects or notification filters, all entries corresponding * to the listener will be removed. * * @param listener The listener object to be removed. * * @exception ListenerNotFoundException The listener is not registered. */ @Override public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException { if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) { SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, dbgTag, "removeNotificationListener","Removing listener "+ listener); } notifBroadcaster.removeNotificationListener(listener); }
Example 30
Source Project: jdk8u_jdk Source File: ClientNotifForwarder.java License: GNU General Public License v2.0 | 5 votes |
void dispatchNotification(TargetedNotification tn, Integer myListenerID, Map<Integer, ClientListenerInfo> listeners) { final Notification notif = tn.getNotification(); final Integer listenerID = tn.getListenerID(); if (listenerID.equals(myListenerID)) return; final ClientListenerInfo li = listeners.get(listenerID); if (li == null) { logger.trace("NotifFetcher.dispatch", "Listener ID not in map"); return; } NotificationListener l = li.getListener(); Object h = li.getHandback(); try { l.handleNotification(notif, h); } catch (RuntimeException e) { final String msg = "Failed to forward a notification " + "to a listener"; logger.trace("NotifFetcher-run", msg, e); } }