javax.management.MBeanServerDelegate Java Examples

The following examples show how to use javax.management.MBeanServerDelegate. 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 File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #2
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #4
Source File: DelegateNameWildcardNameTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
 
Example #5
Source File: DelegateNameWildcardNameTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
    }
 
Example #6
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
    }

}
 
Example #7
Source File: ArrayNotificationBuffer.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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");
}
 
Example #8
Source File: RMIConnector.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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);
    }

}
 
Example #9
Source File: ArrayNotificationBuffer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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");
}
 
Example #10
Source File: DefaultMBeanServerInterceptor.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example #11
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #12
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #13
Source File: ArrayNotificationBuffer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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");
}
 
Example #14
Source File: OldMBeanServerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
OldMBeanServer(String defaultDomain, MBeanServerDelegate delegate) {
    this.defaultDomain = defaultDomain;
    this.delegate = delegate;
    try {
        registerMBean(delegate, MBeanServerDelegate.DELEGATE_NAME);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #15
Source File: ArrayNotificationBuffer.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void createListeners() {
    logger.debug("createListeners", "starts");

    synchronized (this) {
        createdDuringQuery = new HashSet<ObjectName>();
    }

    try {
        addNotificationListener(MBeanServerDelegate.DELEGATE_NAME,
                                creationListener, creationFilter, null);
        logger.debug("createListeners", "added creationListener");
    } catch (Exception e) {
        final String msg = "Can't add listener to MBean server delegate: ";
        RuntimeException re = new IllegalArgumentException(msg + e);
        EnvHelp.initCause(re, e);
        logger.fine("createListeners", msg + e);
        logger.debug("createListeners", e);
        throw re;
    }

    /* Spec doesn't say whether Set returned by QueryNames can be modified
       so we clone it. */
    Set<ObjectName> names = queryNames(null, broadcasterQuery);
    names = new HashSet<ObjectName>(names);

    synchronized (this) {
        names.addAll(createdDuringQuery);
        createdDuringQuery = null;
    }

    for (ObjectName name : names)
        addBufferListener(name);
    logger.debug("createListeners", "ends");
}
 
Example #16
Source File: JmxMBeanServer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <b>Package:</b> Creates an MBeanServer.
 * @param domain The default domain name used by this MBeanServer.
 * @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 metadata The MetaData object that will be used by the
 *        MBean server in order to invoke the MBean interface of
 *        the registered MBeans.
 * @param interceptors If <code>true</code>,
 *        {@link MBeanServerInterceptor} will be enabled (default is
 *        <code>false</code>).
 * @param fairLock If {@code true}, the MBean repository will use a {@link
 *        java.util.concurrent.locks.ReentrantReadWriteLock#ReentrantReadWriteLock(boolean)
 *        fair locking} policy.
 */
JmxMBeanServer(String domain, MBeanServer outer,
               MBeanServerDelegate    delegate,
               MBeanInstantiator      instantiator,
               boolean                interceptors,
               boolean                fairLock)  {

    if (instantiator == null) {
        final ModifiableClassLoaderRepository
            clr = new ClassLoaderRepositorySupport();
        instantiator = new MBeanInstantiator(clr);
    }

    final MBeanInstantiator fInstantiator = instantiator;
    this.secureClr = new
        SecureClassLoaderRepository(AccessController.doPrivileged(new PrivilegedAction<ClassLoaderRepository>() {
            @Override
            public ClassLoaderRepository run() {
                return fInstantiator.getClassLoaderRepository();
            }
        })
    );
    if (delegate == null)
        delegate = new MBeanServerDelegateImpl();
    if (outer == null)
        outer = this;

    this.instantiator = instantiator;
    this.mBeanServerDelegateObject = delegate;
    this.outerShell   = outer;

    final Repository repository = new Repository(domain);
    this.mbsInterceptor =
        new DefaultMBeanServerInterceptor(outer, delegate, instantiator,
                                          repository);
    this.interceptorsEnabled = interceptors;
    initialize();
}
 
Example #17
Source File: OldMBeanServerTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void unregisterMBean(ObjectName name)
throws InstanceNotFoundException, MBeanRegistrationException {

    forbidJMImpl(name);

    DynamicMBean mbean = getMBean(name);
    if (mbean == null)
        throw new InstanceNotFoundException(name.toString());

    MBeanRegistration reg = mbeanRegistration(mbean);
    try {
        reg.preDeregister();
    } catch (Exception e) {
        throw new MBeanRegistrationException(e);
    }
    if (!mbeans.remove(name, mbean))
        throw new InstanceNotFoundException(name.toString());
        // This is incorrect because we've invoked preDeregister

    Object userMBean = getUserMBean(mbean);
    if (userMBean instanceof ClassLoader)
        clr.removeLoader((ClassLoader) userMBean);

    Notification n = new MBeanServerNotification(
            MBeanServerNotification.REGISTRATION_NOTIFICATION,
            MBeanServerDelegate.DELEGATE_NAME,
            0,
            name);
    delegate.sendNotification(n);

    reg.postDeregister();
}
 
Example #18
Source File: ServerNotifForwarder.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example #19
Source File: MBeanServerBuilderImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public MBeanServer newMBeanServer(String defaultDomain,
                                  MBeanServer outer,
                                  MBeanServerDelegate delegate) {
    final MBeanServerForwarder mbsf =
        MBeanServerForwarderInvocationHandler.newProxyInstance();

    final MBeanServer innerMBeanServer =
        inner.newMBeanServer(defaultDomain,
                             (outer == null ? mbsf : outer),
                             delegate);

    mbsf.setMBeanServer(innerMBeanServer);
    return mbsf;
}
 
Example #20
Source File: MBeanServerMXBeanUnsupportedTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public MBeanServer newMBeanServer(
        String defaultDomain,
        MBeanServer outer,
        MBeanServerDelegate delegate) {
    final MBeanServerForwarder mbsf =
            MBeanServerForwarderInvocationHandler.newProxyInstance();

    final MBeanServer innerMBeanServer =
            inner.newMBeanServer(defaultDomain,
            (outer == null ? mbsf : outer),
            delegate);

    mbsf.setMBeanServer(innerMBeanServer);
    return mbsf;
}
 
Example #21
Source File: MBeanServerBuilderImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public MBeanServer newMBeanServer(String defaultDomain,
                                  MBeanServer outer,
                                  MBeanServerDelegate delegate) {
    final MBeanServerForwarder mbsf =
        MBeanServerForwarderInvocationHandler.newProxyInstance();

    final MBeanServer innerMBeanServer =
        inner.newMBeanServer(defaultDomain,
                             (outer == null ? mbsf : outer),
                             delegate);

    mbsf.setMBeanServer(innerMBeanServer);
    return mbsf;
}
 
Example #22
Source File: MBeanServerMXBeanUnsupportedTest.java    From native-obfuscator with GNU General Public License v3.0 5 votes vote down vote up
public MBeanServer newMBeanServer(
        String defaultDomain,
        MBeanServer outer,
        MBeanServerDelegate delegate) {
    final MBeanServerForwarder mbsf =
            MBeanServerForwarderInvocationHandler.newProxyInstance();

    final MBeanServer innerMBeanServer =
            inner.newMBeanServer(defaultDomain,
            (outer == null ? mbsf : outer),
            delegate);

    mbsf.setMBeanServer(innerMBeanServer);
    return mbsf;
}
 
Example #23
Source File: JmxMetricTracker.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws Exception {
    MBeanServer server = this.server;
    NotificationListener listener = this.listener;
    if (server != null && listener != null) {
        server.removeNotificationListener(MBeanServerDelegate.DELEGATE_NAME, listener);
    }
    Thread logManagerPropertyPoller = this.logManagerPropertyPoller;
    if (logManagerPropertyPoller != null) {
        logManagerPropertyPoller.interrupt();
    }
}
 
Example #24
Source File: MBeanServerBuilderImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public MBeanServer newMBeanServer(String defaultDomain,
                                  MBeanServer outer,
                                  MBeanServerDelegate delegate) {
    final MBeanServerForwarder mbsf =
        MBeanServerForwarderInvocationHandler.newProxyInstance();

    final MBeanServer innerMBeanServer =
        inner.newMBeanServer(defaultDomain,
                             (outer == null ? mbsf : outer),
                             delegate);

    mbsf.setMBeanServer(innerMBeanServer);
    return mbsf;
}
 
Example #25
Source File: ServerNotifForwarder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void snoopOnUnregister(NotificationResult nr) {
    List<IdAndFilter> copy = null;
    synchronized (listenerMap) {
        Set<IdAndFilter> delegateSet = listenerMap.get(MBeanServerDelegate.DELEGATE_NAME);
        if (delegateSet == null || delegateSet.isEmpty()) {
            return;
        }
        copy = new ArrayList<>(delegateSet);
    }

    for (TargetedNotification tn : nr.getTargetedNotifications()) {
        Integer id = tn.getListenerID();
        for (IdAndFilter idaf : copy) {
            if (idaf.id == id) {
                // This is a notification from the MBeanServerDelegate.
                Notification n = tn.getNotification();
                if (n instanceof MBeanServerNotification &&
                        n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
                    MBeanServerNotification mbsn = (MBeanServerNotification) n;
                    ObjectName gone = mbsn.getMBeanName();
                    synchronized (listenerMap) {
                        listenerMap.remove(gone);
                    }
                }
            }
        }
    }
}
 
Example #26
Source File: OldMBeanServerTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
OldMBeanServer(String defaultDomain, MBeanServerDelegate delegate) {
    this.defaultDomain = defaultDomain;
    this.delegate = delegate;
    try {
        registerMBean(delegate, MBeanServerDelegate.DELEGATE_NAME);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #27
Source File: RMIConnector.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException {
    NotificationFilterSupport clientFilter =
            new NotificationFilterSupport();
    clientFilter.enableType(
            MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
    MarshalledObject<NotificationFilter> sFilter =
        new MarshalledObject<NotificationFilter>(clientFilter);

    Integer[] listenerIDs;
    final ObjectName[] names =
        new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
    final MarshalledObject<NotificationFilter>[] filters =
        Util.cast(new MarshalledObject<?>[] {sFilter});
    final Subject[] subjects = new Subject[] {null};
    try {
        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);

    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);
    }
    return listenerIDs[0];
}
 
Example #28
Source File: MBeanServerMXBeanUnsupportedTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public MBeanServer newMBeanServer(
        String defaultDomain,
        MBeanServer outer,
        MBeanServerDelegate delegate) {
    final MBeanServerForwarder mbsf =
            MBeanServerForwarderInvocationHandler.newProxyInstance();

    final MBeanServer innerMBeanServer =
            inner.newMBeanServer(defaultDomain,
            (outer == null ? mbsf : outer),
            delegate);

    mbsf.setMBeanServer(innerMBeanServer);
    return mbsf;
}
 
Example #29
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException {
    NotificationFilterSupport clientFilter =
            new NotificationFilterSupport();
    clientFilter.enableType(
            MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
    MarshalledObject<NotificationFilter> sFilter =
        new MarshalledObject<NotificationFilter>(clientFilter);

    Integer[] listenerIDs;
    final ObjectName[] names =
        new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
    final MarshalledObject<NotificationFilter>[] filters =
        Util.cast(new MarshalledObject<?>[] {sFilter});
    final Subject[] subjects = new Subject[] {null};
    try {
        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);

    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);
    }
    return listenerIDs[0];
}
 
Example #30
Source File: JmxMBeanServer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <b>Package:</b> Creates an MBeanServer.
 * @param domain The default domain name used by this MBeanServer.
 * @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 metadata The MetaData object that will be used by the
 *        MBean server in order to invoke the MBean interface of
 *        the registered MBeans.
 * @param interceptors If <code>true</code>,
 *        {@link MBeanServerInterceptor} will be enabled (default is
 *        <code>false</code>).
 * @param fairLock If {@code true}, the MBean repository will use a {@link
 *        java.util.concurrent.locks.ReentrantReadWriteLock#ReentrantReadWriteLock(boolean)
 *        fair locking} policy.
 */
JmxMBeanServer(String domain, MBeanServer outer,
               MBeanServerDelegate    delegate,
               MBeanInstantiator      instantiator,
               boolean                interceptors,
               boolean                fairLock)  {

    if (instantiator == null) {
        final ModifiableClassLoaderRepository
            clr = new ClassLoaderRepositorySupport();
        instantiator = new MBeanInstantiator(clr);
    }

    final MBeanInstantiator fInstantiator = instantiator;
    this.secureClr = new
        SecureClassLoaderRepository(AccessController.doPrivileged(new PrivilegedAction<ClassLoaderRepository>() {
            @Override
            public ClassLoaderRepository run() {
                return fInstantiator.getClassLoaderRepository();
            }
        })
    );
    if (delegate == null)
        delegate = new MBeanServerDelegateImpl();
    if (outer == null)
        outer = this;

    this.instantiator = instantiator;
    this.mBeanServerDelegateObject = delegate;
    this.outerShell   = outer;

    final Repository repository = new Repository(domain);
    this.mbsInterceptor =
        new DefaultMBeanServerInterceptor(outer, delegate, instantiator,
                                          repository);
    this.interceptorsEnabled = interceptors;
    initialize();
}