javax.management.MalformedObjectNameException#getMessage ( )源码实例Demo

下面列出了javax.management.MalformedObjectNameException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tda   文件: MBeanDumper.java
/**
 * Constructs a ThreadMonitor object to get thread information
 * in a remote JVM.
 */
public MBeanDumper(MBeanServerConnection server) throws IOException {
   setMBeanServerConnection(server);
   try {
       objname = new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
    } catch (MalformedObjectNameException e) {
        // should not reach here
        InternalError ie = new InternalError(e.getMessage());
        ie.initCause(e);
        throw ie;
   }
   parseMBeanInfo(); 
}
 
源代码2 项目: attic-polygene-java   文件: JmxFixture.java
public boolean objectExists( String objName ) {
    try
    {
        ObjectName objectName = new ObjectName( prefix + objName );
        return server.isRegistered( objectName );
    }
    catch( MalformedObjectNameException ex )
    {
        throw new IllegalArgumentException( ex.getMessage(), ex );
    }
}
 
源代码3 项目: scriptella-etl   文件: JmxEtlManager.java
/**
 * Find ETL mbeans.
 *
 * @return set of object names.
 */
public static Set<ObjectName> findEtlMBeans() {
    try {
        return getMBeanServer().queryNames(new ObjectName(MBEAN_NAME_PREFIX + ",*"), null);
    } catch (MalformedObjectNameException e) {
        throw new IllegalStateException(e.getMessage(), e);
    }
}
 
源代码4 项目: cxf   文件: InstrumentationManagerImpl.java
private ObjectName getDelegateName() throws JMException {
    try {
        return (ObjectName)MBeanServerDelegate.class.getField("DELEGATE_NAME").get(null);
    } catch (Throwable t) {
        //ignore, likely on Java5
    }
    try {
        return new ObjectName("JMImplementation:type=MBeanServerDelegate");
    } catch (MalformedObjectNameException e) {
        JMException jme = new JMException(e.getMessage());
        jme.initCause(e);
        throw jme;
    }
}
 
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码6 项目: dragonwell8_jdk   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码7 项目: TencentKona-8   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码8 项目: jdk8u60   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码9 项目: JDKSourceCode1.8   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码10 项目: openjdk-jdk8u   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码12 项目: openjdk-jdk9   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码13 项目: jdk8u-jdk   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码14 项目: hottub   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码15 项目: openjdk-8-source   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码16 项目: openjdk-8   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码17 项目: jdk8u_jdk   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码18 项目: jdk8u-jdk   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}
 
源代码19 项目: jdk8u-dev-jdk   文件: ServerNotifForwarder.java
public Integer addNotificationListener(final ObjectName name,
    final NotificationFilter filter)
    throws InstanceNotFoundException, IOException {

    if (logger.traceOn()) {
        logger.trace("addNotificationListener",
            "Add a listener at " + name);
    }

    checkState();

    // Explicitly check MBeanPermission for addNotificationListener
    //
    checkMBeanPermission(name, "addNotificationListener");
    if (notificationAccessController != null) {
        notificationAccessController.addNotificationListener(
            connectionId, name, getSubject());
    }
    try {
        boolean instanceOf =
        AccessController.doPrivileged(
                new PrivilegedExceptionAction<Boolean>() {
                    public Boolean run() throws InstanceNotFoundException {
                        return mbeanServer.isInstanceOf(name, broadcasterClass);
                    }
        });
        if (!instanceOf) {
            throw new IllegalArgumentException("The specified MBean [" +
                name + "] is not a " +
                "NotificationBroadcaster " +
                "object.");
        }
    } catch (PrivilegedActionException e) {
        throw (InstanceNotFoundException) extractException(e);
    }

    final Integer id = getListenerID();

    // 6238731: set the default domain if no domain is set.
    ObjectName nn = name;
    if (name.getDomain() == null || name.getDomain().equals("")) {
        try {
            nn = ObjectName.getInstance(mbeanServer.getDefaultDomain(),
                                        name.getKeyPropertyList());
        } catch (MalformedObjectNameException mfoe) {
            // impossible, but...
            IOException ioe = new IOException(mfoe.getMessage());
            ioe.initCause(mfoe);
            throw ioe;
        }
    }

    synchronized (listenerMap) {
        IdAndFilter idaf = new IdAndFilter(id, filter);
        Set<IdAndFilter> set = listenerMap.get(nn);
        // Tread carefully because if set.size() == 1 it may be the
        // Collections.singleton we make here, which is unmodifiable.
        if (set == null)
            set = Collections.singleton(idaf);
        else {
            if (set.size() == 1)
                set = new HashSet<IdAndFilter>(set);
            set.add(idaf);
        }
        listenerMap.put(nn, set);
    }

    return id;
}