/** * Creates a DefaultMBeanServerInterceptor with the specified * repository instance. * <p>Do not forget to call <code>initialize(outer,delegate)</code> * before using this object. * @param outer A pointer to the MBeanServer object that must be * passed to the MBeans when invoking their * {@link javax.management.MBeanRegistration} interface. * @param delegate A pointer to the MBeanServerDelegate associated * with the new MBeanServer. The new MBeanServer must register * this MBean in its MBean repository. * @param instantiator The MBeanInstantiator that will be used to * instantiate MBeans and take care of class loading issues. * @param repository The repository to use for this MBeanServer. */ public DefaultMBeanServerInterceptor(MBeanServer outer, MBeanServerDelegate delegate, MBeanInstantiator instantiator, Repository repository) { if (outer == null) throw new IllegalArgumentException("outer MBeanServer cannot be null"); if (delegate == null) throw new IllegalArgumentException("MBeanServerDelegate cannot be null"); if (instantiator == null) throw new IllegalArgumentException("MBeanInstantiator cannot be null"); if (repository == null) throw new IllegalArgumentException("Repository cannot be null"); this.server = outer; this.delegate = delegate; this.instantiator = instantiator; this.repository = repository; this.domain = repository.getDefaultDomain(); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType, ObjectName name) { // ------------------------------ // ------------------------------ // --------------------- // Create notification // --------------------- MBeanServerNotification notif = new MBeanServerNotification( NotifType,MBeanServerDelegate.DELEGATE_NAME,0,name); if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) { MBEANSERVER_LOGGER.logp(Level.FINER, DefaultMBeanServerInterceptor.class.getName(), "sendNotification", NotifType + " " + name); } delegate.sendNotification(notif); }
private void destroyListeners() { checkNoLocks(); logger.debug("destroyListeners", "starts"); try { removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME, creationListener); } catch (Exception e) { logger.warning("remove listener from MBeanServer delegate", e); } Set<ObjectName> names = queryNames(null, broadcasterQuery); for (final ObjectName name : names) { if (logger.debugOn()) logger.debug("destroyListeners", "remove listener from " + name); removeBufferListener(name); } logger.debug("destroyListeners", "ends"); }
protected void removeListenerForMBeanRemovedNotif(Integer id) throws IOException, InstanceNotFoundException, ListenerNotFoundException { try { connection.removeNotificationListeners( MBeanServerDelegate.DELEGATE_NAME, new Integer[] {id}, null); } catch (IOException ioe) { communicatorAdmin.gotIOException(ioe); connection.removeNotificationListeners( MBeanServerDelegate.DELEGATE_NAME, new Integer[] {id}, null); } }
public static void main(String[] args) throws Exception { System.out.println( "Test that <MBeanServerDelegate.DELEGATE_NAME> equals " + "<new ObjectName(\"JMImplementation:type=MBeanServerDelegate\")>"); final ObjectName delegateName = new ObjectName("JMImplementation:type=MBeanServerDelegate"); if (!delegateName.equals(MBeanServerDelegate.DELEGATE_NAME)) throw new AssertionError("Unexpected value: " + "MBeanServerDelegate.DELEGATE_NAME = " + MBeanServerDelegate.DELEGATE_NAME); System.out.println("MBeanServerDelegate.DELEGATE_NAME = " + "new ObjectName(\"" + delegateName + "\")"); System.out.println("Test that <ObjectName.WILDCARD> " + "equals <new ObjectName(\"*:*\")>"); final ObjectName wildcardName = new ObjectName("*:*"); if (!wildcardName.equals(ObjectName.WILDCARD)) throw new AssertionError("Unexpected value: " + "ObjectName.WILDCARD = " + ObjectName.WILDCARD); System.out.println("ObjectName.WILDCARD = " + "new ObjectName(\"" + wildcardName + "\")"); System.out.println("Test passes: constants were initialized properly"); }
/** * Sends an MBeanServerNotifications with the specified type for the * MBean with the specified ObjectName */ private void sendNotification(String NotifType, ObjectName name) { // ------------------------------ // ------------------------------ // --------------------- // Create notification // --------------------- MBeanServerNotification notif = new MBeanServerNotification( NotifType,MBeanServerDelegate.DELEGATE_NAME,0,name); if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { MBEANSERVER_LOGGER.log(Level.TRACE, NotifType + " " + name); } delegate.sendNotification(notif); }